Mysql database sync between two databases

后端 未结 4 1163
独厮守ぢ
独厮守ぢ 2020-11-27 10:39

We are running a Java PoS (Point of Sale) application at various shops, with a MySql backend. I want to keep the databases in the shops synchronised with a database on a hos

4条回答
  •  借酒劲吻你
    2020-11-27 11:32

    Replication is not very hard to create.

    Here's some good tutorials:

    http://aciddrop.com/2008/01/10/step-by-step-how-to-setup-mysql-database-replication/

    http://www.ghacks.net/2009/04/09/set-up-mysql-database-replication/

    http://dev.mysql.com/doc/refman/5.5/en/replication-howto.html

    http://www.lassosoft.com/Beginners-Guide-to-MySQL-Replication

    Here some simple rules you will have to keep in mind (there's more of course but that is the main concept):

    1. Setup 1 server (master) for writing data.
    2. Setup 1 or more servers (slaves) for reading data.

    This way, you will avoid errors.

    For example: If your script insert into the same tables on both master and slave, you will have duplicate primary key conflict.

    You can view the "slave" as a "backup" server which hold the same information as the master but cannot add data directly, only follow what the master server instructions.

    NOTE: Of course you can read from the master and you can write to the slave but make sure you don't write to the same tables (master to slave and slave to master).

    I would recommend to monitor your servers to make sure everything is fine.

    Let me know if you need additional help

提交回复
热议问题