MySQL master-slave replication failure Case II

Source: Internet
Author: User


Case TWO:


Master multi-Slave architecture, main library master down

Solution Ideas:


1, log in from library

Show Processlist;

View update status for two threads

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/83/A1/wKioL1d46XXAm2LmAALthMC5r1I585.png "title=" 0003. PNG "alt=" Wkiol1d46xxam2lmaalthmc5r1i585.png "/>

Result Description:

Previous master-slave synchronization is normal


Log in to the remaining 2 separately from the Library 32,33 view:

Cat/data/3306/data/master.infocat/data/3307/data/master.info


Compare, the POS is the largest, the description is closer to the main library, then we elect this slave as the new master.

or using semi-synchronous technology, direct elections to the real-time synchronization of this library for the new master


If, Master is down, and master is still writing, we need to pull the master Binlog to the newly selected slave,

For data completion, the other slave is executed with the newly selected master to keep it in sync.


Switching Steps and Considerations:


1. Make sure all Relay_log are updated

At each execution from the library

Stop slave io_thread;show processlist; direct See has read all relay log; Indicates that the update is performed from the library;


2, Login

The newly elected master (i.e. the old one slave), execute the following command

Stop Slave;reset Master;quit;


3, enter the newly elected slave data directory, delete the Master.info relay-log.info, prevent the continuation of reading data from the old master

CD/DATA/3306/DATARM-RF Master.info Relay-log.info

Check authorization table, read-only and other parameters, need to delete



4, upgrade the new election from the library to the main library

Vim/data/3306/my.cnf

Open Binlog:

Log-bin = Mysql-bin If the following parameters are present, be sure to delete the log-slave-updatesread-only--replication-do-db--replication-ignore-db-- Replication-do-table--replication-ignore-table--replication-wild-do-table--replication-wild-ignore-table

Restart service, upgrade main library complete


5, if the main library server is not down, you need to go to the main binlog, complement the main library from the library



6, other operations from library

Check (synchronous user,rep are present, meaning that other slave have permission to connect to the new master)

Login slave:

Stop Slavechange Master to master_host= ' new_master_ip '; If not synchronized, specify Posstart slave;show slave status\g;


++++++++++++ Main Library Downtime switch success


7. Modify the program configuration file to replace the previous masterip with the new Masterip

Restart Service




This article is from the "Crazy_sir" blog, make sure to keep this source http://douya.blog.51cto.com/6173221/1795367

MySQL master-slave replication failure Case II

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.