MySQL MHA在线手动切换——小坑
今天测试了MySQL的高可用架构--MHA,并进行了自动切换、手动failover以及手动在线切换,其中手动在线切换发现小坑:当旧master切换为新slave后,没有自动将read_only设置为on,例证如下:
环境说明:
OS:CentOS release 6.5
MySQL: 5.6.22-71.0-log Percona Server
slave1:172.16.52.130
mysql> show variables like ‘read_only‘; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | read_only | ON | +---------------+------- |
slave2:172.16.52.132
mysql> show variables like ‘read_only‘; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | read_only | ON | +---------------+-------+ |
master:172.16.52.131
mysql> show variables like ‘read_only‘; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | read_only | OFF | +---------------+-------+ |
在MHA-manager上进行手动在线切换:
masterha_master_switch --conf=/etc/masterha/app1.cnf --master_state=alive --orig_master_is_new_slave --interactive=0 &>/masterha/app1/manager.log 部分信息: [info] Switching master to 172.16.52.130(172.16.52.130:3306) completed successfully. |
可以发现172.16.52.130切位主库(可以指定新主库:--new_master_host=IP,--new_master_port=PORT)
mysql> show slave hosts; +-----------+------+------+-----------+--------------------------------------+ | Server_id | Host | Port | Master_id | Slave_UUID | +-----------+------+------+-----------+--------------------------------------+ | 132 | | 3306 | 130 | e173b5bf-e286-11e4-8d56-000c29c78a39 | | 131 | | 3306 | 130 | 18f4bdc7-e285-11e4-8d4a-000c298dfc24 | +-----------+------+------+-----------+--------------------------------------+ |
查看原主库-新从库的参数:172.16.52.131
mysql> show variables like ‘read_only‘; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | read_only | OFF | +---------------+-------+ |
slave 2:172.16.52.132
mysql> show variables like ‘read_only‘; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | read_only | ON | +---------------+-------+ |
master:172.16.52.130
mysql> show variables like ‘read_only‘; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | read_only | OFF | +---------------+-------+ |
总结:
发现从库切换为主库,关闭read_only,主库切换为从库,为打开read_only,所以切换完后,需要手动修改新的从库参数
set global read_only=on;
本文出自 “浮生凤年” 博客,请务必保留此出处http://liuzhanbin.blog.51cto.com/10060150/1641823
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。