MySQL Master-slave switching

Source: Internet
Author: User

Switch Master and slave:

    1. All updates in relay log have been executed from the library:

mysql> stop slave Io_thread;

Query OK, 0 rows affected (0.06 sec)


Mysql> Show Processlist\g

1. Row ***************************

Id:6

User:system User

Host:

Db:null

Command:connect

time:2144

State: Slave have read all relay log, waiting for the Slave I/O thread to update it

Info:null


2. Stop slave

mysql> stop slave Io_thread;

Query OK, 0 rows affected (0.06 sec)


[[email protected]/]# grep log-bin/data/3307/my.cnf

Log-bin=/data/3307/mysql3307-bin

[Email protected]/]#


[Email protected] ~]#/usr/bin/mysqladmin-p3307--socket=/data/3307/mysql.sock shutdown

[Email protected] ~]#/opt/mysql/bin/mysqld_safe--DEFAULTS-FILE=/DATA/3307/MY.CNF &

[Email protected] ~]#/usr/bin/mysql-p3307--socket=/data/3307/mysql.sock



3.reset Master

mysql> stop Slave;

Query OK, 0 rows affected (0.13 sec)


mysql> Reset Master;

Query OK, 0 rows affected (0.41 sec)


Mysql>



4. Delete Master.info Relay-log.info


5. From the library to open Log-bin, close log-slave-updates, close read-only.



MySQL Master-slave switching

Related Article

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.