MariaDB Galera Cluster集群故障恢复

mariadb galera cluster集群故障恢复时,常常会遇到节点没法启动的状况,启动服务时报错:mysql

systemctl start mariadb
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.


通常状况下,若是集群中还有存活的节点,那么离线的节点只须要执行systemctl start mariadb便可从新加入集群,但若是全部节点均已离线,就会出现这种状况,此时须要人工肯定启动顺序,先检查每一个节点的/var/lib/mysql/grastate.dat文件,以测试环境为例,当前两节点上的mariadb服务均处于中止状态,grastate.dat的内容分别为:
sql

# GALERA saved state
version: 2.1
uuid:    44f8dbe5-1271-11eb-8206-1e1a48859dc8
seqno:   157035
safe_to_bootstrap: 0
# GALERA saved state
version: 2.1
uuid:    44f8dbe5-1271-11eb-8206-1e1a48859dc8
seqno:   157036
safe_to_bootstrap: 1


能够看到二者有相同的uuid,但seqno和safe_to_bootstrap不一样。集群中seqno最大的节点是优先启动节点,通常它的safe_to_bootstrap=1。此时以galera_new_cluster方式启动优先节点,而后再以systemctl start mariadb方式启动其它节点,集群就顺利恢复了。
bootstrap

相关文章
相关标签/搜索