Mysql主从同步 异常Slave_SQL_Running: No

Posted Leader.Z

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mysql主从同步 异常Slave_SQL_Running: No相关的知识,希望对你有一定的参考价值。

在刚搭建好的mysql主从节点上对从节点进行操作,导致同步异常:报错如下:

从节点执行:

mysql> show slave statusG;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.43.10
Master_User: db
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 32168
Relay_Log_File: mysql-relay.000004
Relay_Log_Pos: 4091
Relay_Master_Log_File: mysql-bin.000003
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1146
Last_Error: Error executing row event: ‘Table ‘test.test1‘ doesn‘t exist‘
Skip_Counter: 0
Exec_Master_Log_Pos: 19009
Relay_Log_Space: 18368
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1146
Last_SQL_Error: Error executing row event: ‘Table ‘test.test1‘ doesn‘t exist‘
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: 36285a17-0dea-11ea-908d-000c298eae92
Master_Info_File: /usr/local/mysql/data/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp: 191124 22:25:38
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)

ERROR:
No query specified

解决方法1:

Slave_SQL_Running: No
1.程序可能在slave上进行了写操作

2.也可能是slave机器重起后,事务回滚造成的.

一般是事务回滚造成的:
解决办法:
mysql> stop slave ;
mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
mysql> start slave ;

解决办法二、

首先停掉Slave服务:slave stop
到主服务器上查看主机状态:
记录File和Position对应的值

进入master

mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000003 | 32168 | test | mysql | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

 

然后到slave服务器上执行手动同步:

mysql> change master to 
> master_host=‘192.168.43.10‘,
> master_user=‘db‘, 
> master_password=‘123456‘, 
> master_port=3306, 
> master_log_file=‘mysql-bin.000003‘, 
> master_log_pos=32168 ;
mysql> start slave ;

 

以上是关于Mysql主从同步 异常Slave_SQL_Running: No的主要内容,如果未能解决你的问题,请参考以下文章

mysql主从同步异常修复

mysql主从同步异常

mysql主从同步异常

mysql主从同步异常

Linux运维之Shell编程------监控MySQL错误码及主从复制同步异常

zabbix监控mysql主从状态