简体   繁体   English

SQL Server简单冗余

[英]SQL Server Simple Redundancy

I am quite a rookie here and would like to ask all you experts out here on the preferred method of configuring two SQL Servers (2008 R2 and above) for a simple redundancy with the following characteristics: 我在这里很菜鸟,想请所有专家就配置两个SQL Server(2008 R2及更高版本)的首选方法提供以下特征的简单冗余:

  1. There are 2 computers. 有2台计算机。 Each will have its own SQL Server, and also its own windows service writing timestamped data regularly to the DB. 每个服务器都有自己的SQL Server,也有自己的Windows服务,将带有时间戳的数据定期写入数据库。 This service already has its own simple switchover/failover algorithm. 该服务已经具有自己的简单切换/故障转移算法。

  2. For the behaviour of the databases, once the primary server goes offline, the backup computer's service will take over to write data to the backup database. 对于数据库的行为,一旦主服务器脱机,备用计算机的服务将接管将数据写入备用数据库。 The clients will know that since the primary is down, it will reconnect to the backup for data retrieval. 客户端将知道,由于主数据库已关闭,它将重新连接到备份以进行数据检索。

  3. Now, when the primary gets back online, the service in this computer will start to write data to database, while the service in the backup computer will stop. 现在,当主数据库重新联机时,此计算机中的服务将开始将数据写入数据库,而备份计算机中的服务将停止。

  4. From here, a suitable synchronisation plan is required to ensure that the data from the backup database will be synched, or transferred back to the primary database for integrity. 从这里开始,需要一个合适的同步计划,以确保备份数据库中的数据将被同步或传输回主数据库以确保完整性。 In fact, even when the primary is not offline, both databases should be synched as well. 实际上,即使主数据库不脱机,两个数据库也应同步。

From my descriptions above, I have gone through several texts and arrived at 3 possible candidate methods: 从上面的描述中,我浏览了几篇文章,得出了3种可能的候选方法:

  1. Merge Replication 合并复制
  2. Mirroring 镜像
  3. Additional Customised Programming - really, the last resort, but if needed to I will have to get my hands dirty on this 附加的自定义编程-确实是最后的手段,但是如果需要的话,我将不得不动手做这件事

As a late entrant to recent MS technologies after a long hiatus, I was initially a bit lost. 中断了很长时间之后,作为最新MS技术的较晚进入者,我起初有些失落。 I could not find a clear indication while reading those texts, on whether the methods supports behaviour (4) as described above. 阅读这些文本时,我找不到关于该方法是否支持上述行为(4)的明确指示。

As I understand, method (2) will not work in our case because after failover, the Backup DB becomes the "Principal", and the Primary DB becomes the "Mirror DB". 据我了解,方法(2)在我们的情况下不起作用,因为故障转移后,备份DB成为“主体”,而主DB成为“镜像数据库”。 From what I have read, the Mirror DB is offline and not able to be accessed. 根据我的阅读,Mirror DB处于脱机状态,无法访问。 Kindly note the windows service behaviour in (3) above. 请注意上面(3)中的Windows服务行为。

As for method (1), I am confused as to how it will (or will not) work. 至于方法(1),我对它如何(或不可以)工作感到困惑。 For example, I understand the concept of Publishing and Subscribing, so the Primary DB will be configured as the publisher, and the Backup DB will be the subscriber. 例如,我了解发布和订阅的概念,因此主数据库将配置为发布者,备份数据库将成为订阅者。 In order to merge, the Backup DB will also need to be configured as the publisher and vice versa. 为了合并,还需要将备份数据库配置为发布者,反之亦然。 In this case, imagine that the service in the Primary is writing data to the DB, then it gets published to the Backup DB. 在这种情况下,假设主服务器中的服务正在将数据写入数据库,然后将其发布到备份数据库。 Then, again the Backup DB will publish this back to the Primary DB (all based on triggers). 然后,备份数据库再次将其发布回主数据库(全部基于触发器)。 It seems like an infinite loop here. 这里似乎是一个无限循环。

I hope my assumptions are fairly correct. 我希望我的假设是正确的。 What am I missing? 我想念什么?

Note: Those servers will only be arriving in a week's time, so I have nothing to test on right now. 注意:这些服务器将仅在一周的时间内到达,因此我现在无需进行任何测试。 Can only prepare theoretically. 理论上只能准备。

Thanks and Regards. 谢谢并恭祝安康。

If you really need credibility without investing a lot of time, I would suggest to go with the standard solution which is database mirroring . 如果您确实需要信誉而不花很多时间,那么我建议您使用数据库镜像的标准解决方案。 Automatic failover works with having a witness machine which handles the database communication and therefore the client application would not even know if such a failure occurs on the database server. 自动故障转移与具有处理数据库通信的见证机器一起使用,因此客户端应用程序甚至都不知道数据库服务器上是否发生这种故障。 Therefore, your worries about point (3) would not 因此,您不必担心第(3)点

However, this architecture leaves you with a single point of failure, the witness . 但是, 见证程序使您无法进行单点故障处理 If the witness fails, you have to use redundancy strategy. 如果见证服务器失败,则必须使用冗余策略。 The advantage is that this new recovery process, will not include the database recovery process itself. 优点是此新的恢复过程将不包括数据库恢复过程本身。

Hope I helped! 希望我能帮上忙!

Merge Replication is viable. 合并复制是可行的。 In Merge Replication, you publish to the subscriber. 在合并复制中,您将发布到订阅服务器。 Any changes made at the subscriber are made at the publisher when synchronization takes place. 同步发生时,在订阅服务器上进行的所有更改都将在发布服务器上进行。 If the publisher goes offline, then the changes at the subscriber will be copied to the publisher when it comes back online and syncs. 如果发布者脱机,则订阅者所做的更改将在重新联机并同步时被复制到发布者。

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

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