質問

I have 2 MySQL databases with same table structure but on different servers. I want to make it that when the database on server 1 is updated, the database on the server 2 is also updated, and vice versa. Can I do it in MySQL?

役に立ちましたか?

解決

What you are looking for is two-way replication. You can read up on why not to do it with mysql here If you must, mysql supports it, but it doesn't guarantee atomicity of the operations involved, which will lead to inconsistencies at some point. I stronly advise against this.

他のヒント

It's risky to do bidirectional replication, because MySQL replication is asynchronous. Below is a link to a webinar describing the risks. The recording of the webinar is free to view, but you need to register to view it. The slides are free to download.

The Hazards of Multi-writing in a Dual-Master Setup

The solution to this problem is Percona XtraDB Cluster, which is basically MySQL enhanced with synchronous, multi-way replication technology. You can have any number of servers in a cluster, and you can write changes to any of these servers. The changes are propagated to all other nodes in the cluster synchronously, greatly reducing the risks.

You can Have DATABASE REPLICATION. See this link it gives hints on how to do database replications.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top