mariadb 集群 重启的几种情形

最近项目中遇到过一次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   Laijx  阅读(406)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
点击右上角即可分享
微信分享提示