当集群中所有节点都宕机后,集群再次启动后,能否自动选主
1、MGR集群所有节点都宕机后,集群重启,能否自动选主和启动MGR服务
这是个来自群友的问题。
首先,MySQL服务利用 systemd 即可实现故障后自启动,注意下面这个配置即可:
[root@GreatSQL ~]# cat /usr/lib/systemd/system/greatsql.service
...
Restart=on-failure
其次,mysqld进程启动后,想要实现MGR的自动选主及自启动也是可以的,利用MySQL Shell即可,例如:
[root@GreatSQL ~]# mysqlsh --uri greatsql@yejr-mgr3:3306
...
-- 不管干啥,都先看 help,这是玩转Linux的必备素养,啥事不清楚都先找男人(man)
-- 注意到有这样的一个方法 rebootClusterFromCompleteOutage(),看起来没跑了MySQL yejr-mgr3:3306 ssl JS > \help dba
rebootClusterFromCompleteOutage([clusterName][, options])
Brings a cluster back ONLINE when all members are OFFLINE.
-- 跑一个试试看
MySQL yejr-mgr3:3306 ssl JS > dba.rebootClusterFromCompleteOutage()
Restoring the default cluster from complete outage...
The instance 'yejr-mgr4:3306' was part of the cluster configuration.
Would you like to rejoin it to the cluster? [y/N]: y
The instance 'yejr-mgr2:3306' was part of the cluster configuration.
Would you like to rejoin it to the cluster? [y/N]: y
Dba.rebootClusterFromCompleteOutage: The active session instance (yejr-mgr3:3306) isn't the most updated in comparison with the ONLINE instances of the Cluster's metadata. Please use the most up to date instance: 'yejr-mgr4:3306'. (RuntimeError)
可以看到错误信息提示我们当前节点上没有最新的数据,不能直接启动MGR,错误信息中还提供了该去哪个节点启动的建议,所以我们改成在 yejr-mgr4 节点上执行拉起MGR:
MySQL集群故障恢复与多实例Router管理

最低0.47元/天 解锁文章
282

被折叠的 条评论
为什么被折叠?



