Today, we tested MySQL's highly available architecture--mha, and performed automatic switching, manual failover, and manual online switching, where manual online switching found pits: When the old Master switched to a new slave, the READ_ONLY was not automatically set to ON, as illustrated below:
Environment Description:
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 | +---------------+-------+ |
Manual online Switching on the Mha-manager:
Masterha_master_switch--conf=/etc/masterha/app1.cnf--master_state=alive--orig_master_is_new_slave--interactive =0 &>/masterha/app1/manager.log Some information: [INFO] Switching master to 172.16.52.130 (172.16.52.130:3306) completed successfully. |
You can find the 172.16.52.130 Tangent main library (you can specify a new main library:--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 | +-----------+------+------+-----------+--------------------------------------+ |
View the original library-new from library parameters: 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 | +---------------+-------+ |
Summarize:
Discover switch from library to main library, close read_only, Main library switch to from library, open read_only, so after switch, need to manually modify new from library parameter
Set global read_only=on;
This article is from the "Floating Phoenix Year" blog, please be sure to keep this source http://liuzhanbin.blog.51cto.com/10060150/1641823
MySQL MHA Online Manual switching-small pits