- 论坛徽章:
- 0
|
接上一个:那位大虾有时间看看我的翻译,我想把关于mysql replication的FAQ翻译成中文
出处:http://dev.mysql.com/doc/refman/4.1/en/replication-faq.html
Q: What issues should I be aware of when setting up two-way replication?
Q:我设置双向同步,担心什么问题?
-----------------------------------------------------------------------------------------------------------------------------------------
A: MySQL replication currently does not support any locking protocol between master and slave to guarantee the atomicity of a distributed (cross-server) update. In other words, it is possible for client A to make an update to co-master 1, and in the meantime, before it propagates to co-master 2, client B could make an update to co-master 2 that makes the update of client A work differently than it did on co-master 1. Thus, when the update of client A makes it to co-master 2, it produces tables that are different than what you have on co-master 1, even after all the updates from co-master 2 have also propagated. This means that you should not chain two servers together in a two-way replication relationship unless you are sure that your updates can safely happen in any order, or unless you take care of mis-ordered updates somehow in the client code.
---------------------------------------------------------------------------------------------------------------------------------
You must also realize that two-way replication actually does not improve performance very much (if at all), as far as updates are concerned. Both servers need to do the same number of updates each, as you would have one server do. The only difference is that there is a little less lock contention, because the updates originating on another server are serialized in one slave thread. Even this benefit might be offset by network delays.
----------------------------------------------------------------------------------------------------------------------------------------------
A:当前MySQL replication并不支持在master和slave之间利用锁表协议保证slave同步到和master非常的精确。换句话说,client A(slave)可以做到让它的master也进行更新同步,同时,在它变成第二个master时,client B也可以作为master 2的更新源。这样,当client A变成master 2时,即使所有来自master 2的更新得到同步,它产生的表也会和master 1上不同。这就意味这你不能把两天服务器做成双向同步,除非你的更新在任意一个时刻都是非常安全可靠的或者只是进行无序更新。
---------------------------------------------------------------------------------------------------------------------------------
你也必须认识到这种双向同步没有任何问题,其实并不会提高效率。两台服务器每台都要做类似只有一台master时那样同样数量的相互更新。不同之处在于有有很多的锁冲突,因为在他们之间,有相同的slave线程在执行。唯一的好处就是网络延迟不会造成同步失效。 |
|