MYSQL master/master switchover (master database not down) _ MySQL

Source: Internet
Author: User
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

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.