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

多节点Citus部署连接问题排查:VirtualBox虚拟机配置咨询

多节点Citus部署连接问题排查

我是Citus新手,已通过VirtualBox创建三台虚拟机(1台协调器节点、2台工作节点),现在需要实现多节点Citus部署,但不清楚如何将节点连接起来,请求排查连接时出现的错误。以下是各节点的pg_hba.conf配置:

协调器节点(pg_hba.conf)

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                    trust
# IPv4 local connections:
host    all             all             127.0.0.1/32           trust
# Allow connections from the worker nodes
host    all             all             192.168.3.77/32         md5
host    all             all             192.168.3.187/32        md5
# IPv6 local connections:
host    all             all             ::1/128                trust

工作节点1(pg_hba.conf)

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                    trust
# IPv4 local connections:
host    all             all             127.0.0.1/32           trust
# Allow connections from the coordinator node
host    all             all             192.168.3.71/32         md5
# IPv6 local connections:
host    all             all             ::1/128                trust

工作节点2(pg_hba.conf)

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                    trust
# IPv4 local connections:
host    all             all             127.0.0.1/32           trust
# Allow connections from the coordinator node
host    all             all             192.168.3.71/32         md5
# IPv6 local connections:
host    all             all             ::1/128                trust

连接排查与配置调整建议

  • 验证节点网络连通性
    在协调器节点ping工作节点IP(192.168.3.77、192.168.3.187),在工作节点ping协调器IP(192.168.3.71),确认网络通畅。同时检查VirtualBox虚拟机的网络模式,建议使用桥接模式或内部网络,确保节点处于同一网段。

  • 调整PostgreSQL监听地址
    每个节点的postgresql.conf中,设置listen_addresses = '*'(或包含自身IP),否则PostgreSQL仅监听本地回环地址,外部节点无法连接。修改后重启PostgreSQL服务:sudo systemctl restart postgresql。

  • 验证认证配置
    当前跨节点连接使用md5认证,需确保三个节点的postgres用户(或Citus专用用户)密码一致。可临时将md5改为trust测试连接,排除认证问题后再改回md5保障安全。

  • 添加Citus工作节点
    在协调器节点以postgres用户登录PostgreSQL,执行以下命令添加工作节点:

    SELECT * FROM citus_add_node('192.168.3.77', 5432);
    SELECT * FROM citus_add_node('192.168.3.187', 5432);
    

    执行SELECT * FROM citus_get_active_worker_nodes();验证节点是否成功添加。

  • 开放防火墙端口
    每个节点需开放PostgreSQL默认端口5432:

    • Ubuntu/Debian:sudo ufw allow 5432
    • CentOS/RHEL:sudo firewall-cmd --add-port=5432/tcp --permanent && sudo firewall-cmd --reload

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.05 08:30:24