同事給我打電話說團購資料庫主從不同步了,速度開電腦撥VPN解決。
1、登入從庫查看主從同步狀態,確實是否不同步
mysql> show slave status\G*************************** 1. row ***************************Slave_IO_State:Master_Host: 10.10.0.236Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.001501Read_Master_Log_Pos: 144001931Relay_Log_File: mysql-relay-bin.000296Relay_Log_Pos: 144002077Relay_Master_Log_File: mysql-bin.001501Slave_IO_Running: NoSlave_SQL_Running: YesReplicate_Do_DB:Replicate_Ignore_DB: mysql,information_schema,performance_schema,testReplicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 0Last_Error:Skip_Counter: 0Exec_Master_Log_Pos: 144001931Relay_Log_Space: 144002276Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master: NULLMaster_SSL_Verify_Server_Cert: NoLast_IO_Errno: 1236Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position'Last_SQL_Errno: 0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id: 21 row in set (0.00 sec)
看來確實出問題了,查看從庫錯誤記錄檔:
[root@tg_0_zjc tuan]# tail -n 30 logs/mysqld.log130619 22:23:36 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.001343' at position 107, relay log './mysqld-relay-bin.000001' position: 4130619 22:23:36 [Note] Slave I/O thread: connected to master 'slave@10.10.0.236:3306',replication started in log 'mysql-bin.001343' at position 107130620 14:04:21 [Note] Slave: received end packet from server, apparent master shutdown:130620 14:04:21 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.001343' at position 2544563130620 14:04:21 [ERROR] Slave I/O: error reconnecting to master 'slave@10.10.0.236:3306' - retry-time: 60 retries: 86400, Error_code: 2003130620 14:13:45 [Note] Slave: connected to master 'slave@10.10.0.236:3306',replication resumed in log 'mysql-bin.001343' at position 2544563130623 22:04:17 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013)130623 22:04:17 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.001402' at position 121870679130623 22:04:20 [ERROR] Slave I/O: error reconnecting to master 'slave@10.10.0.236:3306' - retry-time: 60 retries: 86400, Error_code: 2003130623 22:08:29 [Note] Slave: connected to master 'slave@10.10.0.236:3306',replication resumed in log 'mysql-bin.001402' at position 121870679130623 22:08:29 [ERROR] Error reading packet from server: Client requested master to start replication from impossible position ( server_errno=1236)130623 22:08:29 [ERROR] Slave I/O: Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position', Error_code: 1236130623 22:08:29 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.001402', position 121870679130623 22:26:29 [Note] Error reading relay log event: slave SQL thread was killed130623 22:26:34 [Note] 'CHANGE MASTER TO executed'. Previous state master_host='10.10.0.236', master_port='3306', master_log_file='mysql-bin.001402', master_log_pos='121870679'. New state master_host='10.10.0.236', master_port='3306', master_log_file='mysql-bin.001403', master_log_pos='107'.130623 22:26:42 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.001403' at position 107, relay log './mysqld-relay-bin.000001' position: 4130623 22:26:42 [Note] Slave I/O thread: connected to master 'slave@10.10.0.236:3306',replication started in log 'mysql-bin.001403' at position 107130629 12:04:21 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013)130629 12:04:21 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.001501' at position 144001931130629 12:04:24 [ERROR] Slave I/O: error reconnecting to master 'slave@10.10.0.236:3306' - retry-time: 60 retries: 86400, Error_code: 2003130629 12:08:33 [Note] Slave: connected to master 'slave@10.10.0.236:3306',replication resumed in log 'mysql-bin.001501' at position 144001931130629 12:08:33 [ERROR] Error reading packet from server: Client requested master to start replication from impossible position ( server_errno=1236)130629 12:08:33 [ERROR] Slave I/O: Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position', Error_code: 1236130629 12:08:33 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.001501', position 144001931130629 22:10:08 [Note] Error reading relay log event: slave SQL thread was killed130629 22:10:12 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.001501' at position 144001931, relay log './mysqld-relay-bin.000296' position: 144002077130629 22:10:12 [Note] Slave I/O thread: connected to master 'slave@10.10.0.236:3306',replication started in log 'mysql-bin.001501' at position 144001931130629 22:10:12 [ERROR] Error reading packet from server: Client requested master to start replication from impossible position ( server_errno=1236)130629 22:10:12 [ERROR] Slave I/O: Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position', Error_code: 1236130629 22:10:12 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.001501', position 144001931
嘗試更改position位置恢複: