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.