首页  :: 新随笔  :: 管理

MariaDB Galera Cluster全部节点宕机后恢复

Posted on 2022-05-12 22:48  高&玉  阅读(647)  评论(0编辑  收藏  举报

问题背景

操作系统:CentOS 7.6

DB版本:MariaDB 10.3.20

DB架构:MariaDB Galera Cluster(3个节点)

 

MariaDB Galera Cluster三个节点所在操作系统全部reboot。 

 

启动mariadb.service服务报错如下:

2022-05-12 17:12:55 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 .
2022-05-12 17:12:55 0 [ERROR] WSREP: wsrep::connect(gcomm://172.18.143.110,172.18.143.111,172.18.143.112) failed: 7
2022-05-12 17:12:55 0 [ERROR] Aborting

解决办法

通过last -x reboot命令查看三个节点操作系统重启的时间,可以确认节点3是最后一个关闭数据库服务:

  • 节点1: 2022年4月23日 18:21
  • 节点2: 2022年4月23日 18:19
  • 节点3: 2022年4月23日 18:30

 

三个节点的grastate.dat文件内容一致:

cat /var/lib/mysql/grastate.dat
# GALERA saved state
version: 2.1
uuid:    00000000-0000-0000-0000-000000000000    #不包括此行
seqno:   -1
safe_to_bootstrap: 0

 

三个节点的mariadb.service服务为非正常关闭:

seqno:   -1
safe_to_bootstrap: 0

 

修改MariaDB安全引导参数:

[root]# vi /var/lib/mysql/grastate.dat
safe_to_bootstrap: 1

 

依次启动mariadb.service集群恢复正常。

 

 参考:https://galeracluster.com/library/training/tutorials/restarting-cluster.html