办公室掉电,PXC集群环境无法启动,也就是说整个集群的状态处于丢失的情形。因此需要采取强制的方式来进行,见下面的描述。
一、故障现象
查看mysql错误日志如下:
2017-07-08 09:05:50 3913 [Note] WSREP: GCache history reset: old(0947d0da-4ffe-11e7-b169-137e84a69003:0) ->
new(0947d0da-4ffe-11e7-b169-137e84a69003:112047)
2017-07-08 09:05:50 3913 [Note] WSREP: Assign initial position for certification: 112047, protocol version: -1
2017-07-08 09:05:50 3913 [Note] WSREP: wsrep_sst_grab()
2017-07-08 09:05:50 3913 [Note] WSREP: Start replication
2017-07-08 09:05:50 3913 [Note] WSREP: Setting initial position to 0947d0da-4ffe-11e7-b169-137e84a69003:112047
2017-07-08 09:05:50 3913 [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 .
2017-07-08 09:05:50 3913 [ERROR] WSREP: wsrep::connect(gcomm://192.168.1.248,192.168.1.249,192.168.1.253) failed: 7
2017-07-08 09:05:50 3913 [ERROR] Aborting
2017-07-08 09:05:50 3913 [Note] WSREP: Service disconnected.
2017-07-08 09:05:50 3913 [Note] WSREP: Waiting to close threads......
2017-07-08 09:05:55 3913 [Note] WSREP: Some threads may fail to exit.
2017-07-08 09:05:55 3913 [Note] Binlog end
2017-07-08 09:05:55 3913 [Note] /usr/sbin/mysqld: Shutdown complete
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
二、故障分析及解决
最好的办法首先就是从日志定位问题的关键。如前所述,
[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 .
无法从当前节点实现安全引导。原因是当前节点不是集群中最后离开的节点,也就是说当前节点可能未能包含所有的更新。
如果强制启动当前节点,需要修改grastate.dat文件将safe_to_bootstrap的值置为1。
咋一看,那就从另外一个节点启动吧。当前的集群仅仅配置了2个节点。遗憾的是另外一个节点也收到了同样的错误。
也就是只能强制启动了。
下面查看grastate.dat,该文件主要描述GALERA保持的状态信息,按指引修改safe_to_bootstrap的值置为1
# more grastate.dat
# GALERA saved state
version: 2.1
uuid: 0947d0da-4ffe-11e7-b169-137e84a69003
seqno: -1
safe_to_bootstrap: 0
修改safe_to_bootstrap的值为1
# vi grastate.dat
再次启动正常
# /etc/init.d/mysql bootstrap-pxc
mysql> show variables like 'version';
+---------------+----------------+
| Variable_name | Value |
+---------------+----------------+
| version | 5.6.36-82.0-56 |
+---------------+----------------+
mysql> select 'Leshami' Author,'http://blog.csdn.net/leshami' Blog,
-> '645746311' QQ from dual;
+---------+------------------------------+-----------+
| Author | Blog | QQ |
+---------+------------------------------+-----------+
| Leshami | http://blog.csdn.net/leshami | 645746311 |
+---------+------------------------------+-----------+
mysql> show global status like 'wsrep_cluster%';
+--------------------------+--------------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------------+
| wsrep_cluster_conf_id | 2 |
| wsrep_cluster_size | 2 |
| wsrep_cluster_state_uuid | 0947d0da-4ffe-11e7-b169-137e84a69003 |
| wsrep_cluster_status | Primary |
+--------------------------+--------------------------------------+