Is there a way to mirror databases in MySQL? In SQL Server, you have the ability to link 2 databases in a master to master relationship. One DB will accept transactions and the transactions will be committed on both DBs at the same time. Is there a a similar concept in MySQL?
-
stackoverflow.com/questions/3402794/mysql-replicationJocelyn– Jocelyn2012年08月23日 20:29:58 +00:00Commented Aug 23, 2012 at 20:29
-
Setting up Replication in MySQL is quite easy. You can find a full guide here.DeveloperInToronto– DeveloperInToronto2012年08月23日 20:32:10 +00:00Commented Aug 23, 2012 at 20:32
-
MySQL has a "Multi-Master" replication feature in it's Cluster NDB engine. http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-replication-multi-master.htmlspencer7593– spencer75932012年08月23日 22:35:30 +00:00Commented Aug 23, 2012 at 22:35
3 Answers 3
I think the other answer missed the point of the question; which is that in SQL Server mirroring, a transaction that commits to both servers A and B are committed at the same time (in atomicity). If the transaction fails on one server, it fails on both. It doesn't seem like there is a similar feature on MySQL
its called MySQL Replication:
Replication enables data from one MySQL database server (the master) to be replicated to one or more MySQL database servers (the slaves). Replication is asynchronous by default - slaves need not to connected permanently to receive updates from the master. This means that updates can occur over long-distance connections and even over temporary or intermittent connections such as a dial-up service. Depending on the configuration, you can replicate all databases, selected databases, or even selected tables within a database.
If you want to setup a DB Cluster using MySQL that commits DB Changes on a Master and a Slave at the same time, your best setup would have to involve PXC (Percona XtraDB Cluster).
PXC uses the WriteSet Replication package from Galera (made by CoderShip)
Upon installation, Percona Server has Galera integrated. Don't worry about interoperability. Percona's server binaries are a complete drop-in replacement for MySQL's server binaries.
Read documentation because there are some limitations.Such limitations include
- All Data should be InnoDB
- No Replication of MyISAM data
- Slowest Performing Node slows down Cluster
IMHO you can reasonably live with those limitations.
If you are looking for simple mirroring, PXC would be just fine because all DB writes would go to just one server and synchronous replication would take place at COMMIT time.
I have evaluated this product and it seems very sound so far...