postgresql 高可用 repmgr 的使用之八 常用的几个命令
stop pgsql
$ pg_ctl -D /var/lib/postgresql/9.6/main -m fast stop
或者
$ sudo pg_ctlcluster 9.6 main stop
clone standby
$ repmgr -h 192.168.56.101 -U repmgr -d repmgr -f /etc/repmgr.conf standby clone --dry-run --verbose
$ repmgr -h 192.168.56.101 -U repmgr -d repmgr -f /etc/repmgr.conf standby clone --verbose
start pgsql
$ sudo pg_ctlcluster 9.6 main start
register
$ repmgr -f /etc/repmgr.conf primary register --upstream-node-id=1 --verbose
$ repmgr -f /etc/repmgr.conf standby register --upstream-node-id=1 --verbose
$ repmgr -f /etc/repmgr.conf primary register --upstream-node-id=1 --force --verbose
$ repmgr -f /etc/repmgr.conf standby register --upstream-node-id=1 --force --verbose
switchover
$ repmgr -f /etc/repmgr.conf standby switchover --dry-run --force-rewind --siblings-follow --verbose
$ repmgr -f /etc/repmgr.conf standby switchover --force-rewind --siblings-follow --verbose
–siblings-follow 表示所有备份节点的 upstream 变更为新的master
promote
$ repmgr -f /etc/repmgr.conf standby promote --verbose
node rejoin
$ repmgr -f /etc/repmgr.conf node rejoin -d 'host=10.101.70.90 user=repmgr dbname=repmgr connect_timeout=2' --force-rewind --dry-run --verbose
$ repmgr -f /etc/repmgr.conf node rejoin -d 'host=10.101.70.90 user=repmgr dbname=repmgr connect_timeout=2' --force-rewind --verbose
cluster
$ repmgr -f /etc/repmgr.conf cluster show
$ repmgr -f /etc/repmgr.conf cluster crosscheck
$ repmgr -f /etc/repmgr.conf cluster event
$ repmgr -f /etc/repmgr.conf cluster event --event=repmgrd_start