[英]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.