mysql-5.7.22 master-slave synchronization (read-write separation) restart fails

Restart the master-slave library synchronization configuration

0. Backup the database (very important! Both the master and slave databases must be backed up) 
1. Synchronize the database table structure to keep the master and slave database table structures consistent 
2. In the master database environment, run SHOW MASTER STATUS, and the output is as follows: 
write picture description here

3. Remember the file name and position name, switch to the slave library environment 
4. Run stop slave 
in the slave library environment 5. Run in the slave library environment

   CHANGE  MASTER TO 
   MASTER_HOST='188.180.81.176', MASTER_USER='username',  
   MASTER_PASSWORD='111111',             
   MASTER_LOG_FILE='mysql-bin.000001',  MASTER_LOG_POS=98;

 (Host is the main library ip address, MASTER_USER and MASTER_PASSWORD are the account and password created when master-slave synchronization is configured, file and Pos are the main library file name and position name respectively)

6. Run start slave; 
7. Run show slave status\G ; check if the output contains the following:

...
  Slave_IO_Running: Yes
  Slave_SQL_Running: Yes
...
  •  

8. Add a piece of data to the master library to check whether the slave library has completed synchronization.

If the slave library is required to synchronize the master library, the steps are the same as above, and the relevant parameters of the master-slave environment should be remembered to switch.

possible trouble

1. Slave_IO_Running: Connecting: 
There are three main reasons why lave_IO_Running is connecting:

1. Network failure 
2. Incorrect password 
3. Incorrect pos

Check whether the master-slave environment firewall intercepts the request, and then check whether the value of MASTER_LOG_POS is the position address of the target address. If it is still connection after re-entering, you need to check whether the account password configured in the master-slave synchronization configuration is correct (the project is generally Documents will be left after configuration, remember to check).

2. Slave_SQL_Running: No: 
Restart the master-slave library configuration according to the above steps to solve the problem.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325808634&siteId=291194637