2

有没有办法获得容错的 MySQL 复制?我所处的环境有很多网络问题。复制似乎出现错误并停止。我需要它继续工作并从这些故障中恢复。有一些包装软件会检查复制的状态并在丢失其日志位置的情况下重新启动它。有替代方案吗?

注意:复制是从具有 MySQL 4.1 的嵌入式计算机到具有 MySQL 5.0.45 的外部计算机完成的

4

4 回答 4

2

What error are you getting? You also haven't described what replication scheme or Mysql version you're using. The errors you're getting are also important.

Replication usually stops when there's a primary/unique key conflict in a Master-Master replication. Other than that on a typical Master-Slave replication setup, networking issues shouldn't cause problems.

Try using Mysql 5.1 or newer, since replication in 5.0 is statement-based and causes problems in Master-Master setups, or when you're using stored-procedures.

(Also, stay away from Mysql Cluster ... noticed the advice on another comment).

于 2009-06-08T06:37:18.057 回答
2

仅当数据库以某种方式不同步时才会发生复制错误,让服务器简单地继续意味着数据库不连贯,我真的怀疑你是否想要这样。

以我的经验,唯一出现此类错误的情况是其中一台主服务器未完成查询并且从服务器注意到。

在任何情况下,如果你真的想让从属通过某种计时作业继续,你总是可以每隔几分钟运行一次查询,询问从属“ SHOW SLAVE STATUS”然后检查错误列,如果存在,发送一个“ STOP SLAVE; SET GLOBAL SQL_SLAVE_SKIP_COUNTER; START SLAVE;”命令. 但是当 mysql 遇到错误时,可能更倾向于向管理员发送电子邮件,因此他/她可以调查问题的根源并确保数据库实际上是同步的,否则您可能会看到随着数据库变得越来越不同步,在不久的将来会出现更多错误。

于 2009-06-08T12:28:13.310 回答
1

考虑使用 NDB 存储引擎的 MySQL Cluster,它意味着无共享和容错

于 2009-06-06T15:25:12.630 回答
1

MySQL replication will normally detect problems and reconnect anyway, continuing from where it left off.

If you're getting replication errors, it's likely that the source is something else. MySQL replication effectively does a "tail -f" on the query log and replays it on the slave (it's slightly smarter than that, but not much).

If the databases become out of sync, MySQL replication will neither detect nor repair this, but it may eventually cause it to break as a subsequent update cannot proceed due to conflicting data on the slave.

The default timeouts on the replication slave are much too long - it waits hours (or something) - you'll want to reduce this.

Data becoming out of sync is difficult to avoid, mitigation steps are:

  • Monitor replication using something like mk-table-checksum from Maatkit
  • Audit all your code for replication-unsafe queries
  • If using 5.1, switch to row-based replication, which is less likely to suffer from this problem
于 2009-06-08T06:46:58.757 回答