添加Distributor失败
上周做了一个case,客户无法为SQL Server instance配置remote distributor。 下面分享一下排查问题的过程,希望对您排查类似的问题所有帮助。
客户的环境中的SQL Server均为sql server 2012 RTM.
Distributor server: SQL108W2K8R22
Publisher: SQL108W2K8R21
Subscriber: SQL108W2K8R23
SQL108W2K8R23为SQL108W2K8R21的订阅服务器,模式为push.
现在要为SQL108W2K8R23创建发布,将SQL108W2K8R22添加为分发服务器时出错。
配置时会出现下面的错误:

Error 21670只是一般性的登录错误:Connection to server [%s] failed.没什么价值
于是尝试手工添加:exec sp_adddistributor @distributor = N'SQL108W2K8R22', @password = N'StrongPassword'
得到下面的错误:
Msg 18483, Level 14, State 1, Line 1
Could not connect to server 'SQL108W2K8R22' because 'distributor_admin' is not defined as a remote login at the server. Verify that you have specified the correct login name.
http://support.microsoft.com/kb/818334
按照KB上进行检查,发现这三台SQL SERVER的@@servername和hostname都是匹配的,这篇KB没有起到效果。
在distributor里找到了名称为SQL108W2K8R23的linked server,也可以在sys.servers查看到相应的记录
在distributor中的sys.link_logins中也包含distributor_admin相应的记录。
虽然 SQL108W2K8R23添加remote distributor失败,但仍然创建名为出[repl_distributor]的linked server。
于是在distributor和SQL108W2K8R23上同时抓取trace,看看添加remote distributor(sp_adddistributor)时究竟发生了什么。
在SQL108W2K8R23的trace中,发现SQL108W2K8R23通过linked server repl_distributor向distributor 提交一个查询,用于比对distributor 上SQL 版本。

EXEC @retcode = repl_distributor.master.sys.sp_executesql N'select @dist_ver = @@microsoftversion', N'@dist_ver bigint output', @dist_ver output
这个语句是添加distributor操作中的最后一个语句。

看起来linked server可以工作,成功地将语句发送到了target server(distributor),可能是linked server有些信息没有传递给distributor或者是distributor缺失了一些metadata。但检查了linked server的属性,没有发现异常。但如果是metadata丢失的话,那么删掉重建应该是不错的选择:

