Home >Database >Mysql Tutorial >Mysql主库服务器重启造成从库同步失败(Got fatal error 1236 fr

Mysql主库服务器重启造成从库同步失败(Got fatal error 1236 fr

WBOY
WBOYOriginal
2016-06-07 16:35:181453browse

某一台vps最近隔一周左右就会被意外重启一次,悲催的是这台vps上正好搭着Mysql的主库,这台机器重启后会造成从库的数据库同步时候出现「Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replicatio

某一台vps最近隔一周左右就会被意外重启一次,悲催的是这台vps上正好搭着Mysql的主库,这台机器重启后会造成从库的数据库同步时候出现「Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position'」的错误。

这时候的状态是:在从库上执行SHOW SLAVE STATUS;时候会出现Slave_IO_Running: No的提示。并能找到

解决办法(适用于lnmp 0.9版本):

  1. 登录主库服务器
  2. 执行/usr/local/mysql/bin/mysqlbinlog /usr/local/mysql/var/mysql-bin.000023>test.txt
  3. less test.txt
  4. 找到最近的一条position id,参考下图:
    最近的position id
  5. 从库服务器mysql执行STOP SLAVE;
  6. CHANGE MASTER TO MASTERHOST='主库ip',MASTERUSER='同步用户',MASTERPASSWORD='同步密码',MASTERLOGFILE='mysql-bin.000023',MASTERLOG_POS=130216;
  7. SLAVE START;
  8. 这时候再看SHOW SLAVE STATUS;就会看到已经可以正常同步了
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn