You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS EKS集群中Apache Pinot的Python pinotdb连接超时问题求助

问题描述

我是Apache Pinot新手,在AWS EKS集群部署了Pinot,已暴露Controller服务,能通过链接访问控制台,也能调用部分Controller API。但按照官方文档用Python的pinotdb库连接时,出现超时错误。

使用的Python代码:

from pinotdb import connect

hosted='MyLinkConnection'
#Port=9000
Port=8098

def lambda_handler(event, context):
    conn = connect(host=hosted, port=Port, scheme='http')
    curs = conn.cursor()
    
    #curs.execute("select * from TestTable;")
    curs.execute("select * from TestTable_OFFLINE;")
    
    for row in curs:
        print(row)
    print('Gone')

返回的超时错误:

{
  "errorMessage": "timed out",
  "errorType": "ConnectTimeout",
  "stackTrace": [
    "  File \"/var/task/lambda_function.py\", line 15, in lambda_handler\n    curs.execute(\"select * from TestTable_OFFLINE;\")\n",
    "  File \"/opt/python/pinotdb/db.py\", line 57, in g\n    return f(self, *args, **kwargs)\n",
    "  File \"/opt/python/pinotdb/db.py\", line 490, in execute\n    **kwargs)\n",
    "  File \"/opt/python/httpx/_client.py\", line 1149, in post\n    extensions=extensions,\n",
    "  File \"/opt/python/httpx/_client.py\", line 821, in request\n    return self.send(request, auth=auth, follow_redirects=follow_redirects)\n",
    "  File \"/opt/python/httpx/_client.py\", line 912, in send\n    history=[],\n",
    "  File \"/opt/python/httpx/_client.py\", line 939, in _send_handling_auth\n    history=history,\n",
    "  File \"/opt/python/httpx/_client.py\", line 973, in _send_handling_redirects\n    response = self._send_single_request(request)\n",
    "  File \"/opt/python/httpx/_client.py\", line 1009, in _send_single_request\n    response = transport.handle_request(request)\n",
    "  File \"/opt/python/httpx/_transports/default.py\", line 218, in handle_request\n    resp = self._pool.handle_request(req)\n",
    "  File \"/var/lang/lib/python3.7/contextlib.py\", line 130, in __exit__\n    self.gen.throw(type, value, traceback)\n",
    "  File \"/opt/python/httpx/_transports/default.py\", line 77, in map_httpcore_exceptions\n    raise mapped_exc(message) from exc\n"
  ]
}

我能通过MyLinkConnection访问控制台,但需要解决Python环境下用pinotdb或JDBC连接Pinot的问题,目前已尝试暴露Controller、Broker、Server及ZooKeeper的对应端口。

排查与解决方案

1. 修正连接目标:指向Pinot Broker而非Controller

Pinot的查询请求必须发给Broker服务,Controller仅负责集群管理(如Schema/Table配置),不处理查询请求。你当前代码连接的8098是Controller的默认端口,这是超时的核心原因。

  • 调整代码端口为Broker的默认查询端口9000,同时确保Broker服务已正确暴露,且Python运行环境(如AWS Lambda)能访问Broker地址:
    from pinotdb import connect
    
    # 替换为Broker的实际地址
    hosted='MyBrokerConnection'
    Port=9000
    
    def lambda_handler(event, context):
        conn = connect(host=hosted, port=Port, scheme='http')
        curs = conn.cursor()
        curs.execute("select * from TestTable_OFFLINE limit 10;")
        
        for row in curs:
            print(row)
        print('Gone')
    

2. 验证网络连通性

从Python运行环境(如Lambda)测试到Broker的网络可达性:

# 测试Broker查询端点
curl -X POST http://<Broker地址>:9000/query/sql -d "sql=select * from TestTable_OFFLINE limit 1"
  • 若Lambda在VPC内,需确保EKS Broker服务的安全组允许Lambda所在VPC的流量访问9000端口;
  • 若Broker通过Ingress暴露,确认Ingress规则无拦截,路径转发正确。

3. JDBC连接配置(可选)

若改用JDBC连接,同样需指向Broker地址,URL格式如下:

jdbc:pinot://<Broker地址>:9000/

若启用HTTPS:

jdbc:pinot+https://<Broker地址>:<HTTPS端口>/

内容的提问来源于stack exchange,提问作者Valle1208

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 19:05:37