MySQL主从数据复制问题解决办法
2017-08-16 17:52
441 查看
mysql主从复制,经常会遇到错误而导致slave端复制中断,这个时候一般就需要人工干预,跳过错误才能继续
跳过错误有两种方式:
1.跳过指定数量的事务:
mysql>slave stop;
mysql>set global sql_slave_skip_counter=1; #跳过一个事务
mysql>slave start
2.修改mysql的配置文件,通过slave_skip_errors参数来跳所有错误或指定类型的错误
vi /etc/my.cnf
[mysqld]
slave-skip-errors=1062,1053,1146 #跳过指定error no类型的错误
#slave-skip-errors=all #跳过所有错误
注意:当配置文件里写两行:
slave-skip-errors=1062
slave-skip-errors=1032时,第二个参数会覆盖第一个参数。所以一定要写到同一行,并用逗号分隔。
虽然slave会跳过这些错误,继续复制,但是仍会以Warning的形式记录到错误日志中,如:
160620 10:40:17 [Warning] Slave SQL: Could not execute Write_rows event on table dba.t; Duplicate entry '10' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.000033, end_log_pos 1224, Error_code: 1062
重启Mysql服务
那些没有被复制的错误数据会输出到日志中
如:
发生这种情况,一般是主机断电引起的!!
跳过错误有两种方式:
1.跳过指定数量的事务:
mysql>slave stop;
mysql>set global sql_slave_skip_counter=1; #跳过一个事务
mysql>slave start
2.修改mysql的配置文件,通过slave_skip_errors参数来跳所有错误或指定类型的错误
vi /etc/my.cnf
[mysqld]
slave-skip-errors=1062,1053,1146 #跳过指定error no类型的错误
#slave-skip-errors=all #跳过所有错误
注意:当配置文件里写两行:
slave-skip-errors=1062
slave-skip-errors=1032时,第二个参数会覆盖第一个参数。所以一定要写到同一行,并用逗号分隔。
虽然slave会跳过这些错误,继续复制,但是仍会以Warning的形式记录到错误日志中,如:
160620 10:40:17 [Warning] Slave SQL: Could not execute Write_rows event on table dba.t; Duplicate entry '10' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.000033, end_log_pos 1224, Error_code: 1062
重启Mysql服务
那些没有被复制的错误数据会输出到日志中
如:
Error_code: 1062 Aug 16 17:44:53 mysql75 mysqld: 2017-08-16T09:44:53.142158Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15616-62' for key 'PRIMARY';, Error_code: 1062 Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.910737Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-84' for key 'PRIMARY';, Error_code: 1062 Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.911141Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-85' for key 'PRIMARY';, Error_code: 1062 Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.911918Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-87' for key 'PRIMARY';, Error_code: 1062 Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.912676Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-88' for key 'PRIMARY';, Error_code: 1062 Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.913248Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-89' for key 'PRIMARY';, Error_code: 1062 Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.913808Z 2 [Note] Slave SQL for channel 4000 '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-90' for key 'PRIMARY';, Error_code: 1062 Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.914573Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-91' for key 'PRIMARY';, Error_code: 1062 Aug 16 17:46:18 mysql75 mysqld: 2017-08-16T09:46:18.933328Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 15293ms. The settings might not be optimal. (flushed=4427 and evicted=0, during the time.) Aug 16 17:48:48 mysql75 mysqld: 2017-08-16T09:48:48.759770Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 4020ms. The settings might not be optimal. (flushed=4850 and evicted=0, during the time.) Aug 16 17:49:30 mysql75 mysqld: 2017-08-16T09:49:30.383725Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 4139ms. The settings might not be optimal. (flushed=4984 and evicted=0, during the time.)
发生这种情况,一般是主机断电引起的!!
相关文章推荐
- GridView导出数据到excel数字变为科学记数法的问题的解决办法
- Visio虚线复制到word中变为实线问题的解决办法
- Mysql导入数据时乱码问题解决办法
- PDO取Oracle lob大字段,当数据量太大无法取出的问题的解决办法
- IE6中运行EXTJS中某些组件无法解析DOMINO产生的JSON数据问题的解决办法
- Hibernate数据的lazy问题,以及使用spring整合hibernate lazy的解决办法(好文转载)
- GridView导出数据到excel数字变为科学记数法的问题的解决办法
- 【数据操作】安装SQLServer2008问题解决办法
- PDO取Oracle lob大字段,当数据量太大无法取出的问题的解决办法
- 常见问题及解决办法 整理之10(SQL SERVER 2005 同步复制技术)
- 已知Oracle数据库有GD和ZS两个数据库,GD数据库v_s表有数据写入时,从v_s表中提取最新数据到ZS数据库的D_E表中。请问用什么办法解决这一问题?如果又碰到不能互访的问题时,又用什么办法解决?
- 使用dbms_rectifier_diff解决高级复制中的数据冲突问题
- MySQL问题贴3:Delphi第一次编译连接MySQl数据时缺少dll文件的解决办法
- PDO取Oracle lob大字段,当数据量太大无法取出的问题的解决办法
- 关于使用DirectShow架构,传输YUV420数据的Filter与Video Renderer Filter连接问题的解决办法。
- 使用dbms_rectifier_diff解决高级复制中的数据冲突问题
- flash读外部数据中文乱问题解决办法
- eXtremeTable导出数据为XLS和PDF时的中文问题解决办法
- 智能设备下,在ComboBox控件添加了多项数据,只显示第一项数据,而不显示其它数据的问题解决办法
- 关于CListCtrl控件更新Item的闪烁问题和一次插入大容量数据的显示问题解决办法