MySQL Note Master-slave switch

Source: Internet
Author: User

One, normal switching

1) Check the output of the show Processlist statement from the server until you see have read all relaylogwaiting for the slave I/O thread to update it

2) Ensure that all statements in the log have been processed from the server. mysql> STOP SLAVE Io_thread

When these are done from the server, they can be reconfigured to a new setting.

3) on the slave server that is promoted to the primary server, issue the STOP slave and reset master and reset slave operations.

4) Then restart the MySQL service.

5) Create user grant replication Slave on * * [email protected] ' IP of A ' identified by ' replpwd ' in the standby server (new primary server)

Grant Allprivileges on * * to ' Repdcs ' @ ' IPs ' identified by REPLPWD;

6) Reset master on the primary server. Then change MASTER tomaster_host= ' original from server IP ', master_user= ' username ', master_password= ' password ', master_log_file= ' Master-bin.000015 ';

7) View status show slave status \g;

Show Master Status \g;

If not, restart the main library again and perform the change Master tomaster_host= ' 192.168.0.110 ', master_user= ' Repdcs ', master_password= ' 111111 ' on the standby, master_log_file= ' mysqlbin.000002 ';

8) Modify the app's connection address to the new main library

Switch is complete.

Second, host direct downtime

1> to perform stop SLAVE and reset MASTER on the standby machine

2> view show slave status \g;

3> then modifies the app's connection address.

Most of the switching to direct down the mainframe has been unable to provide services

MySQL Note 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.