事物复制的一些错误

1

Replication-replication distribution subsystem agent null failed. the publication XXX does not exist

从字面上可以看到,当前订阅的发布已经不存在了,而相应的分发代理却因为某些原因没有被删除,继续运行,就会出现这种错误。

这个错误可以在distributor的错误日志中,或者MSrepl_errors表中看到.

A1 如何解决:在distributor服务器中的分发数据库中执行如下语句

select publisher,subscriber From MSsubscriber_info

上面的查询列出“发布”与"订阅”的对照关系,但实际上对我们排错并没有什么作用,因为此时订阅的信息很可能已经从Mssubscriber_info中删除了,你无法的找到到底是哪些’subscriber’在进行这种无效的请求.我们能做的也只有凭借记忆找出到底那些可能的订阅者了…

找到可能的订阅,检查其对应的job的隶属记录:

clip_image002

就可以将对应的订阅删除了

2

pull模式下,在复制监视器中看到大量的”为分发的命令”,检查distribution agent对应的作业,查看其历史记录,发现如下错误:

Agent message code 20084. The process could not connect to Distributor 'XXXXX'.

在distributor的errorlog找到distribution agent帐号登录失败的信息。

解决方法 为distribution agent帐号在distirbutor创建登录

 

3

2011-04-03 17:37:05.853 Connecting to Distributor ‘XXX’
The remote server "%s" does not exist, or has not been designated as a valid Publisher, or you may not have permission to see available Publishers.

解决方法:可能是publisher已经无法连接,或者缺少权限。确定distribution agent帐号是否属于PAL,如果不是则添加

exec sp_help_publication_access @publication = N'publicationName'

会列出PAL的成员

 

4

在push模式下,分发代理出现如下错误:

Agent message code 14260. You do not have sufficient permission to run this command. Contact your system administrator

检查是否符合如下条件:

Distribution Agent for a push subscription

The Windows account under which the agent runs is used when it makes connections to the Distributor. This account must:

· At minimum be a member of the db_owner fixed database role in the distribution database.

· Be a member of the PAL.

· Have read permissions on the snapshot share.

· Have read permissions on the installation directory of the OLE DB provider for the Subscriber if the subscription is for a non-SQL Server Subscriber.

The account that is used to connect to the Subscriber must at minimum be a member of the db_owner fixed database role in the subscription database, or have equivalent permissions if the subscription is for a non-SQL Server Subscriber.

 

5

查看复制监视器/dbo.MSrepl_errors

遇到如下错误:

尝试的命令:

if @@trancount > 0 rollback tran
(事务序列号: 0x0000003A000001DB006800000000,命令 ID: 3)

错误消息:

· 应用复制的命令时在订阅服务器上找不到该行。 (源: MSSQLServer,错误号: 20598)
获取帮助: http://help/20598

· 应用复制的命令时在订阅服务器上找不到该行。 (源: MSSQLServer,错误号: 20598)
获取帮助: http://help/20598

出现这种错误的原始可能是:订阅服务器中的一个数据行A被(误)删除了,而发布服务器要修改/删除A这条记录,顺利删除后要将结果更新到订阅,此时订阅服务器中A已经不存在了…

可以在distributor上执行如下语句,获得具体错误信息

sp_browsereplcmds '0x0000003A000001DB006800000000','0x0000003A000001DB006800000000'

从上面的截图可以看出,一个删除100行数据的语句在发布库执行,  将相应的信息传递到分发后,分发库调用100次sp_MSdel_dbotx来完成数据的同步. 从之前的错误信息进一步看到,其中的第三条语句执行时到了问题:

 分发代理在执行sp_MSdel_dbotx这条语句后出现了上述的错误。Sp_Msdel_dbotx这个存储过程的定义是在将对象添加到发布是定义的。默认的命名规则是sp_MS+operation+schemaName+tableName

可以通过下面这个查询定位到具体表

Use [distribution] 

select *From MSarticles where article_id=@article_id 

 

具体的定义可以在subscriber的订阅库中查看

use [subDBName] 
exec sp_helptext [sp_MSdel_dbota] 

解决方式是将删除的行在订阅中重新插入,主键就是sp_MSdel_dbota里的参数。

6

Cannot drop the database XXX because it is being used for replication

exec sp_removedbreplication 'database'

原文地址:https://www.cnblogs.com/stswordman/p/2011738.html