执行注册主节点,提示不能注销,下游还有节点????下游节点都已经成了主节点了,还不能自己识别????
[postgres@db223 data]$ repmgr -f /home/postgres/repmgr/repmgr.conf primary unregister
ERROR: 1 other node still has this node as its upstream node
HINT: ensure these nodes are following the current primary with "repmgr standby follow"
DETAIL: the affected node(s) are:
db206 (ID: 2)
那就执行重新加入集群操作
[postgres@db223 data]$ repmgr -f ~/repmgr/repmgr.conf node rejoin -d 'host=db206 port=5432 user=repmgr dbname=repmgr password=repmgr' --force-rewind
ERROR: database is still running in state "in production"
HINT: "repmgr node rejoin" cannot be executed on a running node
提示必须关闭数据库
[postgres@db223 data]$ pg_ctl stop
waiting for server to shut down.... done
server stopped
再次重新加入集群
[postgres@db223 data]$ repmgr -f ~/repmgr/repmgr.conf node rejoin -d 'host=db206 port=5432 user=repmgr dbname=repmgr password=repmgr' --force-rewind
NOTICE: rejoin target is node "db206" (ID: 2)
NOTICE: pg_rewind execution required for this node to attach to rejoin target node 2
DETAIL: rejoin target server's timeline 12 forked off current database system timeline 11 before current recovery point 120/6E3B2810
NOTICE: executing pg_rewind
DETAIL: pg_rewind command is "/home/postgres/pg14/bin/pg_rewind -D '/home/postgres/pg14/data' --source-server='host=db206 dbname=repmgr user=repmgr password=repmgr connect_timeout=2'"
NOTICE: 0 files copied to /home/postgres/pg14/data
NOTICE: setting node 1's upstream to node 2
WARNING: unable to ping "host=db223 dbname=repmgr user=repmgr password=repmgr connect_timeout=2"
DETAIL: PQping() returned "PQPING_NO_RESPONSE"
NOTICE: starting server using "/home/postgres/pg14/bin/pg_ctl -w -D '/home/postgres/pg14/data' start"
WARNING: unable to ping "host=db223 dbname=repmgr user=repmgr password=repmgr connect_timeout=2"
DETAIL: PQping() returned "PQPING_REJECT"
NOTICE: NODE REJOIN successful
DETAIL: node 1 is now attached to node 2
自动启动数据库,再次查看集群信息
[postgres@db206 ~]$ repmgr -f ~/repmgr/repmgr.conf cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+-------+---------+-----------+----------+----------+----------+----------+------------------------------------------------------------------------
1 | db223 | standby | running | db206 | default | 100 | 11 | host=db223 dbname=repmgr user=repmgr password=repmgr connect_timeout=2
2 | db206 | primary | * running | | default | 100 | 12 | host=db206 dbname=repmgr user=repmgr password=repmgr connect_timeout=2