在本地虚拟机上装好了pxc,重启物理机之前没有正常关闭虚拟机上pxc。再次开启虚拟机无法启动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
无法从当前节点实现安全引导。原因是当前节点不是集群中最后离开的节点,也就是说当前节点可能未能包含所有的更新。
如果强制启动当前节点,需要修改grastate.dat文件将safe_to_bootstrap的值置为1。
咋一看,那就从另外一个节点启动吧。当前的集群仅仅配置了2个节点。遗憾的是另外一个节点也收到了同样的错误。
也就是只能强制启动了。
下面查看grastate.dat,该文件主要描述GALERA保持的状态信息,按指引修改safe_to_bootstrap的值置为1
grastate.dat文件默认在 /var/lib/mysql/下面
修改grastate.dat 的safe_to_bootstrap 的值为1 ,启动成功
另外一个错误:
[ERROR] WSREP: gcs/src/gcs_group.cpp:group_post_state_exchange():321: Reversing history: 10 -> 7,
this member has applied 3 more events than the primary component.Data loss is possible. Aborting.
查资料发现需要删除 /var/lib/mysql/grastate.dat 文件 ( 启动不了的节点上 ),然后启动即可。( 原因未知 )
mysql 在linux环境下 表名区分大小写问题:
修改变量lower-case-table-names
为什么会出现这个问题,主要是因为开发和测试环境不一致导致的,这也是有时测试环境完全没问题,一到生产就出诡异问题的原因之一。所以,我们除了让测试同事认真测试外,最好本地和测试环境还是一致。
对当前这个问题,我们直接修改SQL中的Emp
为emp
即可解决问题,但是为了根本解决问题,我们还须修改mysql的环境变量,也就是将lower_case_table_names的值改为0.
修改方法:
1. 找到mysql的安装位置
2. 找到主目录下的my.ini配置文件
3. 在[mysqld]节点下添加lower-case-table-names=0
4. 重启mysql服务