Fanr

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
参考:
前提:
    准备一台电脑,主机名和以前的分发数据库一致。并且安装sql server
 
恢复步骤:
在新的distribution服务器上
1.配置distribution,增加之前的publisher
2.使用备份还原distribution数据库
3.创建job,主要是快照agent和logreadagent,可以从老的distribution直接复制
3.修改发布服务器属性
  EXEC sp_changedistpublisher  'TESTSYNCDBSERV', 'active', 'true' 
4.修改[MSpublisher_databases]中的publisher_id为publisher服务器在sys.servers中的server_id
UPDATE t  set t. publisher_id  = 2  from dbo.[MSpublisher_databases]  t WHERE id=2   
5.修改[MSpublications]中的publisher_id为publisher服务器在sys.servers中的server_id
UPDATE t set t. publisher_id  = 2 from dbo.MSpublications  t WHERE publication_id=2
6.修改[MSdistribution_agents]中的publisher_id为publisher服务器在sys.servers中的server_id,subscriber_id为订阅服务器在sys.servers中的server_id,如果没有订阅的可以直接创建。
 EXEC master.dbo.sp_addlinkedserver @server = N'TESTSYNCRPTSERV', @srvproduct=N'SQL Server'
 EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'TESTSYNCRPTSERV',@useself=N'True',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL
 update dbo.MSdistribution_agents SET publisher_id=2,subscriber_id=3 WHERE id = 4
7.修改[MSsubscriptions]中的publisher_id为publisher服务器在sys.servers中的server_id,subscriber_id为订阅服务器在sys.servers中的server_id,如果没有订阅的可以直接创建。
update dbo.MSsubscriptions  SET publisher_id =2,subscriber_id=3 WHERE publication_id=2
8.修改logreadagent,snapshotagent的publish_id和对应的job信息
 update [MSlogreader_agents]  SET publisher_id =2  WHERE id = 2
 update [MSsnapshot_agents]  SET publisher_id =2  WHERE id = 2
 update t
  set t.job_id = sj.job_id, t.job_step_uid = sjs.step_uid
 from dbo.MSlogreader_agents t
  left join dbo.MSreplication_monitordata   sm on sm.agent_name = t.name
  left join msdb.dbo.sysjobs sj  on sj.name = t.name
  left join msdb.dbo.sysjobsteps sjs on sj.job_id = sjs.job_id and sjs.step_id = 2
 update t
  set t.job_id = sj.job_id, t.job_step_uid = sjs.step_uid
 from dbo.[MSsnapshot_agents] t
  left join dbo.MSreplication_monitordata   sm on sm.agent_name = t.name
  left join msdb.dbo.sysjobs sj  on sj.name = t.name
  left join msdb.dbo.sysjobsteps sjs on sj.job_id = sjs.job_id and sjs.step_id = 2
 
在发布上运行
修改发布数据库中的syspublications,syssubscriptions中job的id
update [dbo].[syspublications] set snapshot_jobid=0xD2E257AFD287304CA2FC14F3D7C1AECF
update [dbo].[syssubscriptions] set distribution_jobid=0x0E79D3A2A36F73409DB3F4261723F37A

 

 
 
posted on 2018-09-21 13:23  Fanr_Zh  阅读(649)  评论(0编辑  收藏  举报