An example of mysql master-slave synchronous replication error Solution

Source: Internet
Author: User

This afternoon, I copied the data from mysql. After all the servers are configured, I found that the following errors were reported.
Copy codeThe Code is as follows:
Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the -- replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it ).

It indicates that the server ID is the same as the master ID, and the/etc/my is the same as the master ID. I did not comment out the server_id = 1 line in cnf (I set server_id in the copy section below), so I immediately commented out this line, and then restarted mysql and found that the same error was still reported.

Run the following command to view server_id:
Copy codeThe Code is as follows:
Mysql> show variables like 'server _ id ';
+ --------------- + ------- +
| Variable_name | Value |
+ --------------- + ------- +
| Server_id | 1 |
+ --------------- + ------- +
1 row in set (0.00 sec)

Mysql has not updated server_id from the my. cnf file. In this case, it can only be manually modified.
Copy codeThe Code is as follows:
Mysql> set global server_id = 2; # The value here is the same as that set in my. cnf.
Mysql> slave start;

After this operation, slave returns to normal.

But later, mosquitoes will use/etc/init. d/mysqld restart restarts the mysql service, then checks the slave status, and finds that the above error occurs again. Then, check server_id and find that this value is restored to 1.

Then the mosquito re-checked/etc/my. the cnf content confirmed it should not be a problem with this file, so I checked it on google and found that mysql will find/etc/my at startup. cnf, DATADIR/my. cnf, USER_HOME/my. cnf.

So I executed
Copy codeThe Code is as follows:
Find/-name "my. cnf"

The my. cnf file was found in the/usr/local/mysql directory, so the mosquito deleted the file and then restarted the mysql service to restore everything to normal. If someone has a similar problem, try this method.

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.