A master-slave replication interrupt caused by MySQL cross-Library operations at a time

Source: Internet
Author: User

Today, all MySQL slave replication from the server is abnormally interrupted, landed on one of the platform to execute show slave status\g, found the following error:
--
Last_error:error ' Operation DROP USER failed for ' guest ' @ ' localhost ' on query. Default database: ' Work '. Query: ' Drop user ' guest ' @ ' localhost '
--
In other words, this is caused by the command drop user ' guest ' @ ' localhost ', which we usually only do on master, and that this action should only affect the "MySQL" System database. This kind of operation has been done many times before, but why this time alone will be a problem?
After some investigation, we finally found the root of the problem, that is,
"Binlog-do-db, Binlog-ignore-db, replicate-do-db, replicate-ignore-db" This kind of parameter, is not imagined reliable!

Usually, we assume that as long as the above parameters are set, the master-slave copy of MySQL will only take effect on the database we set up. But in fact, MySQL is not based on content to judge, but very silly based on you do the "use of work" or in the initial connection specified by the database to judge.
And this time, before we execute the drop user, because we need to select some data from the "work" database, we have to go into the work database, and we all know that there is no need to go to the "MySQL" system database when executing the drop user. So we executed the drop user directly, but because MySQL's judgment was executed after the use of work, it was considered that the operation of the "working" database was synchronized, and there were no [email protected] users from the service. The result is an error that causes a master-slave replication interrupt.

Therefore, in a MySQL server environment with a master-slave replication architecture, we try to avoid such cross-library operations to ensure that the command is executed after the correct use dbname is executed.

The recovery scenario for this type of failure is simple enough to skip this SQL.
--
Stop slave;
Set global sql_slave_skip_counter=1;
Start slave;
Show Slave Status\g
--

Resources:
http://www.mysqlperformanceblog.com/2009/05/14/why-mysqls-binlog-do-db-option-is-dangerous/

A master-slave replication interrupt caused by MySQL cross-Library operations at a time

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.