mysql master slave synchronization copy error resolved
- 2020-05-10 23:00:29
- OfStack
Mosquito took 1 master and 3 slave mysql replication this afternoon. As a result, after all the servers were configured, the following error was found
server_id=1 in /etc/ my.cnf (I set server_id in the copy section below), so I immediately commented out the line. Then I restarted mysql and found the same error.
See 1 server_id using the following command
It was found that mysql did not update server_id from the my.cnf file, so you had to modify it manually
After doing so, slave returned to normal.
But later mosquitoes use/etc/init d/mysqld restart restart mysql service, then look at slave state, find again the above error, then look at server_id found this value to 1 again.
After that, the mosquito checked the contents of etc/ my.cnf again, and confirmed that it should not be the problem of this file, so it went to google and found that mysql would look up /etc/ my.cnf, DATADIR/ my.cnf, USER_HOME/ my.cnf at startup.
So I did it
The my.cnf file was found in the /usr/local/mysql directory, so the mosquito deleted the file and restarted the mysql service, and found that the first cut returned to normal. If someone has a similar problem, try this.
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).
server_id=1 in /etc/ my.cnf (I set server_id in the copy section below), so I immediately commented out the line. Then I restarted mysql and found the same error.
See 1 server_id using the following command
mysql> show variables like 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id | 1 |
+---------------+-------+
1 row in set (0.00 sec)
It was found that mysql did not update server_id from the my.cnf file, so you had to modify it manually
mysql> set global server_id=2; # The sum here my.cnf In the setting of 1 Sample line
mysql> slave start;
After doing so, slave returned to normal.
But later mosquitoes use/etc/init d/mysqld restart restart mysql service, then look at slave state, find again the above error, then look at server_id found this value to 1 again.
After that, the mosquito checked the contents of etc/ my.cnf again, and confirmed that it should not be the problem of this file, so it went to google and found that mysql would look up /etc/ my.cnf, DATADIR/ my.cnf, USER_HOME/ my.cnf at startup.
So I did it
find / -name "my.cnf"
The my.cnf file was found in the /usr/local/mysql directory, so the mosquito deleted the file and restarted the mysql service, and found that the first cut returned to normal. If someone has a similar problem, try this.