mysql slave-skip-errors_mysql之slave_skip_errors选项

要说slave_skip_errors选项,就不得不提mysql的replication机制,总的来说它分了三步来实现mysql主从库的同步

master将改变记录到二进制日志(binary log)中(这些记录叫做二进制日志事件,binary log events);

slave将master的binary log events拷贝到它的中继日志(relay log);

slave重做中继日志中的事件,将改变反映它自己的数据。

但是在主从同步中会出现因为从库执行某些sql语句失败而导致主从备份关系失效,如果要修复这种失效就需要用到slave_skip_errors参数(使用sql_skip_errors_counter也是可以的)。

slave_skip_errors选项有四个可用值,分别为:off、all、ErorCode、ddl_exist_errors。

af200c1102d8d74502ec79028f499f42.png

根据各个值得字面意思即可知道它们的用法,但是其中ddl_exist_errors值却比较特别,它代表了一组errorCode的组合,分别是:

1007:数据库已存在,创建数据库失败

1008:数据库不存在,删除数据库失败

1050:数据表已存在,创建数据表失败

1050:数据表不存在,删除数据表失败

1054:字段不存在,或程序文件跟数据库有冲突

1060:字段重复,导致无法插入

1061:重复键名

1068:定义了多个主键

1094:位置线程ID

1146:数据表缺失,请恢复数据库

但是还要注意的是,该值只在mysql cluster版的mysqld中才可用,而在mysql Server版的mysqld中不可用。

用到的文章:

如何查看bin-log内容:http://blog.chinaunix.net/uid-16844903-id-3896711.html

mysql主从同步原理:http://machael.blog.51cto.com/829462/239112/

mysql配置文件说明:http://www.educity.cn/shujuku/1095729.html

mysql小误区:http://dinglin.iteye.com/blog/1236330

mysql复制的几种模式:http://www.cnblogs.com/end/archive/2012/12/05/2803975.html

参考:

mysql错误代码:http://dev.mysql.com/doc/refman/5.1/en/error-messages-server.html

mysql bugs之关于ddl_exist_errors值:http://i.cnblogs.com/EditPosts.aspx?opt=1

扩展阅读:

replication常用架构:http://www.cnblogs.com/ggjucheng/archive/2012/11/13/2768879.html

理解mysql 复制(replication):http://www.cnblogs.com/hustcat/archive/2009/12/19/1627525.html

原文:http://www.cnblogs.com/lit10050528/p/3958430.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Master configuration Find the my.cnf file Configure under [mysqld] [mysqld] server-id=1 log-bin=master-bin   Restart the service and log in to mysql Create a user to obtain the log file. mysql> CREATE USER 'sree'@'%' IDENTIFIED BY 'sree' Grant relevant permissions (copy permissions) *.* represents all tables in all libraries mysql> grant replication slave on *.* to 'sree'@'%'   Refresh permissions mysql> flush privileges mysql> show master status; | File | Position | master-bin.000004 | 120                      Slave configuration ==================== Modify the configuration file: Configure under [mysqld] [mysqld] server-id=2 #As long as it is different from the above.   Then log in to mysql mysql>  CHANGE MASTER TO     MASTER_LOG_FILE='master-bin.000004 ', #above file        MASTER_LOG_POS = 120 ; #The above position        MASTER_HOST='192.168.249.130', #The ip address of the main library         MASTER_USER = 'sree',         MASTER_PASSWORD = 'sree',  Then start slave ============ mysql> show slave status\G; see: ===  Slave_IO_Running: Yes  Slave_SQL_Running: Yes It means that it was successful.     Errors in the whole process: Slave_IO_Running: Connecting 1. Mine is the wrong host ip. 2. There are still some firewalls on the Internet that are not turned off I use centos7 to turn off the firewall: systemctl stop firewalld 3. There is also a mistake in the above-mentioned secret.   Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs This error generally occur when we clone the master to slaver. Delete auto.cnf of mysql, and then restart the service.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值