天天看點

mysql主從同步是否異常_Mysql主從同步 異常Slave_SQL_Running: No

在剛搭建好的mysql主從節點上對從節點進行操作,導緻同步異常:報錯如下:

從節點執行:

mysql> show slave status\G;

*************************** 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 ;