This afternoon, I copied the data from mysql. After all the servers are configured, I found that the following errors were reported.
CopyCode The 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 executedCopy codeThe Code is as follows: Find/-name "My. CNF"
I found my In the/usr/local/MySQL directory. the CNF file is deleted, and then the MySQL service is restarted. If someone has a similar problem, try this method.