SQL Server 2008 复制 遇到: 进程无法执行 ‘sp_replcmds’ 命令
故障描述
当我解决故障时遇到一个SQL
复制问题。 我正在做的是从生产备份中恢复两个DB,然后在它们之间安装复制。 复制似乎没有任何错误配置,但是当我查看复制监视器中的状态时,我看到如下错误消息:
Error messages:
The process could not execute 'sp_replcmds' on 'MYSERVER1'. Get help: http://help/MSSQL_REPL20011
Cannot execute as the database principal because the principal "dbo" does not exist, this type of principal cannot be impersonated, or you do not have permission. (Source: MSSQLServer, Error number: 15517) Get help: http://help/15517
The process could not execute 'sp_replcmds' on 'MYSERVER1'. Get help: http://help/MSSQL_REPL22037
问题排查
遇到此问题时,可能是由于数据库没有正确设置所有者。
运行以下语句,观察每个数据库是否都有所有者
select name, suser_sname(owner_sid)from sys.databases;
如果DB
所有者为NULL
。 则需要将“dbo”
更改为有效登录。
更改方式1
在数据库上运行:
ALTER AUTHORIZATION ON DATABASE::[<dbname>] TO [sa]
例如
alter authorization on database::[test2] to [node3\administrator]
更改方式2
USE [<dbname>]
GO
sp_changedbowner 'sa'
更改方式3
右键单击了数据库->属性 ,并在“常规”选项卡中验证了所有者设置正确。 但是,在“文件”选项卡中,未设置所有者。
一旦设置好数据库拥有者,复制运行没有问题。
参考资料
SQL Server 2008 replication failing with: process could not execute ‘sp_replcmds’