Replication--使用备份初始化订阅--请求订阅

1. 修改发布属性"许从备份文件初始化"置为TRUE

Replication--使用备份初始化订阅--请求订阅


脚本修改:
USE [DB01]
GO
DECLARE @publication AS sysname
SET @publication = N‘DB01_REP1‘
EXEC sp_changepublication
@publication = @publication,
@property = N‘allow_initialize_from_backup‘,
@value = true
2. 备份数据库并在订阅服务器上还原
3. 创建订阅
--===============================================================
--在发布服务器上运行
use [DB01]
exec sp_addsubscription
@publication = N‘DB01_REP1‘,
@subscriber = N‘SQLVM5‘,
@destination_db = N‘DB01‘,
@sync_type = N‘initialize with backup‘,
@subscription_type = N‘pull‘,--使用请求订阅
@backupdevicetype=‘disk‘,
@backupdevicename=‘F:\DB01_03.trn‘--最后一次备份的备份文件(发布服务器上的存放位置)
如果遇到如下提示:
消息 21397,级别 16,状态 1,过程 sp_MSaddautonosyncsubscription,第 279 行
对从指定备份创建的非同步订阅进行同步时需要一些事务,但这些事务在分发服务器上不可用。请使用更新的日志以及差异或完整数据库备份再试此操作。
对镜像服务器使用日志还原来同步数据
--===============================================================
--在订阅服务器上运行
use [DB01]
exec sp_addpullsubscription
@publisher = N‘SQLVM6‘,
@publication = N‘DB01_REP1‘,
@publisher_db = N‘DB01‘,
@independent_agent = N‘True‘,
@subscription_type = N‘pull‘,
@description = N‘‘,
@update_mode = N‘read only‘,
@immediate_sync = 0;
GO
exec sp_addpullsubscription_agent
@publisher = N‘SQLVM6‘,
@publisher_db = N‘DB01‘,
@publication = N‘DB01_REP1‘,
@distributor = N‘SQLVM6‘,
@distributor_security_mode = 0,
@distributor_login = N‘sa‘,
@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 = 20131028,
@active_end_date = 99991231,
@alt_snapshot_folder = N‘‘,
@working_directory = N‘‘,
@use_ftp = N‘False‘,
@job_login = null,
@job_password = null,
@publication_type = 0
GO
 
4.检查订阅状态和使用复制监视器来查看同步情况

Replication--使用备份初始化订阅--请求订阅

上一篇:反斜杠" \ "运用时出现错误:这是转义符,谁用谁倒霉


下一篇:lua入门