我有4个数据库、一个发布服务器和3个订阅服务器(事务性复制)。
如果发布服务器出现错误,我想:
(这样程序就可以正常运行,三个数据库也能继续更新)
我有创建新发布和创建新订阅服务器的代码,但我不知道如何删除旧订阅。
我读过这个这里:
在发布数据库的发布服务器上,执行sp_dropsubscription (Transact-SQL)。指定“发布”和“订阅服务器”。指定“项目”的all值。(可选)如果分发服务器无法访问,请为@ignore_distributor指定值1,以便在不删除分发服务器上的相关对象的情况下删除订阅。在订阅数据库的订阅服务器上,执行sp_subscription_cleanup (Transact-SQL)以删除订阅数据库中的复制元数据。
但就我而言,出版商和发行商都在同一台机器上。(因此我无法立即执行sp_dropsubsription,因为发行者机器已经关闭)
编辑:我已经完成了sp_subscription_cleanup @publisher='PCONE', @publisher_db='TEST'
(在其中一个订阅服务器中),但是订阅仍然在本地订阅文件夹中
因此,这并不妨碍老出版商在恢复生活时发送数据。
我怎么才能防止这种情况?(如何以编程方式执行等效于右键单击订阅并选择delete的操作)
发布于 2011-12-02 20:50:45
如果你在找大锤子,服务提供商_摘除术就是它。这应该执行您所要求的操作,并删除订阅数据库中的所有与复制相关的功能,而不管发布服务器是否可访问。一旦发布服务器/分发服务器恢复,您也可以进行清理以删除该侧的订阅。
就像我说的,这是大锤子,所以要小心使用。
发布于 2011-11-28 11:25:07
由于它是推送数据的发布服务器,因此删除订阅将在发布服务器上完成。下面是我使用的脚本(取自Wrox)。我首先在第1部分中找到要删除的订阅,然后使用该信息删除订阅。这个脚本不是一次全部运行的。
**/* Part I on the publisher/distribution server */**
use distribution
go
/* Declare a table variable */
declare @subscription_push table
(
publisher_id smallint,
publisher_db sysname,
subscriber_db sysname,
subscription_int int,
sync_type tinyint,
status tinyint
);
insert into @subscription_push
select publisher_id, publisher_db, subscriber_db, subscription_type, sync_type, status
from distribution..MSsubscriptions
where subscription_type = 1 and status = 2
/* check the data */
select * from @subscription_push
/* Declare table variable that will store the publisher, the publication database, the type of publication and the name of the publication using
sp_helpsubscription */
declare @subscriberinfo table
(publisher sysname,
subscriber sysname);
insert into @subscriberinfo
select publisher, subscriber from distribution..MSsubscriber_info
/* check the data */
select * from @subscriberinfo
**/* Part II */**
/* Then remove the subscription from the publisher based on the information in the table @subscriberinfo*/
exec sp_dropsubscription @publication='publication_name', @article='article or all for all articles', @subscriber='subscribername', @destination_db='TEST'
go
希望这能有所帮助。我已经在测试环境中使用过好几次了。也许有人有更好的方法来删除推送订阅?
发布于 2014-12-12 16:56:37
我偶然发现这个旧的帖子是在寻找同样的答案。有一个更容易的方法,而不是鱼雷所有的复制。运行sp_dropsubscription
之后,必须在订阅服务器上运行清理存储过程。所以,在运行这个之后:
USE PublisherDB
GO
exec sp_dropsubscription
@publication = N'MyPublication',
@subscriber = N'SubscriberServer',
@destination_db = N'SubscriptionDatabase',
@article = N'all';
您需要运行以下操作:
USE SubscriberDB
GO
exec sp_subscription_cleanup
@publisher = N'PublisherServer',
@publisher_db = N'PublisherDB',
@publication = N'MyPublication';
我希望这能帮到别人。这将从订阅服务器中删除任何元数据。在运行清理之前,订阅将显示在本地订阅中。
https://dba.stackexchange.com/questions/8191
复制相似问题