MySQL --slave-skip-errors

本文详细介绍了MySQL从库skip-errors选项的用途、工作原理、适用场景及注意事项,帮助数据库管理员合理配置此选项,避免数据同步问题。

官方说明:

  • --slave-skip-errors=[err_code1,err_code2,...|all]

    (MySQL Cluster NDB 7.0.33 and later; MySQL Cluster NDB 7.1.22 and later:)--slave-skip-errors=[err_code1,err_code2,...|all|ddl_exist_errors]

    Command-Line Format--slave-skip-errors=name
    Option-File Formatslave-skip-errors
    System Variable Nameslave_skip_errors
    Variable ScopeGlobal
    Dynamic VariableNo
    Permitted Values (>= 5.1.61-ndb-7.0.33,5.1.61-ndb-7.1.22)
    Typestring
    DefaultOFF
    Valid Values[list of error codes]
    all
    ddl_exist_errors

    Normally, replication stops when an error occurs on the slave. This gives you the opportunity to resolve the inconsistency in the data manually. This option tells the slave SQL thread to continue replication when a statement returns any of the errors listed in the option value.

    Do not use this option unless you fully understand why you are getting errors. If there are no bugs in your replication setup and client programs, and no bugs in MySQL itself, an error that stops replication should never occur. Indiscriminate use of this option results in slaves becoming hopelessly out of synchrony with the master, with you having no idea why this has occurred.

    Note

    Prior to MySQL 5.1.35, this option had no effect with row-based logging. (Bug #39393)

    For error codes, you should use the numbers provided by the error message in your slave error log and in the output of SHOW SLAVE STATUSAppendix C, Errors, Error Codes, and Common Problems, lists server error codes.

    You can also (but should not) use the very nonrecommended value of all to cause the slave to ignore all error messages and keeps going regardless of what happens. Needless to say, if you use all, there are no guarantees regarding the integrity of your data. Please do not complain (or file bug reports) in this case if the slave's data is not anywhere close to what it is on the master. You have been warned.

    For MySQL Cluster Replication in MySQL Cluster NDB 7.0 beginning with version 7.0.33 and MySQL Cluster NDB 7.1 beginning with version 7.1.22, an additional shorthand value ddl_exist_errors is supported for use with the enhanced failover mechanism which is implemented in that and later version of MySQL Cluster NDB 7.2. This value is equivalent to the error code list 1007,1008,1050,1051,1054,1060,1061,1068,1094,1146This value is not supported by the mysqld binary included with the MySQL Server 5.1 distribution. (Bug #11762277, Bug #54854) For more information, see Section 17.6.8, “Implementing Failover with MySQL Cluster Replication”.

    Examples:

    --slave-skip-errors=1062,1053
    --slave-skip-errors=all
    --slave-skip-errors=ddl_exist_errors
    
System variables used on replication slaves.  The following list describes system variables for controlling replication slave servers. They can be set at server startup and some of them can be changed at runtime usingSET. Server options used with replication slaves are listed earlier in this section.

如果从库主要用作主库的备份,那么就不应该使用这个启动参数。设置不当,很可能造成主从数据库的数据不同步。但是,如果从数据库仅仅是为了分担主数据库的查询压力,且对数据的完整性要求不是很严格,那么这个选项的确可以减轻数据库管理员维护从数据看的工作量。

转载于:https://www.cnblogs.com/zhaoshuangshuang/p/3363722.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值