非故障切换
当用户需要将原主机切换被备机,原备机切换为主机,可以使用 switchover 命令:
antdb=# SWITCHOR DATANODE SLAVE dn2_2;
NOTICE: wait max 10 seconds to wait there are no active connections on coordinators and master nodes
NOTICE: gcn1 try lock cluster successfully
NOTICE: wait max 10 seconds to check there are no active locks in pg_locks except the locks on pg_locks table
NOTICE: wait max 10 seconds to check dn2_1 and dn2_2 have the same xlog position
NOTICE: dn2_2 was successfully promoted to the new master
NOTICE: dn2_2 running on correct status of master mode
NOTICE: dn2_1 running on correct status of slave mode
NOTICE: gcn1 try unlock cluster successfully
NOTICE: Switch the datanode master from dn2_1 to dn2_2 has been successfully completed
nodename | status | description
----------+--------+-------------------
dn2_2 | t | promotion success
(1 row)
antdb=# list node dn2_2;
name | host | type | mastername | port | sync_state | path | initialized | incluster | readonly | zone
-------+-------+-----------------+------------+-------+------------+----------------------------------+-------------+-----------+----------+-------
dn2_2 | adb01 | datanode master | | 52542 | | /data/antdb/data/adb50/d2/dn2_2 | t | t | f | local
(1 row)
antdb=# list node dn2_1;
name | host | type | mastername | port | sync_state | path | initialized | incluster | readonly | zone
-------+-------+----------------+------------+-------+------------+----------------------------------+-------------+-----------+----------+-------
dn2_1 | adb01 | datanode slave | dn2_2 | 52541 | sync | /data/antdb/data/adb50/d1/dn2_1 | t | t | f | local
(1 row)
可以看到,主备之间发生了切换。
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




