简体   繁体   English

设置要从主数据库更新的本地数据库

[英]setting up a local database to be updated from a master database

I'm looking for an efficient way to keep multiple databases (on different servers) sync with a master database (also on a different server). 我正在寻找一种使多个数据库(在不同服务器上)与master数据库(也在另一个服务器上)同步的有效方法。 Mind you I only need a one way sync (from master to all others). 请注意,我只需要一种单向同步(从主同步到所有其他同步)。

As I was searching I came across multiple solutions. 在搜索时,我遇到了多种解决方案。

  • replication : Which (from what I read) is unreliable, because if the slave servers or down temporarily or anything like that, they end up missing information. replication :哪个(从我的读物来看)是不可靠的,因为如果从属服务器暂时关闭或关闭或诸如此类,它们最终会丢失信息。 (Please correct me if I'm wrong) (如果我错了,请纠正我)
  • Injection : Which I also think is unreliable, not to mention a security problem because you're directly communicating with the slave databases. Injection :我也认为这是不可靠的,更不用说安全问题了,因为您正在直接与从数据库通信。

Since I didn't like what I saw, I decided to make my own system (ultimately not liking it either) My system was to make a new table called ORDERS , and would basically hold values that could be translated as "Delete item with id 32 in table someTable" and on the slave side they would follow each of these instructions. 由于我不喜欢自己看到的内容,因此我决定创建自己的系统(最终也不喜欢),我的系统是创建一个名为ORDERS的新表,并且基本上将保留可以转换为“删除带有ID的项目”的值表someTable中的“ 32”,在从属端,它们将遵循这些指令中的每一个。

What do you think is the best way? 您认为最好的方法是什么? The database is really small (with at most 3000 entries), so I want a really simple solution. 该数据库非常小(最多具有3000个条目),所以我想要一个非常简单的解决方案。 Thanks 谢谢

If you are using mysql, just use a master/slave setup. 如果您使用的是mysql,则只需使用主/从设置。 Not sure where you heard it's unreliable if the slave goes down. 不确定从站掉线是否不可靠。 One of the settings is how long of a replication log history to keep. 设置之一是复制日志历史记录保留的时间。 If this is set to 7 days on the master, then a slave can go down and be offline for up to 7 days. 如果在主服务器上将其设置为7天,则从服务器可以关闭并脱机长达7天。 When the slave starts back up, it starts reading from the replication log where it left off. 当从属服务器开始备份时,它将从停止的复制日志开始读取。 It will take a while to catch up, but you won't lose anything. 赶上需要一段时间,但您不会失去任何东西。

Companies have been using mysql replication for years with no problems. 多年来,公司一直在使用mysql复制没有问题。 I have a master-master circular replication setup with slave off of each master. 我有一个主-主循环复制设置,每个主控都带有从属。 I've actually had a triple master setup during a migration with the servers on opposite side of the country. 实际上,在迁移过程中,我在该国的另一端使用了三重主服务器设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM