同步练主库异常重启从库处理

Posted allenhu320

tags:

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

1、从库状态
mysql> show slave statusG
*************************** 1. row ***************************
               Slave_IO_State:
                  Master_Host: 10.215.51.22
                  Master_User: repl
                  Master_Port: 3307
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000054
          Read_Master_Log_Pos: 1014602227
               Relay_Log_File: relay-bin.000159
                Relay_Log_Pos: 1014602390
        Relay_Master_Log_File: mysql-bin.000054
             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: 1014602227
              Relay_Log_Space: 1014602604
              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: 1236
                Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: ‘Client requested master to start replication from position > file size; the first event ‘mysql-bin.000054‘ at 1014602227, the last event read from ‘/data/mysql_3307_english/binlog/mysql-bin.000054‘ at 4, the last byte read from ‘/data/mysql_3307_english/binlog/mysql-bin.000054‘ at 4.‘
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 223307
                  Master_UUID: 8e95a40f-b288-11e8-a9b5-0894ef5f328a
             Master_Info_File: /data/mysql_3307_english/data/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp: 191012 22:00:38
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set:
            Executed_Gtid_Set:
                Auto_Position: 0
1 row in set (0.00 sec)
 
2、从库relaylog情况
[root@zsyx-pte3033-f12-47 relaylog]# ll
total 990840
-rw-rw----. 1 mysql mysql        214 Sep 21 16:09 relay-bin.000158
-rw-rw----. 1 mysql mysql 1014602390 Oct 12 21:46 relay-bin.000159
-rw-rw----. 1 mysql mysql        102 Sep 21 16:09 relay-bin.index
-rw-rw----. 1 mysql mysql         98 Oct 12 21:46 relay-log.info
 
3、主库erro.log
2019-10-12 21:59:39 6831 [Note] InnoDB: Initializing buffer pool, size = 24.0G
2019-10-12 21:59:41 6831 [Note] InnoDB: Completed initialization of buffer pool
2019-10-12 21:59:41 6831 [Note] InnoDB: Highest supported file format is Barracuda.
2019-10-12 21:59:41 6831 [Note] InnoDB: The log sequence numbers 47860123317 and 47860123317 in ibdata files do not match the log sequence number 134360558585 in the ib_logfiles!
2019-10-12 21:59:41 6831 [Note] InnoDB: Database was not shutdown normally!
2019-10-12 21:59:41 6831 [Note] InnoDB: Starting crash recovery.
2019-10-12 21:59:41 6831 [Note] InnoDB: Reading tablespace information from the .ibd files...
2019-10-12 21:59:41 6831 [Note] InnoDB: Restoring possible half-written data pages
2019-10-12 21:59:41 6831 [Note] InnoDB: from the doublewrite buffer...
InnoDB: Last MySQL binlog file position 0 1014602227, file name mysql-bin.000054
2019-10-12 21:59:41 6831 [Note] InnoDB: 128 rollback segment(s) are active.
2019-10-12 21:59:41 6831 [Note] InnoDB: Waiting for purge to start
2019-10-12 21:59:41 6831 [Note] InnoDB: 5.6.25 started; log sequence number 134360558585
2019-10-12 21:59:41 6831 [Note] Recovering after a crash using /data/mysql_3307_english/binlog/mysql-bin
2019-10-12 21:59:48 6831 [ERROR] Error in Log_event::read_log_event(): ‘read error‘, data_len: 113, event_type: 30
2019-10-12 21:59:48 6831 [Note] Starting crash recovery...
2019-10-12 21:59:48 6831 [Note] Crash recovery finished.
2019-10-12 21:59:48 6831 [Note] Crashed binlog file /data/mysql_3307_english/binlog/mysql-bin.000054 size is 1014566912, but recovered up to 1014566735. Binlog trimmed to 1014566735 bytes.
2019-10-12 21:59:48 6831 [Note] Server hostname (bind-address): ‘*‘; port: 3307
2019-10-12 21:59:48 6831 [Note] IPv6 is available.
2019-10-12 21:59:48 6831 [Note]   - ‘::‘ resolves to ‘::‘;
2019-10-12 21:59:48 6831 [Note] Server socket created on IP: ‘::‘.
2019-10-12 21:59:48 6831 [Warning] ‘user‘ entry ‘root@zsyx-wlzj-yw-exercise01‘ ignored in --skip-name-resolve mode.
2019-10-12 21:59:48 6831 [Warning] ‘user‘ entry ‘@zsyx-wlzj-yw-exercise01‘ ignored in --skip-name-resolve mode.
2019-10-12 21:59:48 6831 [Warning] ‘proxies_priv‘ entry ‘@ root@zsyx-wlzj-yw-exercise01‘ ignored in --skip-name-resolve mode.
2019-10-12 21:59:48 6831 [Note] Event Scheduler: Loaded 0 events
2019-10-12 21:59:48 6831 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: ‘5.6.25-log‘  socket: ‘/tmp/mysqld.3307_english.sock‘  port: 3307  Source distribution
 
4、三个点取最小点
1014566912   master 事务点            mysql-bin.000054 size is 1014566912
1014566735   master recover点       recovered up to 1014566735
1014602227   slave                           Exec_Master_Log_Pos: 1014602227
 
5、从库执行
stop slave;
CHANGE MASTER TO  MASTER_HOST=‘10.215.51.22‘,  MASTER_USER=‘repl‘,  MASTER_PASSWORD=‘repl‘,  MASTER_PORT=3307,  MASTER_LOG_FILE=‘mysql-bin.000054‘,  MASTER_LOG_POS=1014566735;
start slave;
show slave statusG
一切正常
 
6、校验
screen -S allen
pt-table-sync --print --sync-to-master h=10.xx.xx.xx,u=xx,p=xx,P=3307 --databases english --charset=utf8
ctrl + ad
 
 

以上是关于同步练主库异常重启从库处理的主要内容,如果未能解决你的问题,请参考以下文章

Mysql主从同步异常处理

mysql误删搭建有主从的主库master binlog处理

redis主从同步异常

mysql主从复制,要主库和从库表结构一致才能复制吗

【mongoDB】mongoDB 主从从裁架构重启

mariadb(mysql)从库relaylog损坏无法同步的处理方法