于是手工执行了一把,得到了同样的错误:
Msg 20584, Level 16, State 1, Procedure sp_MSrepl_check_server, Line 67
Cannot drop server 'SQL108W2K8R21' because it is used as a Subscriber to remote Publisher 'SQL108W2K8R23' in replication.
sys.sp_dropremotelogin @publisher,'distributor_admin','distributor_admin'
sys.sp_dropserver @publisher, 'droplogins'
sp_dropremotelogin的作用如下:
Removes a remote login mapped to a local login used to execute remote stored procedures against the local server running SQL Server
而sp_dropserver内部调用了sp_MSrepl_check_server,检查(distribution.dbo. MSsubscriber_info)将要删除的publisher是否同时也是一个订阅。如果是,就抛出异常,然后退出。
不幸的是,sp_dropremotelogin和sp_dropserver是单独执行的,并不在一个事务里。所以虽然最终执行失败,但sp_dropremotelogin造成的影响却没有回滚。
将distribution.dbo. MSsubscriber_info里的相关记录删除。
然后将publisher删除后重建,之后添加distributor的操作就成功了J
扩展:
1)
sp_dropremotelogin:Removes a remote login mapped to a local login used to execute remote stored procedures against the local server running SQL Server
sp_addremotelogin:Adds a new remote login ID on the local server. This enables remote servers to connect and execute remote procedure calls.
MSsubscriber_info :it contains one row for each Publisher/Subscriber pair that is being pushed subscriptions from the local Distributor. This table is stored in the distribution database.
这些存储过程和表都是sql server 2000时代的产物,用于linked server相关操作。在2005里就已经depreciated。
2)后来分析了内部的调用逻辑,实际上只需要在distributor执行sp_addremotelogin就可以解决这个问题,没有必要重建. 如果您以后遇到了下面这个错误,可以尝试在distributor中执行sp_addremotelogin。
Could not connect to server 'SQL108W2K8R22' because 'distributor_admin' is not defined as a remote login at the server. Verify that you have specified the correct login name.
3)如果在移除publisher时遇到下面的错误,可以将distribution.. MSsubscriber_info的相关记录删除,然后再次尝试。
Cannot
drop
server
'server1'
because
it
is
used
as
a
Subscriber
to
remote
Publisher
'serve2'
in
replication.
4)您在SQL SERVER 2014版本的distributor中不会遇到第三个问题,这并因为不是sp_addDistributor或sp_dropdistpublisher在2014中有了逻辑上变更,而是在添加订阅的时候,不会在向distribution.. MSsubscriber_info插入记录。这样sp_MSrepl_check_server就不会抛出异常了。
添加Distributor失败的更多相关文章
- SQL Server AlwaysOn添加监听器失败
标签:MSSQL/ 一.错误描述 1.群集服务未能使群集服务或应用程序“Alwayson22”完全联机或脱机.一个或多个资源可能处于失败状态.这可能会影响群集服务或应用程序的可用性 2.群集服务中的群 ...
- VS2010添加类失败问题,弹出错误框,提示 CodeModel操作失败,无法访问标记数据库
我在使用VS2010添加类的时候,会弹出一个错误框,提示 CodeModel操作失败,可以无法访问标记数据库 英文版是 CodeModel operation failed,Possibly cann ...
- response.addCookie(cookie)添加cookie失败.
两个if循环能进来,创建的两个cookie也能通过控制台输出. 但是却添加失败. 原因是:request.getRequestDispatcher("/MainFrame").f ...
- 【VMware vSphere】vCenter添加主机失败:无法访问指定主机
背景 前一段时间,给一台服务器安装ESXi系统,安装成功之后,通过vCenter在上面安装了一台VDP系统.结果前几天发现服务器掉线,重新连接时出现问题.问题描述如下: 其中错误堆栈具体内容为:在 v ...
- ubuntu 的 apt-get update 出现404错误时,或者添加ppa失败时,ubuntu 版本也 end of life 了的解决方案
xmodulo.com/how-to-fix-apt-get-update-error-on-ubuntu.html 如果是依赖没找到,可以用 sudo apt-get install -f 先补齐依 ...
- matlab添加toolbox失败的解决办法
matlab添加toolbox有三种方法: 1.在网上下载对应的文件,再复制到matlab安装路径中的toolbox文件夹里. 结果:失败.仍然显示不能用该模块. 2.由于笔者的学校有买正版,所以可以 ...
- 使用postman添加cookie失败和cookie消失问题
例如 groupId=2; path=/; domain=.www.baidu.com; HttpOnly; Expires=Tue, 16 Jul 2019 03:42:12 GMT; 添加失败和c ...
- nhibernate操作sql2008数据库(添加数据失败)
今天遇到一错误困了我一天,如此痛恨,遂记录于此: nhibernate框架+MVC模式搭的项目,添加数据时报错: "could not insert: [KXRMallManage.Mode ...
- discuz 添加板块失败解决办法
最近把服务器环境升了下级,发现discuz后台添加栏目添加不了了,数据库没变,源代码没变,就突然添加不了了.刚开始添加1个板块成功了,再添加就怎么也添不进去了.只是页面刷新了一下,啥提示没有. 经过一 ...
随机推荐
- 【代码笔记】iOS-点击任何处,出现城市
一,效果图. 二,工程目录. 三,代码. //点击任何处,出现城市 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { ...
- 关于学习YYKit的记录
<1>遇到的问题 <1>使用@[].mutableCopy创建可变数组 代码出处:YYKitDemo-> YYRootViewController 源代码:self.ti ...
- 转:无法向会话状态服务器发出会话状态请求请。确保 ASP.NET State Service (ASP.NET 状态服务)已启动
今天看到一篇文章感觉不错,收藏转载下. 原文地址:http://blog.csdn.net/sntyy/article/details/2090347 版权为原作者所有 无法向会话状态服务器发出会话状 ...
- AngularJS 简介
AngularJS 是一个 JavaScript 框架. 它可通过 <script> 标签添加到 HTML 页面. <script src="http://apps.bdi ...
- 在VC环境下执行代码出现错误
这是在执行代码过程中出现的错误,源代码在别的电脑上能运行,在自己的VC里运行就出现错误,在网上也搜过解决办法,但还是有点不太理解,是编程环境的问题h还是代码本身也存在问题???
- 一秒钟看懂SaaS、CRM、OA、ERP、HR、进销存
自2014年以来,SaaS.CRM.OA.ERP.HR.APM.进销存.财务系统等,这些名词大量出现在微信朋友圈.电视楼宇广告和千百万融资资讯中.它们到底是什么意思?相互之间又有什么区别?在这个飞速发 ...
- ORACLE数据库异步IO介绍
异步IO概念 Linux 异步 I/O (AIO)是 Linux 内核中提供的一个增强的功能.它是Linux 2.6 版本内核的一个标准特性,当然我们在2.4 版本内核的补丁中也可以找到它.AIO 背 ...
- R语言中的循环函数(Grouping Function)
R语言中有几个常用的函数,可以按组对数据进行处理,apply, lapply, sapply, tapply, mapply,等.这几个函数功能有些类似,下面介绍下这几个函数的用法. Apply 这是 ...
- MySQL出现Waiting for table metadata lock的原因以及解决方法
转自:http://ctripmysqldba.iteye.com/blog/1938150 (有修改) MySQL在进行alter table等DDL操作时,有时会出现Waiting for tab ...
- Hadoop环境常用命令
用户可以通过dfsadmin -safemode value 来操作安全模式,参数value的说明如下: enter - 进入安全模式 leave - 强制NameNode离开安全模式 get - ...