MHA实现mysql主从切换之主故障
2019/10/10/17:32:47 阅读:1900 来源:谷歌SEO算法 标签:
云计算
下面来给各位同学介绍一个MHA实现mysql主从切换之主故障,手动指定Master到从节点,希望例子能帮助各位解决问题.
本文主要模拟实现主Master故障后,手动指定Master到从节点.
- #masterha_master_switch--master_state=dead--conf=/etc/masterha/app1.cnf--dead_master_host=10.1.1.231--dead_master_ip=10.1.1.231--dead_master_port=63306--new_master_host=10.1.1.234--new_master_ip=10.1.1.234--new_master_port=63306
只显示如下日志,部分信息在附件,利用MHA实现mysql主从切换之主故障–手动指定Master到从节点的照片:
- -----FailoverReport-----
- app1:MySQLMasterfailover10.1.1.231to10.1.1.234succeeded
- Master10.1.1.231isdown!
- CheckMHAManagerlogsatcompute-0-52.localfordetails.
- Startedmanual(interactive)failover.
- Thelatestslave10.1.1.234(10.1.1.234:63306)hasallrelaylogsforrecovery.
- Selected10.1.1.234asanewmaster.
- 10.1.1.234:OK:Applyingalllogssucceeded.
- Generatingrelaydifffilesfromthelatestslavesucceeded.
- 10.1.1.234:Resettingslaveinfosucceeded.
- --phpfensi.com
- Masterfailoverto10.1.1.234(10.1.1.234:63306)completedsuccessfully.
此时从库已经变成主库,到10.1.1.234上查看如下信息:
- mysql>showmasterstatus;
- +------------------------+----------+--------------+--------------------------------------+-------------------+
- |File|Position|Binlog_Do_DB|Binlog_Ignore_DB|Executed_Gtid_Set|
- +------------------------+----------+--------------+--------------------------------------+-------------------+
- |mysql-slave-bin.000011|120|denovo_ng|mysql,denovo,test,information_schema||
- +------------------------+----------+--------------+--------------------------------------+-------------------+
- 1rowinset(0.00sec)
- mysql>
原主库恢复以后,添加它为Slave到Master/Slave集群里面,具体操作如下:
1、10.1.1.234(新主库)执行如下,可参考:
centos5.6下mysql5.6主从环境安装配置,http://www.diyoms.com/website/1318.html
grant replication slave on *.* to 'jpsync'@'10.1.1.231' identified by 'jppasswd';
flush privileges;
同时修改/etc/my.cnf添加如下:
skip_slave_start
注意:防止重启数据库,启动slave进程,导致数据不一致.
并删除master.info和relay-log.info.
2、10.1.1.231(新从库)上执行:
- changemastertomaster_host='10.1.1.234',master_port=63306,master_user='jpsync',
- master_password='jppasswd',master_log_file='mysql-master-bin.000011',master_log_pos=120;
这个时候再执行show slave statusG;后出现如下结果说明主从复制已经恢复.
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
热门评论