Switch Master and slave:
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