Citus协调器与工作节点部署失败,请求协助排查问题
多节点Citus部署报错排查
服务器配置
| 节点类型 | 主机IP |
|---|---|
| 协调器(Coordinator) | 192.168.54.176 |
| 工作节点1(Worker_node1) | 192.168.54.117 |
| 工作节点2(Worker_node2) | 192.168.54.118 |
环境版本信息
| 信息项 | 版本号 |
|---|---|
| 操作系统(OS) | CentOS7.9 |
| PostgreSQL | 15.6 |
已安装扩展列表
postgres=# \dx 已安装扩展列表 name | version | schema | description ----------------+--------+------------+------------------------------ citus | 11.3-2 | pg_catalog | Citus分布式数据库扩展 citus_columnar | 11.3-1 | pg_catalog | Citus列式存储扩展 plpgsql | 1.0 | pg_catalog | PL/pgSQL过程化语言 (3行记录)
已完成的配置
- 修改
postgresql.conf设置listen_addresses = '*' pg_hba.conf配置如下:
# TYPE DATABASE USER ADDRESS METHOD # "local" 仅用于Unix域套接字连接 local all all trust # IPv4本地连接: host all all 127.0.0.1/32 trust host all all 0.0.0.0/0 trust # IPv6本地连接: host all all ::1/128 trust # 允许来自localhost的复制连接,使用具有复制权限的用户 local replication all trust host replication all 127.0.0.1/32 trust
执行命令及报错
- 协调器节点执行配置命令无返回内容:
postgres=# SELECT citus_set_coordinator_host('192.168.54.176', 5432); citus_set_coordinator_host ---------------------------- (1行记录)
- 添加工作节点时触发报错:
postgres=# SELECT * from citus_add_node('192.168.54.117', 5432); ERROR: Node cannot add itself as a worker. HINT: Add the node as a coordinator by using: SELECT citus_set_coordinator_host('192.168.54.117', 5432); postgres=# SELECT * from citus_add_node('192.168.54.118', 5432); ERROR: Node cannot add itself as a worker. HINT: Add the node as a coordinator by using: SELECT citus_set_coordinator_host('192.168.54.118', 5432);
遗漏步骤及解决方法
1. 所有节点必须预加载Citus库
在所有节点的postgresql.conf中添加或修改配置:
shared_preload_libraries = 'citus'
修改后重启PostgreSQL服务,这是Citus识别节点身份的核心配置,缺失会导致节点身份识别混乱。
2. 工作节点的正确配置流程
工作节点仅需完成以下操作,无需设置自身为协调器:
- 安装Citus扩展:
CREATE EXTENSION citus;
- 确保
postgresql.conf已设置listen_addresses = '*'和shared_preload_libraries = 'citus' - 重启PostgreSQL服务,确保配置生效
3. 协调器节点的验证操作
在协调器节点执行以下命令确认自身身份:
SELECT * FROM citus_get_local_node();
返回结果应显示协调器的IP(192.168.54.176),而非127.0.0.1或其他worker节点IP。如果显示错误,需重新执行citus_set_coordinator_host并重启服务。
4. 重新添加工作节点
完成上述配置后,回到协调器节点重新执行添加命令:
SELECT * from citus_add_node('192.168.54.117', 5432); SELECT * from citus_add_node('192.168.54.118', 5432);
添加成功后可执行以下命令验证节点状态:
SELECT * FROM citus_get_active_worker_nodes();
内容的提问来源于stack exchange,提问作者Ja L
相关产品推荐
相关产品推荐

