Mysql database sync between two databases(两个数据库之间的Mysql数据库同步)
问题描述
我们正在各个商店运行 Java PoS(销售点)应用程序,并使用 MySql 后端.我想让商店中的数据库与主机服务器上的数据库保持同步.
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 host server.
当商店发生一些变化时,它们应该在主机服务器上得到更新.我如何实现这一目标?
When some changes happen in a shop, they should get updated on the host server. How do I achieve this?
推荐答案
复制不是很难创建.
这里有一些不错的教程:
Here's some good tutorials:
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-复制
这里有一些您必须牢记的简单规则(当然还有更多规则,但这是主要概念):
Here some simple rules you will have to keep in mind (there's more of course but that is the main concept):
- 设置 1 个服务器(主)用于写入数据.
- 设置 1 个或多个服务器(从属)用于读取数据.
这样可以避免错误.
例如:如果你的脚本插入到master和slave的同一张表中,你就会有重复的主键冲突.
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.
注意:当然,您可以从主站读取,也可以向从站写入,但请确保不要写入相同的表(主站到从站和从站到主站).
我建议监控您的服务器以确保一切正常.
I would recommend to monitor your servers to make sure everything is fine.
如果您需要其他帮助,请告诉我
Let me know if you need additional help
这篇关于两个数据库之间的Mysql数据库同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:两个数据库之间的Mysql数据库同步
基础教程推荐
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
