简体   繁体   English

SQL Server事务复制重新发布

[英]SQL Server transactional replication republication

We have a transactional replication setup where the subscriber is also a publisher to a second set of subscribers. 我们有一个事务复制设置,其中订户也是第二组订户的发布者。 I think this is because of the slow link between the primary publisher and the subscriber. 我认为这是由于主要发布者和订阅者之间的链接速度较慢。 The subscriber publishes the same set of articles to multiple local subscribers. 订户将相同的文章集发布给多个本地订户。

One problem we have is when the primary publisher/subscriber setup needs to be reinitialized, we have to remove the second publisher/subscriber setup. 我们遇到的一个问题是,当需要重新初始化主要的发布者/订阅者设置时,我们必须删除第二个发布者/订阅者设置。 We get errors regarding dropping of tables otherwise. 否则,我们会收到有关删除表的错误。 They can't be dropped by the initialization process because they are being used for replication by the second setup. 在初始化过程中不能删除它们,因为第二个设置将它们用于复制。

Maybe this is the way it has to be done but I'm wondering if there is a better way. 也许这是必须完成的方法,但是我想知道是否有更好的方法。 Looking for any tips or suggestions. 寻找任何提示或建议。

Thanks, Kevin 谢谢,凯文

Maybe. 也许。 The procedure to add an article ( sp_addarticle ) takes a parameter @pre_creation_cmd that specifies what to do before creating the article. 添加文章的过程( sp_addarticle )使用参数@pre_creation_cmd ,该参数指定在创建文章之前要执行的操作。 The default is "drop", but can be "none" (do nothing), "delete" (deletes all data in the destination table), or "truncate" (truncates the destination table). 默认值为“ drop”,但可以为“ none”(不执行任何操作),“ delete”(删除目标表中的所有数据)或“ truncate”(截断目标表)。 In your case, I'd choose "delete" since you can't truncate a replicated table, either. 在您的情况下,由于您也无法截断复制的表,因此我选择“删除”。

But I have to say that if it were me, I wouldn't do that either. 但是我不得不说,如果是我,我也不会那样做。 I'd make my re-init script a sqlcmd script that looks something like: 我将重新初始化脚本设置为类似于以下内容的sqlcmd脚本:

:connect $(REPEATER_INSTANCE)
use [$(REPEATER_DB)];
declare arts cursor for
   select p.name as pub, a.name as art
   from sysarticles as a
   join syspublications as p
      on a.pubid = p.pubid;
open arts;
declare @p sysname, @a sysname;
while(1=1)
begin
   fetch next from arts into @p, @a
   if (@@fetch_status <> 0)
      break;
   exec sp_droparticle @publication = @p, @article @a;
end
close arts;
deallocate arts;

:connect $(PUBLISHER)
use [$(PUBLISHER_DB)];
--whatever script you use to create the publication here

Note: that's completely untested (I don't have replication set up at home), but should be pretty close. 注意:这是完全未经测试的(我没有在家中设置复制),但是应该非常接近。

Lastly (and rhetorically), why are you re-initializing so often? 最后,(为什么要这么频繁地)重新初始化? That should be a rare event. 那应该是罕见的事件。 If it's not, you may have a configuration issue (eg if you're constantly lagging behind so far that you exceed the distributor retention, increase the distributor retention). 如果不是,则可能是配置问题(例如,如果您一直落后于超出分配器的保留时间,请增加分配器的保留时间)。

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

相关问题 Sql Server 2008 事务复制和事务日志 - Sql Server 2008 Transactional Replication and the Transaction Log 使用远程分发器进行事务复制对SQL Server 2008的性能影响 - Performance impact on SQL server 2008 with transactional replication using remote distributor SQL Server 2008 事务复制-快照 .NET 错误 - SQL Server 2008 transactional replication-Snapshot .NET error SQL Server 2008事务复制&#39;缺少结束注释标记&#39;* /&#39; - SQL Server 2008 transactional replication 'Missing end comment mark '*/'' 如何配置SQL Server事务性Web同步/复制? - How to configure SQL Server transactional web synchronization/replication? 在订阅数据库上为SQL Server 2012事务复制启用非聚集索引的生成 - Enabling generation of non-clustered indexes on subscription database for SQL Server 2012 transactional replication 如何在不进行事务复制的情况下将数据从一台SQL服务器传输到另一台SQL服务器 - How to transfer Data from One SQL server to another with out transactional replication SQL Server 2005事务复制无法发布包含索引创建的存储过程 - SQL Server 2005 Transactional Replication Fails to Publish Stored Procedure Containing an Index Create Sql Server 复制或同步框架 - Sql Server Replication or SyncFramework SQL Server复制问题 - SQL Server replication question
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM