从库复制报低级的1236错误处理

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/zengxuewen2045/article/details/51615958


一.基本信息
版本:10.1.12-MariaDB
binlog格式: ROW
事务级别:READ-COMMITTED
master1:10.16.24.107
master2:10.16.24.108
slave1:10.16.24.109
vip:10.16.24.58

二.问题描述
m2上查看:
(product)root@localhost [(none)]> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000009 |      359 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

用冷备方式将m2 coyp一份到s1,并在s1上执行如下:
change master to
master_host='10.16.24.108',
master_port=3307,
master_user='repl',
master_password='replsafe',
master_log_file=' mysql-bin.000009',
master_log_pos=359;

s1上启动slave,报下面错:

(product)root@localhost [(none)]> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State:
                  Master_Host: 10.16.24.108
                  Master_User: repl
                  Master_Port: 3307
                Connect_Retry: 60
              Master_Log_File:  mysql-bin.000009
          Read_Master_Log_Pos: 359
               Relay_Log_File: relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File:  mysql-bin.000009
             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: 359
              Relay_Log_Space: 249
              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: 'Could not find first log file name in binary log index file'
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1083307
               Master_SSL_Crl:
           Master_SSL_Crlpath:
                   Using_Gtid: No
                  Gtid_IO_Pos:
      Replicate_Do_Domain_Ids:
  Replicate_Ignore_Domain_Ids:
                Parallel_Mode: conservative
1 row in set (0.00 sec)

三.问题分析

1236错误一般与权限或位置不对引起。
检查m2的mysql-bin.000009的position 359,发现没有这个position。
[apps@mvxl0783 log]$ /apps/svr/mariadb101/bin/mysqlbinlog -vv --base64-output=DECODE-ROWS  mysql-bin.000009 --start-position=359
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

查找与359最接近的position为320,如下:
/apps/svr/mariadb101/bin/mysqlbinlog -vv --base64-output=DECODE-ROWS mysql-bin.000009 >./a.log

[apps@mvxl0783 log]$ tail -20 a.log
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#160608 22:29:27 server id 1083307  end_log_pos 249     Start: binlog v 4, server v 10.1.12-MariaDB created 160608 22:29:27 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
# at 249
#160608 22:29:27 server id 1083307  end_log_pos 320     Gtid list [0-621133307-40,
# 0-1073307-77,
# 0-1083307-80]
# at 320
#160608 22:29:27 server id 1083307  end_log_pos 359     Binlog checkpoint mysql-bin.000009
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

stop slave,并重新change master,如下:
change master to
master_host='10.16.24.108',
master_port=3307,
master_user='repl',
master_password='replsafe',
master_log_file=' mysql-bin.000009',
master_log_pos=320;

启动slave后,查看status依然报错。

重新检查change master命令,发现master_log_file有一空格引起,
change master to
master_host='10.16.24.108',
master_port=3307,
master_user='repl',
master_password='replsafe',
master_log_file=' mysql-bin.000009',
master_log_pos=359;

四.问题解决
改成如下,则可以正常同步,不再报错。
change master to
master_host='10.16.24.108',
master_port=3307,
master_user='repl',
master_password='replsafe',
master_log_file='mysql-bin.000009',
master_log_pos=359;

(product)root@localhost [(none)]> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.16.24.108
                  Master_User: repl
                  Master_Port: 3307
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000009
          Read_Master_Log_Pos: 359
               Relay_Log_File: relay-bin.000002
                Relay_Log_Pos: 537
        Relay_Master_Log_File: mysql-bin.000009
             Slave_IO_Running: Yes
            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: 359

展开阅读全文

没有更多推荐了,返回首页