MySQL Galera集群的心跳间隔调整
当在两个数据中心之间部署galera的集群时,由于经常WAN的不稳定而导致galera产生脑裂而引发
集群重新选举,所在在网络不稳定的情况下,我们可以适当调整检查的间隔和心跳超时的参数.
150503 20:21:25 [Note] WSREP: (96ccaff4-f176-11e4-a670-d2ca25a9d25b, 'tcp://0.0.0.0:4567')
reconnecting to 10b99ae6-f18a-11e4-8e94-c37e3464d18c (tcp://192.168.10.215:4567), attempt 0
150503 20:21:26 [Note] WSREP: evs::proto(96ccaff4-f176-11e4-a670-d2ca25a9d25b, OPERATIONAL,
view_id(REG,10b99ae6-f18a-11e4-8e94-c37e3464d18c,6))
suspecting node: 10b99ae6-f18a-11e4-8e94-c37e3464d18c
...............................................
150503 20:21:36 [Note] WSREP: evs::proto(96ccaff4-f176-11e4-a670-d2ca25a9d25b, GATHER,
view_id(REG,10b99ae6-f18a-11e4-8e94-c37e3464d18c,6)) detected inactive
node: 10b99ae6-f18a-11e4-8e94-c37e3464d18c
150503 20:21:37 [Note] WSREP: view(view_id(NON_PRIM,10b99ae6-f18a-11e4-8e94-c37e3464d18c,6) memb {
96ccaff4-f176-11e4-a670-d2ca25a9d25b,0
默认的检查的间隔为0.5s,如果在10秒内没有返回就引发集群重新选举,如图在20:21:25开始挂起节点,在20:21:36
开始重新选举
在这种情况下我们可以选当修改参数
mysql> set global
-> wsrep_provider_options="evs.keepalive_period = PT3S;
"> evs.suspect_timeout = PT20S;
"> evs.inactive_timeout = PT1M;
"> evs.install_timeout = PT1M"
-> ;
Query OK, 0 rows affected (0.00 sec)
修改检查间隔为3秒,心跳超时为20秒.(修改/etc/my.cnf用永生效)
150503 21:30:49 [Note] WSREP: (96ccaff4-f176-11e4-a670-d2ca25a9d25b, 'tcp://0.0.0.0:4567')
reconnecting to 10b99ae6-f18a-11e4-8e94-c37e3464d18c (tcp://192.168.10.215:4567), attempt 0
150503 21:31:15 [Note] WSREP: evs::proto(96ccaff4-f176-11e4-a670-d2ca25a9d25b, OPERATIONAL, view_id(REG,10b99ae6-f18a-11e4-8e94-c37e3464d18c,11))
suspecting node: 10b99ae6-f18a-11e4-8e94-c37e3464d18c
.........................................
150503 21:31:35 [Note] WSREP: evs::proto(96ccaff4-f176-11e4-a670-d2ca25a9d25b, GATHER, view_id(REG,10b99ae6-f18a-11e4-8e94-c37e3464d18c,11))
detected inactive node: 10b99ae6-f18a-11e4-8e94-c37e3464d18c
150503 21:31:36 [Note] WSREP: view(view_id(NON_PRIM,10b99ae6-f18a-11e4-8e94-c37e3464d18c,11) memb {
96ccaff4-f176-11e4-a670-d2ca25a9d25b,0
} joined {
} left {
} partitioned {
10b99ae6-f18a-11e4-8e94-c37e3464d18c,0
在21:31:15开始挂起结点,在20秒后继续挂起,在21:31:36秒开始进行集群重新选举。