码迷,mamicode.com
首页 > 数据库 > 详细

MySQL MHA在线手动切换——小坑

时间:2015-05-04 20:23:19      阅读:264      评论:0      收藏:0      [点我收藏+]

标签:mha 在线切换read_only

今天测试了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

MySQL MHA在线手动切换——小坑

标签:mha 在线切换read_only

原文地址:http://liuzhanbin.blog.51cto.com/10060150/1641823

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!