简体   繁体   English

非常大的表的SQL Server事务复制

[英]SQL Server transactional replication for very large tables

I have set up transactional replication between two SQL Servers on different ends of a relatively slow VPN connection. 我已经在相对较慢的VPN连接的不同端的两个SQL Server之间设置了事务复制。 The setup is your standard "load snapshot immediately" kind of thing where the first thing it does after initializing the subscription is to drop and recreate all tables on the subscriber side and then start doing a BCP of all the data. 该设置是您标准的“立即加载快照”类型的事情,其中​​初始化订阅后它首先执行的操作是删除并重新创建订户端的所有表,然后开始执行所有数据的BCP。 The problem is that there are a few tables with several million rows in them, and the process either a) takes a REALLY long time or b) just flat out fails. 问题是,有在他们几百万行的几张桌子,过程或者a)需要长的时间或者b)只是平了失败。 The messages I keep getting when I look in Replication Monitor are: 我查看Replication Monitor时收到的消息是:

  • The process is running and is waiting for a response from the server. 进程正在运行,正在等待服务器的响应。
  • Query timeout expired 查询超时已过期
  • Initializing 初始化

It then tries to restart the bulk loading process (skipping any BCP files that it has already loaded). 然后它尝试重新启动批量加载过程(跳过它已加载的任何BCP文件)。

I am currently stuck where it just keeps doing this over and over again. 我现在卡在一直反复做这件事的地方。 It's been running for a couple days now. 它已经运行了几天了。

My questions are: 我的问题是:

  1. Is there something I could do to improve this situation given that the network connection is so slow? 鉴于网络连接速度太慢,我能做些什么来改善这种情况? Maybe some setting or something? 也许一些设置或什么? I don't mind waiting a long time as long as the process doesn't keep timing out. 我不介意等待很长时间,只要这个过程不能保持超时。

  2. Is there a better way to do this? 有一个更好的方法吗? Perhaps make a backup, zip it, copy it over and then restore? 也许做一个备份,拉链,复制然后恢复? If so, how would the replication process know where to pick up when it starts applying the transactions, since updates will be occurring between the time I make the backup and get it restored and running on the other side. 如果是这样,复制过程在开始应用事务时如何知道在哪里获取,因为在我进行备份和恢复并在另一端运行之间将进行更新。

Yes. 是。 You can apply the initial snapshot manually . 您可以手动应用初始快照

It's been a while for me, but the link (into BOL) has alternatives to setting up the subscriber. 对我来说已经有一段时间了,但链接(进入BOL)可以替代设置用户。

Edit: From BOL How-tos, Initialize a Transactional Subscriber from a Backup 编辑:从BOL How-tos, 从备份初始化事务订阅者

In SQL 2005, you have a "compact snapshot" option, that allow you to reduce the total size of the snapshot. 在SQL 2005中,您有一个“紧凑快照”选项,允许您减少快照的总大小。 When applied over a network, snapshot items "travel" compacted to the suscriber, where they are then expanded. 当通过网络应用时,快照项“旅行”压缩到潜在客户,然后在那里扩展它们。

I think you can easily figure the potential speed gain by comparing sizes of standard and compacted snapshots. 我认为您可以通过比较标准快照和压缩快照的大小来轻松计算潜在的速度增益。

By the way, there is a (quite) similar question here for merge replication, but I think that at the snapshot level there is no difference. 顺便说一句,有一个(相当)类似的问题, 在这里为合并复制,但我认为,在快照水平没有差别。

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

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