MYSQL master/master switchover (master database not down) bitsCN.com
MYSQL master/master switchover (master database not down)
Switch the Master (3307 write-3308 read)
Premise: stop the business. there are no write operations on 3307.
1. set 3307 to read-only. Command line operations
# Modifying the configuration file
Vim/home/bbq/mysql/mysql-3307/cnf/my. cnf
# Add in [mysqld]
Read_only
# Restart mysqld3307
Service mysqld3307 restart
2. check whether the SQL statement of the master database is executed in the slave database. Mysql client operations
# Method 1
#3308 (read-write) execution
Show processlist;
One of the threads whose user is 'system user'
If the value of State is "Reading event from the relay log", it indicates that the relay log SQL statement for master database synchronization is being executed.
If the State value is "Slave has read all relay log; waiting for the slave I/O thread to update it", it indicates that the relay log SQL statement synchronized from the master database has been executed.
# Method 2 (simple and error-prone, recommended)
#3307 run:
Show master status # Record File and Position
#3308 run:
Select master_pos_wait (File, Position );
3. set "3308" to "writable. Command line operations
# Modifying the configuration file
Vim/home/bbq/mysql/mysql-3308/cnf/my. cnf
# Delete in [mysqld]
# Read_only
# Restart mysqld3308
Service mysqld3308 restart
BitsCN.com