MYSQL master-slave switchover, mysql master-slave

Source: Internet
Author: User

MYSQL master-slave switchover, mysql master-slave

1. modify the configuration file
Read-only = 1 (master database)
# Read-only = 1 (slave database)

2. view the status of the Master/Slave Database
Show slave status \ G
Show master status \ G

3. Operate the slave Database
STOP SLAVEIO_THREAD;
Show processlist;
See Has read all relay log
Show slave status \ G
Stop slave;
Reset master;
Reset slave;

Grant replication slave on *. * to 'testuser' @ '10. 45.172.40 'identified by 'test123 ';
Show master status \ G

For example, after executing reset master;

ERROR 1186 (HY000): Binlog closed, cannot RESET MASTER

Solution:

Modify vim/etc/my. cnf

Add log-bin = mysql-bin

Restart the mysqld service.

 

4. Operate the master database
Show master status \ G
Reset master;
Reset slave;

CHANGE MASTER

MASTER_HOST = '10. 45.172.37 ',

MASTER_USER = 'testuser ',

MASTER_PASSWORD = 'test123 ',

MASTER_PORT = 3306,

MASTER_LOG_FILE = 'mysql-bin.000001 ',

MASTER_LOG_POS = 98,

MASTER_CONNECT_RETRY = 60;

 

5. Restart the Master/slave database and enable the slave process.

Start slave

Show processlist;
Show slave status \ G

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.