复制在主库异常宕机后,很可能出现1236错误.
如:
[ERROR] Error reading packet from server: Could not find first log file name in binary log index file ( server_errno
=1236)
[ERROR] Got fatal error 1236: ‘Could not find first log file name in binary log index file’ from master when reading
data from binary log
[Note] Slave I/O thread exiting, read up to log ‘mysql-bin.000025′, position 106
具体原因不必深究,这是Mysql不够健壮的一个表现.
在一个高度繁忙的数据库日志,确认最近的日志,可能会比较困难.
一般情况下,管理员为图方便,不会重新建立从库,而是手动更改从库的配置,指向宕机重启后,生成的那个日志文件起始点.
如我这里为 mysql-bin.00002 106
mysql> show master status;
+——————+———-+————–+——————+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+——————+———-+————–+——————+
| mysql-bin.000026 | 106 | | |
+——————+———-+————–+——————+
如果还不放心,使用mysqlbinlog 检查主库最近的日志文件,对比从库的relay-bin log.
从库运行命令:
view source
print?
1 stop slave;
2 CHANGE MASTER TO
3 MASTER_HOST='your_host_name',
4 MASTER_USER='replicuser_user',
5 MASTER_PASSWORD='replicuser_password',
6 MASTER_LOG_FILE='mysql-bin.000026',
7 MASTER_LOG_POS=106;
8 start slave;