【MySql】複製出現Slave_SQL_Running: No 錯誤解決
收到報警,mysql的從資料庫在同步的過程出現問題,已停止同步。
ERROR] Slave SQL: Error "Lock wait timeout exceeded; try restarting transaction" on query. Default database: "yang". Query: "UPDATE workitem SET status = state, modify_time=1329640301 where workitem_id = 800", Error_cod
Slave sql not running: result is No|slave_sql_running=0
登入資料庫檢視!
root@127.0.0.1 : yang 16:48:34> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.249.119.52
Master_User: replicator
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.001156
Read_Master_Log_Pos: 49021182
Relay_Log_File: slave-relay.118531
Relay_Log_Pos: 1342
Relay_Master_Log_File: mysql-bin.001156
Slave_IO_Running: Yes
Slave_SQL_Running: No
........
Last_Errno: 1205
Last_Error: Error 'Lock wait timeout exceeded; try restarting transaction' on query. Default database: 'yang'. Query: 'UPDATE workitem SET status = state, modify_time=1329640301 where workitem_id = 800'
Skip_Counter: 0
Exec_Master_Log_Pos: 47702497
Relay_Log_Space: 1319098
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
...........
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1205
Last_SQL_Error: Error 'Lock wait timeout exceeded; try restarting transaction' on query. Default database: 'yang'. Query: 'UPDATE work SET status = state, modify_time=1329640301 where work_id = 800'
1 row in set (0.00 sec)
從庫由於 Error 'Lock wait timeout exceeded; try restarting transaction' on query. Default database: 'yang'. Query: 'UPDATE work SET status = state, modify_time=1329640301 where work_id = 800'; 鎖等待超時導致事務失敗,多次重試不成功。Slave_SQL_程式中斷!
解決辦法一:
1.首先停掉Slave服務:
mysql>slave stop;
2.到主伺服器上檢視主機狀態,
mysql> show master status;
+------------------+-----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+-----------+--------------+------------------+
| mysql-bin.001156 | 48291554 | | |
+------------------+-----------+--------------+------------------+
1 row in set (0.00 sec)
記錄File和Position對應的值 mysql-bin.001156,48291554
3 到slave伺服器上執行手動同步:
mysql> change master to
> master_host='master_ip',
> master_user='user',
> master_password='pwd',
> master_port=3306,
> master_log_file='mysql-bin.001156',
> master_log_pos=48291554;
1 row in set (0.00 sec)
mysql> slave start;
1 row in set (0.00 sec)
再次檢視slave狀態發現:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
...
Seconds_Behind_Master: 0
注:這種辦法可能會導致從伺服器上的資料不完整,如從伺服器一直出錯,但主伺服器日誌檔案一直在增加,過好長時間,再直接從主伺服器上取日誌位置,可能會造成錯誤期間的資料無法更新到從伺服器中.這裡建議採用下面的這種辦法(將錯誤語句直接跳過).
解決辦法二:
mysql> slave stop;
mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
mysql> slave start;
set GLOBAL SQL_SLAVE_SKIP_COUNTER=N,用來跳過備機的一條或N條出錯的複製語句。然後重新start slave即可。
由於我們的是雙master 架構,所以為了避免重複執行變更的語句,實際操作:
root@127.0.0.1 : (none) 16:56:00> SET SQL_LOG_bin=0;
Query OK, 0 rows affected (0.00 sec)
root@127.0.0.1 : (none) 16:56:06> use yang;
Database changed
執行導致錯誤的語句
root@127.0.0.1 : yang 16:56:10> UPDATE workitem SET status = state, modify_time=1329640301 where workitem_id = 800;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
root@127.0.0.1 : yang 16:56:45>stop slave;
Query OK, 0 rows affected (0.00 sec)
root@127.0.0.1 : yang 16:56:46>set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
Query OK, 0 rows affected (0.00 sec)
root@127.0.0.1 : yang 16:56:46>start slave;
Query OK, 0 rows affected (0.00 sec)
最終確認結果
root@127.0.0.1 : (none) 16:59:40> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.249.119.52
Master_User: replicator
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.001156
Read_Master_Log_Pos: 49846932
Relay_Log_File: slave-relay.118532
Relay_Log_Pos: 235831
Relay_Master_Log_File: mysql-bin.001156
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
..........
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 49846932
Relay_Log_Space: 2144848
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: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)
至此問題解決~!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-716757/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql master-slave複製錯誤[解決事例]MySqlAST
- 解決mysql使用GTID主從複製錯誤問題MySql
- mysql ab主從複製出錯及解決過程MySql
- Mysql出現連線錯誤解決辦法MySql
- mysql replication複製錯誤(zt)MySql
- 連線MySQL出現2013錯誤解決MySql
- MySQL 主從複製,常見的binlog錯誤及解決方法MySql
- MySQL主從複製錯誤——列型別轉換錯誤MySql型別
- 高階複製錯誤ORA-23474解決方法
- MySQL 主從複製錯誤1837MySql
- MySQL GTID複製錯誤修復演示MySql
- service mysql start出錯,mysql啟動不了,解決mysql: unrecognized service錯誤MySqlZed
- scp出現錯誤的解決辦法
- 編譯EJB出現錯誤的解決編譯
- ontape出現段錯誤(未解決篇)
- nginx出現403錯誤的解決方法Nginx
- 配置OGG到MYSQL複製時登陸MYSQL報錯解決MySql
- phpmyadmin配製連線mysql時出現錯誤(轉)PHPMySql
- mysql與php錯誤解決MySqlPHP
- mysql錯誤解決總結MySql
- exchange出現1025錯誤!(未解決)
- ant構建時出現錯誤解決方案
- 【MySQL】解決mysql的 1594 錯誤MySql
- mysql多源複製跳過錯誤處理方法MySql
- 【Mysql】Mysql GTID複製程式出現異常,出現斷點MySql斷點
- 複製錯誤案例分享(一)
- 複製錯誤案例分享(二)
- 【MySQL】複製1594錯誤(從庫relaylog損壞)MySql
- 解決共享檔案複製出錯“指定的網路名不再可用”
- jboss+mysql+hibernate 出現錯誤!!!!!!!MySql
- MySQL主從複製延遲解決方案MySql
- u盤出現大檔案無法複製的解決
- 解決Centos7 yum 出現could not retrieve mirrorlist 錯誤CentOS
- Nginx出現413 Request Entity Too Large錯誤解決方法Nginx
- 隨身碟出現防寫錯誤的解決方法
- apache出現 403 permission 和404 not fund錯誤(解決方法)Apache
- exp/imp出現錯誤通過expdp/impdp來解決
- DG rman duplicate 複製庫錯誤