【发布时间】:2019-03-19 08:59:27
【问题描述】:
它是 cluster 的子部分,我正在构建。当我在 master 上执行 pcp_recovery_node 以使用命令从头开始构建备用时
pcp_recovery_node -h 193.185.83.119 -p 9898 -U postgres -n 1
这里,193.185.83.119 是贵宾。 它成功地在 node-b 上构建并启动了备用服务器(比如节点是 node-a 和 node-b),但同时上面的命令没有返回,只是挂在 shell 中,如下所示:-
[postgres@rollc-filesrvr1 数据]$ pcp_recovery_node -h 193.185.83.119 -p 9898 -U postgres -n 1 密码:
我必须使用 ctrl+c 退出此会话。 稍后当我尝试在 node-a (master) 上创建测试数据库时,出现以下错误:
postgres=# create database test; ERROR: source database "template1" is being accessed by other users DETAIL: There is 1 other session using the database.
我确认在 node-a 上运行此命令时 pgpool.service 正在运行,并且我已尝试在发出 pcp 命令之前在 node-b(备用)上使用 on/off pgpool.service。结果还是一样。
我还尝试了谷歌搜索并调整了 pgpool.conf 中的以下设置。我不确定是否可能与这些参数有关:
pgpool.conf 中的 wd_lifecheck_dbname
最初与上述相关的设置是(我得到的结果仍然相同):
wd_lifecheck_dbname = 'template1'
wd_lifecheck_user = 'nobody'
wd_lifecheck_password = ''
后来,我在here、here 找到了不同的设置,在here 找到了一个建议,并尝试了不同的组合,如下所示:
wd_lifecheck_dbname = 'template1'
wd_lifecheck_user = 'postgres'
wd_lifecheck_password = ''
或
wd_lifecheck_dbname = 'postgres'
wd_lifecheck_user = 'postgres'
wd_lifecheck_password = ''
但是没有人帮助改变 shell 上的情况,也不允许我在 master 上创建测试数据库。我觉得,我走到了死胡同。
我仍然无法完全理解 pgpool 中上述 3 个参数的目的和含义,并且不知何故怀疑这些是我配置不正确的参数,尽管也可能有其他原因。
只是为了帮助,这里又是环境细节。
- node-a 和 nod-b 环境:rhel 7.6
- postgres 版本:10.7
- pgpool-||版本:4.0.3
- 复制槽 + wal 存档
这是来自 node-a pgpool.service 的日志
Mar 18 21:10:17 node-a pgpool[16583]: 2019-03-18 21:10:17: pid 16642: LOG: forked new pcp worker, pid=8534 socket=7
Mar 18 21:10:17 node-a pgpool[16583]: 2019-03-18 21:10:17: pid 8534: LOG: starting recovering node 1
Mar 18 21:10:17 node-a pgpool[16583]: 2019-03-18 21:10:17: pid 8534: LOG: executing recovery
Mar 18 21:10:17 node-a pgpool[16583]: 2019-03-18 21:10:17: pid 8534: DETAIL: starting recovery command: "SELECT pgpool_recovery('recovery_1st_stage', 'node-a-ip', '/data/test/data', '5438', 1)"
Mar 18 21:10:17 node-a pgpool[16583]: 2019-03-18 21:10:17: pid 8534: LOG: executing recovery
Mar 18 21:10:17 node-a pgpool[16583]: 2019-03-18 21:10:17: pid 8534: DETAIL: disabling statement_timeout
Mar 18 21:10:18 node-a pgpool[16583]: 2019-03-18 21:10:18: pid 8534: LOG: node recovery, 1st stage is done
Mar 18 21:11:37 node-a pgpool[16583]: 2019-03-18 21:11:37: pid 8534: LOG: checking if postmaster is started
Mar 18 21:11:37 node-a pgpool[16583]: 2019-03-18 21:11:37: pid 8534: DETAIL: trying to connect to postmaster on hostname:node-b-ip database:postgres user:postgres (retry 0 times)
...
...2 more times
Mar 18 21:11:49 node-a pgpool[16583]: 2019-03-18 21:11:49: pid 8534: LOG: checking if postmaster is started
Mar 18 21:11:49 node-a pgpool[16583]: 2019-03-18 21:11:49: pid 8534: DETAIL: trying to connect to postmaster on hostname:node-a-ip database:template1 user:postgres (retry 0 times)
...it keeps on trying till i press ctrl+c on pcp command windows . I have seen it going upto 30 or more.
在使用 pgpool 检查时,node-b 也永远不会显示为 up。
postgres=> 显示 pool_nodes; 节点ID |主机名 |港口|状态 |磅重量 |角色 |选择_cnt |负载平衡节点 |复制延迟 | last_status_change ---------+----------------+------+--------+------ ----+---------+------------+-------+-- -----------------+------------------------ 0 |节点-a-ip | 5438 |向上 | 0.500000 |初级 | 0 |真实 | 0 | 2019-03-18 22:59:19 1 |节点-b-ip | 5438 | 向下 | 0.500000 |待机| 0 |假 | 0 | 2019-03-18 22:59:19 (2 行)
编辑 现在我至少能够更正此查询的最后一部分。即将备用节点添加到集群:
[postgres@node-a-hostname]$ pcp_attach_node -n 1 密码: pcp_attach_node -- 命令成功
现在最后一部分至少显示了正确的情况:
postgres=> 显示 pool_nodes; 节点ID |主机名 |港口|状态 |磅重量 |角色 |选择_cnt |负载平衡节点 |复制延迟 | last_status_change ---------+----------------+------+--------+------ ----+---------+------------+-------+-- -----------------+------------------------ 0 |节点-a-ip | 5438 |向上 | 0.500000 |初级 | 0 |假 | 0 | 2019-03-18 22:59:19 1 |节点-b-ip | 5438 | 向上 | 0.500000 |待机| 0 |真实 | 0 | 2019-03-19 11:38:38 (2 行)
但无法在 node1 上创建数据库的潜在问题仍然存在:
EDIT2:我尝试在 master 上插入和更新,它们已正确复制到 node2,但 create db 仍然无法正常工作。
【问题讨论】:
标签: postgresql database-replication high-availability postgresql-10 pgpool