暂时禁用 Sql 复制

swa*_*eck 7 replication sql-server

由于业务需要,我可能需要在我的环境中禁用事务复制(Sql 2k -> Sql 2008)。从功能上讲,我理解这意味着我需要放弃订阅和文章。当冲突需求得到解决时,获取创建脚本是否足以将复制恢复到原始状态?

谢谢。

Cra*_*ein 9

我使用 SQL Server 2000 (MS2000) 作为发布者和 SQL Server 2008 (MS2008) 作为订阅者测试了这个例子。在发布者上,一个名为 arp 的数据库有多个表,但只有表 users 作为文章包含在发布中。此示例从两台服务器中删除订阅,然后将其重新放回。

在订户 MS2008 上

从 MS2008 中删除现有订阅

USE arp
GO

EXEC sp_droppullsubscription @publisher='MS2000', @publisher_db='arp', @publication='arp_pub'
Run Code Online (Sandbox Code Playgroud)

在出版商 MS2000 上

取消订阅

-- dropped subscription
exec sp_dropsubscription @publication = N'Arp_pub', @subscriber = N'MS2008', @destination_db = N'arp', @article = N'all'
Run Code Online (Sandbox Code Playgroud)

删除了订阅者

-- On MS2000, dropped subscriber from MS2008 after removing it from MS2008
exec sp_dropsubscriber @subscriber = N'MS2008'
Run Code Online (Sandbox Code Playgroud)

稍后,我重新创建订阅。

在发布服务器上,MS2000

添加回订阅者

use [master]
exec sp_addsubscriber @subscriber = N'MS2008', @type = 0, @description = null, @security_mode = 1, @frequency_type = 64, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 4, @frequency_subday_interval = 5, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 99991231

exec sp_changesubscriber_schedule @agent_type = 1, @subscriber = N'MS2008', @frequency_type = 4, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 8, @frequency_subday_interval = 1, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 99991231
GO
Run Code Online (Sandbox Code Playgroud)

添加回订阅

use [Arp]
exec sp_addsubscription @publication = N'Arp_pub', @subscriber = N'MS2008', @destination_db = N'arp', @sync_type = N'Automatic', @subscription_type = N'pull', @update_mode = N'read only'
GO
Run Code Online (Sandbox Code Playgroud)

在订户 MS2008 上

创建数据库

CREATE DATABASE arp;
GO
Run Code Online (Sandbox Code Playgroud)

添加拉订阅

use [arp]
exec sp_addpullsubscription @publisher = N'MS2000', @publication = N'Arp_pub', @publisher_db = N'Arp', @independent_agent = N'False', @subscription_type = N'pull', @description = N'', @update_mode = N'read only', @immediate_sync = 0
Run Code Online (Sandbox Code Playgroud)

添加代理

@job_login 是对默认快照文件夹具有权限的 ntlm 用户。该用户还可以访问发布者上的出版物

快照文件夹是发布者和订阅者均可访问的共享文件夹。

exec sp_addpullsubscription_agent @publisher = N'MS2000', @publisher_db = N'Arp', @publication = N'Arp_pub', @distributor = N'MS2000', @distributor_security_mode = 1, @distributor_login = N'', @distributor_password = null, @enabled_for_syncmgr = N'False', @frequency_type = 64, @frequency_interval = 0, @frequency_relative_interval = 0, @frequency_recurrence_factor = 0, @frequency_subday = 0, @frequency_subday_interval = 0, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 20120214, @active_end_date = 99991231, @alt_snapshot_folder = N'', @working_directory = N'', @use_ftp = N'False', @job_login = N'MS2008\replication_user', @job_password = 'test123', @publication_type = 0
GO
Run Code Online (Sandbox Code Playgroud)

在发布者 MS2000 上,我运行了快照作业

复制的表在 MS2008 上再次可见。