zoukankan      html  css  js  c++  java
  • 复制故障处理

    slave复制中,常见的错误有:

    1032:Can't find record in %s
    1053:Server shutdown in process
    1062:Duplicate entry %s for key %d
    1050:Table %s already exists
    1051:Unknown table %s
    1054:Unknown column %s in %s
    1146:Table %s.%s doesn't exists
    1236:Fatal error reading binlog
     

    1032,1062,1236错误处理

    记录不存在:1032(主库更新或删除的记录在从库上不存在)
    看在master上执行了什么
    mysqlbinlog --base64-output=decode-rows -vv --start-position='1009144978' --stop-position='1010617671' mysql-bin.000045
    将相应的记录在从库上执行
    记录不存在:1032(delete情况)
    跳过一个事务
    传统环境复制:
    stop slave;
    set global sql_slave_skip_counter = 1;
    start slave;
    GTID环境复制:
    stop slave;
    set gtid_next='766d5362-c923-11e6-85b5-000c29de38de:12';   已执行的加1
    begin;commit;
    set gtid_next='AUTOMATIC';
    start slave;
    主键冲突:1062错误
    在从库上将相应主键的记录删掉
    1236错误:log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master;
    show VARIABLES like '%max_allowed_packet%';
    set global max_allowed_packet =512*1024*1024;
     

    MySQL5.6针对复制功能提供了新特性:slave支持crash-safe

    1.停止slave的MySQL实例
    2.my.cnf文件中添加
       master-info-repository=TABLE
       relay-log-info-repository=TABLE
       relay-log-recovery
    3.重启slave的MySQL实例
     
  • 相关阅读:
    查询数据库锁的SQL
    注解学习实例(模拟hibernate,table,column注解,拼装SQL)
    mongoDB学习笔记
    拼装SQL.例子
    MySQL实现类似Oracle序列的函数
    面试总结
    linux下常用命令
    PHP 中 flush() 与 ob_flush() 的区别
    PHP 使用共享内存的资料
    移动设备的web站开发和将web封转成移动端应用的一些资料
  • 原文地址:https://www.cnblogs.com/allenhu320/p/11316305.html
Copyright © 2011-2022 走看看