最近项目中遇到过一次mariadb集群中三台节点有两台挂掉的情况。总结了一下mariadb集群可能遇到的几种情况需要重启。

 

环境说明:

mariadb集群ip:

10.0.101.51

10.0.101.64

10.0.101.69

 mariadb版本:10.7

 

 

情况一:集群中所有节点同时关闭:正常重启

第一台重启:

  galera_new_cluster

剩下节点启动:

  systemctl start mariadb

 

情况二、集群所有节点重启,但有一台最后关闭,且它的数据最新

这时候如果不是在最后一台关闭的服务器执行galera_new_cluster启动会报错:

2023-02-09 11:18:13 0 [ERROR] WSREP: It may not be safe to bootstrap the cluster from this node. It was not the last one to leave the cluster and may not contain all the updates. To force cluster bootstrap with this node, edit the grastate.dat file manually and set safe_to_bootstrap to 1 .

第一台执行:galera_new_cluster。报错

第三台执行:galera_new_cluster。报错

第二台执行:galera_new_cluster,正常启动,然后用systemctl start mariadb 启动剩下两台。

 

三、集群其中一两台重启,有一台一直运行。

直接在重启过的节点执行:systemctl start mariadb 即可

 

四、不推荐操作

不推荐有些博客说的修改  grastate.dat   中  seqno  和  safe_to_bootstrap  的值,然后不分青红皂白直接 galera_new_cluster 启动的方法。有可能造成数据丢失,或者systemctl status mariadb 显示异常的情况。

 posted on 2023-02-09 17:28  Laijx  阅读(311)  评论(0编辑  收藏  举报