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