MySQL master-slave switch

Source: Internet
Author: User

In a master multi-slave environment, such as the main library is m, from the library to S1, S2, when the main library fails, the master-slave switch detailed steps are as follows:

1 First of all, ensure that all the updates from the relay log have been performed from the library, and use the following statements to view:

Mysql> Show Processlist\g

Until you see the following statement, all updates are executed.

Have read all relaylogwaiting for the slave I/O thread to update it

2 Execute the following statement on all from the library:

mysql> stop slave Io_thread;

3 on the S1 from the database, stop the service and then set the S1 as the primary database:

mysql> stop Slave;

mysql> Reset Master;

4 on S2 (if there are more than one, then on all slave servers, at this point S1 the primary server), stop from the service, then reset the S1 to the primary database, and then perform start slave start replication:

mysql> stop Slave;

mysql> Change Master to Master_host = ' 192.168.1.101 ';

mysql> start slave;

5 Modify the Client app to point to the S1 server:

6 Delete the Master.info and relay-log.info files on the S1 server (the new primary library server), or the restart will be initiated from the library as soon as it is restarted.

7 Finally, if the M server is restored, you can set the from library to S1 by S2 method.

Note: The above steps default S1 is enabled with the Log-bin option, and second, the Log-slave-updates parameter is not turned on S1.

This article from "10,000 years too long, seize" blog, please be sure to keep this source http://zengwj1949.blog.51cto.com/10747365/1923462

MySQL master-slave switch

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.