MySQL --slave-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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以参考以下步骤来使用 Docker Compose 部署 WordPress 连接 MySQL 主从复制: 1. 创建一个 Docker Compose 文件 `docker-compose.yml`,并在其中定义两个服务:WordPress 和 MySQL。 ``` version: '3.8' services: db-master: image: mysql:5.7 command: --server-id=1 --log-bin=mysql-bin --binlog-format=row --gtid-mode=ON --enforce-gtid-consistency=ON --slave-skip-errors=all restart: always environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: wordpress volumes: - db-master:/var/lib/mysql networks: - wp-net db-slave: image: mysql:5.7 command: --server-id=2 --log-bin=mysql-bin --binlog-format=row --gtid-mode=ON --enforce-gtid-consistency=ON --slave-skip-errors=all --skip-log-slave-updates restart: always environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: wordpress MYSQL_MASTER_HOST: db-master MYSQL_MASTER_PASSWORD: password MYSQL_ALLOW_EMPTY_PASSWORD: "yes" volumes: - db-slave:/var/lib/mysql depends_on: - db-master networks: - wp-net wordpress: depends_on: - db-slave image: wordpress:latest ports: - "8000:80" restart: always environment: WORDPRESS_DB_HOST: db-slave WORDPRESS_DB_USER: root WORDPRESS_DB_PASSWORD: password WORDPRESS_DB_NAME: wordpress volumes: - wp-content:/var/www/html/wp-content networks: - wp-net volumes: db-master: db-slave: wp-content: networks: wp-net: ``` 2. 在 `db-master` 和 `db-slave` 服务中,分别使用 `--server-id` 设置不同的 ID;使用 `--log-bin` 启用二进制日志;使用 `--binlog-format` 设置二进制日志格式为行格式;使用 `--gtid-mode` 和 `--enforce-gtid-consistency` 启用 GTID 并强制要求一致性;使用 `--slave-skip-errors=all` 设置从库同步时遇到错误时跳过。 3. 在 `db-master` 服务中,使用 `MYSQL_ROOT_PASSWORD` 和 `MYSQL_DATABASE` 设置 root 用户的密码和数据库名;使用 `volumes` 把数据卷挂载到 `/var/lib/mysql` 目录。 4. 在 `db-slave` 服务中,使用 `MYSQL_ROOT_PASSWORD` 和 `MYSQL_DATABASE` 设置 root 用户的密码和数据库名;使用 `MYSQL_MASTER_HOST` 和 `MYSQL_MASTER_PASSWORD` 分别设置主库的主机名和密码;使用 `MYSQL_ALLOW_EMPTY_PASSWORD` 设置空密码;使用 `depends_on` 指定依赖的服务;使用 `volumes` 把数据卷挂载到 `/var/lib/mysql` 目录。 5. 在 `wordpress` 服务中,使用 `depends_on` 指定依赖的服务;使用 `WORDPRESS_DB_HOST`、`WORDPRESS_DB_USER`、`WORDPRESS_DB_PASSWORD` 和 `WORDPRESS_DB_NAME` 分别设置数据库的主机名、用户名、密码和数据库名;使用 `volumes` 把数据卷挂载到 `/var/www/html/wp-content` 目录。 6. 运行 `docker-compose up -d` 启动服务。 这样就可以使用 Docker Compose 部署 WordPress 连接 MySQL 主从复制了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值