欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

distribution 分发数据库 灾难恢复 备份恢复

程序员文章站 2023-11-14 11:11:10
参考: http://www.sqlservercentral.com/articles/Replication/117265/ 前提: 准备一台电脑,主机名和以前的分发数据库一致。并且安装sql server 恢复步骤: 在新的distribution服务器上 1.配置distribution,增 ......
参考:
http://www.sqlservercentral.com/articles/replication/117265/
前提:
    准备一台电脑,主机名和以前的分发数据库一致。并且安装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