暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

AntDB 数据库分布式运维手册-集群节点管理6

tocata 2024-09-04
223

节点主备切换

最新版本的 AntDB 中,高可用由自愈模块自动完成,用户无需关注,因此本章节内容仅为用户手动执行的时候作为参考。

涉及到主备切换的命令有 3 个,分别是 failover、rewind、switchover,应用不同的场景。

故障切换

当主节点 down 了之后,通过 failover 命令实现 datanode、coordinator、gtmcoord 节点的主备切换。

antdb=# FAILOR DATANODE dn1_1; 
WARNING:  An exception occurred during the switching operation, It is recommended to use command such as 'monitor all', 'monitor ha' to check the failure point in the cluster first, and then retry the switching operation!!! 
ERROR:  Can't find a Synchronous standby node, Abort switching to avoid data loss 
antdb=# FAILOR DATANODE dn1_1 force; 
NOTICE:  dn1_3 have the best wal lsn, choose it as a candidate for promotion 
NOTICE:  gcn1 try lock cluster successfully 
NOTICE:  dn1_3 was successfully promoted to the new master 
NOTICE:  dn1_3 running on correct status of master mode 
NOTICE:  set GTM information on dn1_2 successfully 
NOTICE:  dn1_2 running on correct status of slave mode 
NOTICE:  dn1_1 is waiting for rewinding. If the doctor is enabled, the doctor will automatically rewind it 
NOTICE:  gcn1 try unlock cluster successfully 
NOTICE:  Switch the datanode master from dn1_1 to dn1_3 has been successfully completed 
 nodename | status |    description     
----------+--------+------------------- 
 dn1_3    | t      | promotion success 
(1 row) 

从操作中可以看到,如果 master 节点没有同步 slave 存在,则不允许进行 failover 操作,否则会造成数据丢失,需要使用 force 选项来进行强制切换。

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论