MySQL二进制日志复制:是否可以将其设置为忽略错误? [英] MySQL Binary Log Replication: Can it be set to ignore errors?

查看:125
本文介绍了MySQL二进制日志复制:是否可以将其设置为忽略错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个主从MySQL二进制日志复制系统(phew!),对于某些数据,该系统不同步(意味着主数据库比从数据库拥有更多的数据).但是奴隶在丝毫MySQL错误中非常频繁地停止,可以禁用它吗? (也许是my.cnf设置,用于复制从属的ignore-replicating-errors或某种类型的错误;))

这就是发生的情况,时不时地,当从属尝试复制不存在的项目时,从属就会死亡.快速检查 SHOW SLAVE STATUS \ G; 给出

       Slave-IO-Running: Yes
      Slave-SQL-Running: No
        Replicate-Do-DB: 
             Last-Errno: 1062
             Last-Error: Error 'Duplicate entry '15218' for key 1' on query. Default database: 'db'. Query: 'INSERT INTO db.table ( FIELDS ) VALUES ( VALUES )'

我会通过以下操作立即修复(一旦我意识到从站已停止):

STOP SLAVE;
RESET SLAVE;
START SLAVE;

...最近,这变得有点烦人,在我吐出某种为我做这件事的PHP之前,我想知道是否有一些my.cnf条目不会在第一个错误时杀死该奴隶.

干杯

/mp

解决方案

是的,在my.cnf中带有--slave-skip-errors = xxx,其中xxx为'all'或错误代码的逗号分隔列表. /p>

I'm running a master-slave MySQL binary log replication system (phew!) that, for some data, is not in sync (meaning, the master holds more data than the slave). But the slave stops very frequently on the slightest MySQL error, can this be disabled? (perhaps a my.cnf setting for the replicating slave ignore-replicating-errors or some of the sort ;) )

This is what happens, every now and then, when the slave tries to replicate an item that does not exist, the slave just dies. a quick check at SHOW SLAVE STATUS \G; gives

       Slave-IO-Running: Yes
      Slave-SQL-Running: No
        Replicate-Do-DB: 
             Last-Errno: 1062
             Last-Error: Error 'Duplicate entry '15218' for key 1' on query. Default database: 'db'. Query: 'INSERT INTO db.table ( FIELDS ) VALUES ( VALUES )'

which I promptly fix (once I realize that the slave has been stopped) by doing the following:

STOP SLAVE;
RESET SLAVE;
START SLAVE;

... lately this has been getting kind of tiresome, and before I spit out some sort of PHP which does this for me, i was wondering if there's some my.cnf entry which will not kill the slave on the first error.

Cheers,

/mp

解决方案

Yes, with --slave-skip-errors=xxx in my.cnf, where xxx is 'all' or a comma sep list of error codes.

这篇关于MySQL二进制日志复制:是否可以将其设置为忽略错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