MySQL master-slave synchronization error troubleshooting results and repair process: Slave_SQL_Running: No

Cause investigation:

  There must be a reason for receiving a large number of e-mails to the police, so I asked my colleagues what happened? My colleague logged in to the slave database and found the following error message, indicating that the synchronization with the main database failed, and it has been stuck somewhere. I saw that he had been working on it for more than two hours, and there were more and more problems. After one or two minutes of solving one, it will not work. . . . . So the police e-mail is one after another. . . So ask me for help. After logging in from the library, I found:

  One of the slave libraries reported the following error:

copy code

copy code

1 mysql> show slave status\G;
2
3 Slave_IO_Running: Yes
4 Slave_SQL_Running: No
5
6 Last_Errno: 1008
7
8 Last_Error: Error 'Can't drop database 'lcp'; database doesn't exist' on query. Default database: 'lcp'. Query: 'drop database lcp'

copy code

copy code

 

 

Failed to create library,

View logs

1 mysql> SHOW  GLOBAL VARIABLES LIKE '%log%';
2
3 | log_error | /application/mysql/data/db03.err The log path is not moved, the default  
4
5 | log_warnings | 1 Fortunately, logging is enabled. . .

 

Cut a window to view the log:

Found a bug report, could not be synchronized with the main library, the previous one reported that the lcp library already exists. . Wondering why you use my name as a library name. . . Strictly criticize. (I later learned that I thought my name was a deterrent, to scare the server, laugh and cry...)

 Closer to home

  I looked at his historical operation records. I wanted to create the "lcp" library, but found that the library already exists. I wanted to delete the "lcp" library, but found that the system reported an error that the library did not exist. Then I was very depressed and asked him what did you do to the server! ! !

  I'm really not afraid of brainless teammates, just afraid. . . . Haha, of course I’m joking, troubleshooting is also a process of growth. I like my teammate very much, and he often provides me with room to grow. (Ps: Don't imitate easily!! Especially the production environment!!!)

1  160524 10:53:41 [Warning] Slave: Can't create database 'min'; database exists Error_code: 1007
2  160524 10:53:41 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-b
3  in.000758' position 1077
4  160524 11:53:17 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013)

 

  So I continued to scroll up the error log and found a similar message: The min library already exists and the creation cannot be completed. Something seemed to come to mind at the time. Just asked, did you create the min library on the two mysql servers at the same time? The pig-like teammate's answer to me turned out to be: "Yes!"! ! ! ! ! Well forgive him for being a novice. Now that the problem is found, it is naturally simple. Fortunately, one of the slave libraries will not cause a great impact, so I choose the simplest method:

   Move the binglog pointer down one position.

solution:

mysql> slave stop; 
Query OK, 0 rows affected (0.01 sec)

mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
Query OK, 0 rows affected (0.00 sec)

mysql> slave start;
Query OK, 0 rows affected (0.00 sec)

 

mysql> show slave status\G;

Slave_IO_Running: Yes
Slave_SQL_Running: Yes

Guess you like

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