Apache Superset v2.0.0连接Trino v398失败,请求调试指导
- Apache Superset v2.0.0
- Trino v398
- Hive Metastore v3.1.3
我正尝试将Apache Superset连接至Trino(该Trino已通过Hive Metastore连接到S3),但所有连接尝试均失败,恳请提供调试方法。
trino://hive@10.241.68.10:8080/hive
SupersetErrorsException Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/databases/commands/test_connection.py", line 120, in run raise DBAPIError(None, None, None) sqlalchemy.exc.DBAPIError: (builtins.NoneType) None (Background on this error at: http://sqlalche.me/e/13/dbapi) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.8/site-packages/flask/app.py", line 1517, in full_dispatch_request rv = self.dispatch_request() File "/home/ubuntu/.local/lib/python3.8/site-packages/flask/app.py", line 1503, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "/home/ubuntu/.local/lib/python3.8/site-packages/flask_appbuilder/security/decorators.py", line 89, in wraps return f(self, *args, **kwargs) File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/views/base_api.py", line 113, in wraps raise ex File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/views/base_api.py", line 110, in wraps duration, response = time_function(f, self, *args, **kwargs) File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/utils/core.py", line 1507, in time_function response = func(*args, **kwargs) File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/utils/log.py", line 245, in wrapper value = f(*args, **kwargs) File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/views/base_api.py", line 83, in wraps return f(self, *args, **kwargs) File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/databases/api.py", line 709, in test_connection TestConnectionDatabaseCommand(g.user, item).run() File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/databases/commands/test_connection.py", line 145, in run raise DatabaseTestConnectionFailedError(errors) from ex superset.databases.commands.exceptions.DatabaseTestConnectionFailedError: [SupersetError(message='(builtins.NoneType) None (Background on this error at: http://sqlalche.me/e/13/dbapi)', error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'Trino', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})] 2022-10-07 23:58:44,966:WARNING:superset.views.base:SupersetErrorsException Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/databases/commands/test_connection.py", line 120, in run raise DBAPIError(None, None, None) sqlalchemy.exc.DBAPIError: (builtins.NoneType) None (Background on this error at: http://sqlalche.me/e/13/dbapi) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.8/site-packages/flask/app.py", line 1517, in full_dispatch_request rv = self.dispatch_request() File "/home/ubuntu/.local/lib/python3.8/site-packages/flask/app.py", line 1503, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "/home/ubuntu/.local/lib/python3.8/site-packages/flask_appbuilder/security/decorators.py", line 89, in wraps return f(self, *args, **kwargs) File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/views/base_api.py", line 113, in wraps raise ex File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/views/base_api.py", line 110, in wraps duration, response = time_function(f, self, *args, **kwargs) File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/utils/core.py", line 1507, in time_function response = func(*args, **kwargs) File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/utils/log.py", line 245, in wrapper value = f(*args, **kwargs) File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/views/base_api.py", line 83, in wraps return f(self, *args, **kwargs) File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/databases/api.py", line 709, in test_connection TestConnectionDatabaseCommand(g.user, item).run() File "/home/ubuntu/.local/lib/python3.8/site-packages/superset/databases/commands/test_connection.py", line 145, in run raise DatabaseTestConnectionFailedError(errors) from ex superset.databases.commands.exceptions.DatabaseTestConnectionFailedError: [SupersetError(message='(builtins.NoneType) None (Background on this error at: http://sqlalche.me/e/13/dbapi)', error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'Trino', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})]
1. 基础连通性验证
在Superset服务器上执行telnet 10.241.68.10 8080或nc -zv 10.241.68.10 8080,确认网络无防火墙/安全组拦截,能正常访问Trino端口。如果Trino启用SSL,连接字符串需追加?ssl=true,同时确保Superset安装了trino[ssl]依赖。
2. 直接测试Trino连接
在Superset服务器用Trino CLI连接:trino --server 10.241.68.10:8080 --catalog hive --user hive,执行show schemas;验证连接有效性。如果CLI连不上,优先排查Trino配置或网络问题。
3. 检查Superset的Trino依赖版本
执行pip show trino-python-client确认依赖版本,Superset 2.0.0建议匹配0.300.x系列版本(适配Trino 300+)。版本不兼容则卸载重装:pip uninstall trino-python-client && pip install trino-python-client==0.300.0。
4. 查看Trino服务器日志
登录Trino服务器,查看var/log/trino/server.log,搜索Superset连接请求相关日志,定位是否存在认证失败、权限不足等具体错误。
5. 核对连接字符串与Trino配置
确认连接字符串中的catalog为hive,且Trino的etc/catalog/hive.properties文件中hive.metastore.uri配置正确,Hive Metastore服务正常运行。若Trino需密码认证,需在连接字符串中添加密码或在Superset连接配置的密码字段填写。
6. 启用Superset调试日志
修改superset_config.py添加以下配置:
import logging logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger('trino') logger.setLevel(logging.DEBUG)
重启Superset后重新测试连接,通过详细日志定位具体错误。
内容的提问来源于stack exchange,提问作者Erik

