SQLServer Replication 常见错误
1. 错误:已将此(这些)订阅标记为不活动,必须将其重新初始化。需要删除NoSync 订阅,然后重新创建它们?????? use distributiongo -- 查找状态不正常的发布 select status, * from dbo.MSsubscriptions where status <> 2 -- 修改状态 update dbo.MSsubscriptions set status = 2 where status <> 2 ? 观察复制链是否能正常运行,正常后用tablediff比较发布链中的表数据是否一致 2. 错误:表、存储过程不存在以及表结构不一致等 ?? 有一种比较奇怪的现象是订阅端表明明存在,但是同步链依然报错,此时可能有两种情况:
select a.name as table_name,b.name as column_name,( select ' alter table ' + a.name + ' add ' + b.name + ' ' + ( case when name = ' nvarchar ' then cast (b.max_length / 2 AS varchar ) when name like ' date% ' or name = ' money ' then '' else name end ) from sys.types where system_type_id = b.system_type_id ) as definition FROM dbo.sysarticles a WITH (NOLOCK) inner join sys.columns b WITH (NOLOCK) on a.objid = b. object_id inner join dbo.syspublications c with (nolock) on a.pubid = c.pubid where c.name = ' Rp_XXXX ' and b.name = ' xxx ' 3. 错误:.主键冲突 错误完成后,需要比较两边数据是否一致(比下数据量就行了) -- -------------跳过订阅机器上面的错误------------------------ -- ---------------------在分发机器上-------------------------- -- 语法 sp_helpsubscriptionerrors [ @publisher = ] ' publisher ' , [ @publisher_db = ] ' publisher_db ' , [ @publication = ] ' publication ' , [ @subscriber = ] ' subscriber ' , [ @subscriber_db = ] ' subscriber_db ' -- get publisher subscriber select * from MSsubscriber_info -- get publisher_db publication subscriber_db=publisher_db select * from MSpublications -- example sp_helpsubscriptionerrors ' SQLw2k8 ' , ' dbtranpub ' , ' dbtranpub_pub ' , ' SQLw2k8Subscriber ' , ' dbtransub ' -- 获取xact_seqno 值 -- --------------------在订阅机器上--------------------------- sp_setsubscriptionxactseqno [ @publisher= ] ' publisher ' , [ @publisher_db= ] ' publisher_db ' , [ @publication= ] ' publication ' , [ @xact_seqno= ] xact_seqno -- example sp_helpsubscriptionerrors ' SQLw2k8 ' ,xact_seqno -- ----------------------------------------------------------------------------------- 4. 错误:应用复制的命令时在订阅服务器上找不到该行 ?? a. 可以采用“主键冲突”错误的处理方式,跳过错误,然后再用tablediff比较两个表的数据差; select top 100 e.xact_seqno,e.command_id,e. * from dbo.MSdistribution_history h join dbo.MSrepl_errors e on h.error_id = e.id where comments not like ' %transaction% ' -- 失败的代理 order by id desc -- 用上面查到的具体事务序列号,查看复制组件执行的具体命令 -- 在分发数据库上执行:sp_browsereplcmds,注意必须限定开始和结束xact_seqno sp_browsereplcmds ' 0x0000003B00000020000500000000 ' , ' 0x0000003B00000020000500000000 ' -- 结果如下 article_id command 1 {CALL [ dbo ] . [ sp_MSdel_dboUPCCodeTransaction ] ( ' 000000002 ' )} -- 找到对应的对象 select publisher_db,article From dbo.MSarticles where article_id = 1 and publication_id = ( select publication_id from MSpublications with (nolock) where publication = ' Rp_xxx ' ) -- 由sp_MSdel 可以知道,这条命令是一个删除语句,因为发布端的数据已经不存在,所以只能跳过; -- 如果是修改,需要验证上述数据在故障订阅服务器上是否存在,如果不存在,则补上。 5. 错误:用户'xxx' 登录失败或者The process could not connect to Subscriber 'xxxx'. 6. 发布'xxx' 的初始快照尚不可用 7. 进程未能从表“[dbo].[syncobj_0x3745373834413345]”向外大容量复制 8. 错误消息: ? 发生这个错误一般都是在一台机器上面有比较多的发布链,错误原因在于数据库对Replication使用内存的限制, ? HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerSubSystems ? Windows2008 server 如果不是amdin用户可能会不让打开注册表,如果是管理组权限的话,可以到 9.--Cannot drop the database XXX because it is being used for replication ? exec sp_removedbreplication 'database' (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |