MHA realizes the main fault of MySQL master-slave switching

Source: Internet
Author: User

This article mainly simulates the implementation of master master failure by manually specifying master to from node.

#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

Only the following log is displayed, with some information in the attachment:

Use MHA to achieve MySQL master-slave switching main failure-Manually specify master to the photos from the node

-----Failover-----

App1:mysql Master failover 10.1.1.231 to 10.1.1.234 succeeded

Master 10.1.1.231 is down!

Check MHA Manager logs at compute-0-52.local for details.

Started manual (interactive) failover.

The latest slave 10.1.1.234 (10.1.1.234:63306) has all relay to logs for recovery.

Selected 10.1.1.234 as a new master.

10.1.1.234:ok:applying all logs succeeded.

Generating relay diff files from the latest slave succeeded.

10.1.1.234:resetting Slave info succeeded.

Master failover to 10.1.1.234 (10.1.1.234:63306) completed successfully.

At this point the library has become the main library, and the following information is viewed on the 10.1.1.234:

Mysql> Show master status;

+------------------------+----------+--------------+--------------------------------------+-------------------+

| File | Position | binlog_do_db | binlog_ignore_db | Executed_gtid_set |

+------------------------+----------+--------------+--------------------------------------+-------------------+

|      mysql-slave-bin.000011 | 120 | Denovo_ng |                   Mysql,denovo,test,information_schema | |

+------------------------+----------+--------------+--------------------------------------+-------------------+

1 row in Set (0.00 sec)

Mysql>

After the original repository is restored, add it as slave to the Master/slave cluster, as follows:

1, 10.1.1.234 (the new main library) to perform as follows:

can refer to:

centos5.6 under mysql5.6 Master-slave environment installation configuration http://www.diyoms.com/website/1318.html
 
Grant replication slave on *.* to ' Jpsync ' @ ' 10.1.1.231 ' identified by ' jppasswd ';
Flush privileges;
Also modify/ETC/MY.CNF to add the following:

 
Skip_slave_start
Note: Prevent restart of the database, start the slave process, resulting in inconsistent data.

and delete Master.info and Relay-log.info

2, 10.1.1.231 (new from the library) on the implementation:

 
Change Master to master_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;
This time again to perform show slave STATUSG, the following results showed that master-slave replication has been restored.

Slave_io_running:yes

Slave_sql_running:yes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.