【MySQL】Server-id導致Slave_IO_Running: No主從複製故障
【問題描述】:
在master停機維護啟動服務之後,slave的Slave_IO_Running狀態被置為NO
Slave_SQL_Running為Yes,猜測應該是master的鍋
繼續檢查網路,許可權等問題之後仍然為不可用
也嘗試重新
change master to ...., ...., ....,
master_log_file = 'master-bin.034555',
master_log_pos = 98;
依舊不可用
檢視slave的errorlog,發現有報錯,報錯資訊十分明瞭:
並且丟擲: Got fatal error 1236 的錯誤
檢查配置檔案發現#server-id = xxx 被註釋
【解決方案】:
由於server_id為“Dynamic Variable”
故到master中手動執行
最後在將配置檔案中新增
server-id=3028
同樣,某些時候在start slave時報錯“The server is not configured as slave”,
同樣也很有可能是server-id的緣故,只需要手動在主和從庫上執行:
SET GLOBAL server_id = xxx,並保證兩臺server-id不一樣即可,最後寫入my.cnf中。
作者微信公眾號(持續更新)
在master停機維護啟動服務之後,slave的Slave_IO_Running狀態被置為NO
Slave_SQL_Running為Yes,猜測應該是master的鍋
繼續檢查網路,許可權等問題之後仍然為不可用
也嘗試重新
change master to ...., ...., ....,
master_log_file = 'master-bin.034555',
master_log_pos = 98;
依舊不可用
-
mysql> SHOW SLAVE STATUS\G
-
*************************** 1. row ***************************
-
Slave_IO_State:
-
Master_Host: *.*.*.*
-
Master_User: repl
-
Master_Port: 3306
-
Connect_Retry: 60
-
Master_Log_File: master-bin.034555
-
Read_Master_Log_Pos: 98
-
Relay_Log_File: mysqld-relay-bin.000001
-
Relay_Log_Pos: 98
-
Relay_Master_Log_File: master-bin.034555
-
Slave_IO_Running: No
-
Slave_SQL_Running: Yes
-
Replicate_Do_DB:
-
Replicate_Ignore_DB:
-
Replicate_Do_Table:
-
Replicate_Ignore_Table:
-
Replicate_Wild_Do_Table:
-
Replicate_Wild_Ignore_Table:
-
Last_Errno: 0
-
Last_Error:
-
Skip_Counter: 0
-
Exec_Master_Log_Pos: 98
-
Relay_Log_Space: 98
-
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
檢視slave的errorlog,發現有報錯,報錯資訊十分明瞭:
並且丟擲: Got fatal error 1236 的錯誤
- 160322 9:42:51 [Note] Slave SQL thread initialized, starting replication in log 'master-bin.034555' at position 98, relay log './mysqld-relay-bin.0000
- 01' position: 4
- 160322 9:43:01 [Note] Slave I/O thread: connected to master 'repl@*.*.*.*:3306', replication started in log 'master-bin.034555' at position 98
- 160322 9:43:01 [ERROR] Error reading packet from server: Misconfigured master - server id was not set ( server_errno=1236)
- 160322 9:43:01 [ERROR] Got fatal error 1236: 'Misconfigured master - server id was not set' from master when reading data from binary log
- 160322 9:43:01 [Note] Slave I/O thread exiting, read up to log 'master-bin.034555', position 98
- 160322 9:43:07 [Note] Error reading relay log event: slave SQL thread was killed
檢查配置檔案發現#server-id = xxx 被註釋
【解決方案】:
由於server_id為“Dynamic Variable”
故到master中手動執行
-
mysql> SET GLOBAL server_id=3028;
- Query OK, 0 rows affected (0.00 sec)
最後在將配置檔案中新增
server-id=3028
在slave上檢查:
解決。-
mysql> SHOW SLAVE STATUS\G
-
*************************** 1. row ***************************
-
Slave_IO_State: Waiting for master to send event
-
Master_Host: 192.168.30.28
-
Master_User: repl
-
Master_Port: 3306
-
Connect_Retry: 60
-
Master_Log_File: master-bin.034556
-
Read_Master_Log_Pos: 59312658
-
Relay_Log_File: mysqld-relay-bin.000002
-
Relay_Log_Pos: 64698308
-
Relay_Master_Log_File: master-bin.034555
-
Slave_IO_Running: Yes
-
Slave_SQL_Running: Yes
- …………………………
-
Seconds_Behind_Master: 10071
- 1 row in set (0.00 sec)
同樣,某些時候在start slave時報錯“The server is not configured as slave”,
同樣也很有可能是server-id的緣故,只需要手動在主和從庫上執行:
SET GLOBAL server_id = xxx,並保證兩臺server-id不一樣即可,最後寫入my.cnf中。
作者微信公眾號(持續更新)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29773961/viewspace-2061572/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL主從複製與主主複製MySql
- MySQL的主從複製與MySQL的主主複製MySql
- mysql5.7主從複製,主主複製MySql
- MySQL主從複製、半同步複製和主主複製MySql
- mysql複製--主從複製配置MySql
- mysql臨時表空間不夠導致主從複製失敗MySql
- MySQL 主從複製MySql
- 【MySql】主從複製MySql
- MySQL主從複製MySql
- mysql 鏈式複製中關於server-id 導致不復制但不出錯MySqlServer
- MySQL主從複製、半同步複製和主主複製概述MySql
- MySQL主從複製_複製過濾MySql
- MySQL的主從複製、半同步複製、主主複製詳解MySql
- 配置mysql5.5主從複製、半同步複製、主主複製MySql
- MySQL主從複製原理MySql
- MySQL的主從複製MySql
- mysql--主從複製MySql
- mysql主從複製搭建MySql
- MySql 主從複製配置MySql
- MySQL主從複製配置MySql
- mysql 8.4 主從複製MySql
- 故障分析 | Redis 主從複製風暴Redis
- MySQL主從複製之GTID複製MySql
- MySQL主從複製之半同步複製MySql
- MySQL主從複製之非同步複製MySql非同步
- 【MySQL】5.6/5.7並行複製bug導致的故障 ERROR 1755/1756MySql並行Error
- mysql主從複製(一):一主多從MySql
- MySQL++:Liunx - MySQL 主從複製MySql
- MySQL(13)---MYSQL主從複製原理MySql
- mysql replication /mysql 主從複製原理MySql
- mysql主從延遲複製MySql
- Windows Mysql主從複製部署WindowsMySql
- mysql實現主從複製MySql
- MySQL 主從複製實操MySql
- MYSQL主從複製配置(整理)MySql
- windows 下mysql主從複製WindowsMySql
- MySQL8.0主從複製MySql
- MySQL主從複製歷程MySql