使用 MSDTC 的链接服务器错误
我正在显示一个通过 Internet 在两个系统之间使用“链接服务器”进行数据事务的存储过程的示例
Alter Proc [dbo].[usp_Select_TransferingDatasFromServerCheckingforExample]
@RserverName varchar(100), ----- Server Name
@RUserid Varchar(100), ----- server user id
@RPass Varchar(100), ----- Server Password
@DbName varchar(100) ----- Server database
As
Set nocount on
Set Xact_abort on
Declare @user varchar(100)
Declare @userID varchar(100)
Declare @Db Varchar(100)
Declare @Lserver varchar(100)
Select @Lserver = @@servername
Select @userID = suser_name()
select @User=user
Exec('if exists(Select 1 From [Master].[' + @user + '].[sysservers] where srvname = ''' + @RserverName + ''') begin Exec sp_droplinkedsrvlogin ''' + @RserverName + ''',''' + @userID + ''' exec sp_dropserver ''' + @RserverName + ''' end ')
set @RserverName='['+@RserverName+']'
declare @ColumnList varchar(max)
set @ColumnList = null
select @ColumnList = case when @ColumnList is not null then @ColumnList + ',' + quotename(name) else quotename(name) end from syscolumns where id = object_id('bditm') order by colid
set identity_insert Bditm on
exec ('Insert Into Bditm ('+ @ColumnList +') Select * From '+ @RserverName + '.'+ @DbName + '.'+ @user + '.Bditm')
set identity_insert Bditm off
set @RserverName=replace(replace(@RserverName,'[',''),']','')
Exec sp_droplinkedsrvlogin @RserverName,@userID
Exec sp_dropserver @RserverName
当我运行存储过程时 I 在不同的执行时间中出现不同的错误
有时显示此错误
"The operation could not be performed because OLE DB provider "SQLNCLI" for linked server "ServerName" was unable to begin a distributed transaction."
另一次显示此类错误
OLE DB provider "SQLNCLI" for linked server "70.38.11.49" returned message "Protocol error in TDS stream".
OLE DB provider "SQLNCLI" for linked server "70.38.11.49" returned message "Communication link failure".
Msg 65535, Level 16, State 1, Line 0
Session Provider: Physical connection is not usable [xFFFFFFFF].
OLE DB provider "SQLNCLI" for linked server "70.38.11.49" returned message "Communication link failure".
Msg 65535, Level 16, State 1, Line 0
Session Provider: Physical connection is not usable [xFFFFFFFF].
OLE DB provider "SQLNCLI" for linked server "70.38.11.49" returned message "Communication link failure".
Msg 10054, Level 16, State 1, Line 0
TCP Provider: An existing connection was forcibly closed by the remote host.
I我在客户端使用 Windows Xp 和 SQL Server 2005 在 Net Server 中使用 Windows Server 2003 和 Sql server 2005
我在两个系统中设置 MSDTC
我如何解决此问题(并提供在 Windows XP 中设置 MSDTC 的正确信息和 Windows Server 2003)
I am Showing An example of Stored Procedure For Data Transaction using "Linked Server" Between Two System Through Internet
Alter Proc [dbo].[usp_Select_TransferingDatasFromServerCheckingforExample]
@RserverName varchar(100), ----- Server Name
@RUserid Varchar(100), ----- server user id
@RPass Varchar(100), ----- Server Password
@DbName varchar(100) ----- Server database
As
Set nocount on
Set Xact_abort on
Declare @user varchar(100)
Declare @userID varchar(100)
Declare @Db Varchar(100)
Declare @Lserver varchar(100)
Select @Lserver = @@servername
Select @userID = suser_name()
select @User=user
Exec('if exists(Select 1 From [Master].[' + @user + '].[sysservers] where srvname = ''' + @RserverName + ''') begin Exec sp_droplinkedsrvlogin ''' + @RserverName + ''',''' + @userID + ''' exec sp_dropserver ''' + @RserverName + ''' end ')
set @RserverName='['+@RserverName+']'
declare @ColumnList varchar(max)
set @ColumnList = null
select @ColumnList = case when @ColumnList is not null then @ColumnList + ',' + quotename(name) else quotename(name) end from syscolumns where id = object_id('bditm') order by colid
set identity_insert Bditm on
exec ('Insert Into Bditm ('+ @ColumnList +') Select * From '+ @RserverName + '.'+ @DbName + '.'+ @user + '.Bditm')
set identity_insert Bditm off
set @RserverName=replace(replace(@RserverName,'[',''),']','')
Exec sp_droplinkedsrvlogin @RserverName,@userID
Exec sp_dropserver @RserverName
When i Running the Stored Procedure I Getting the different errors in different Time of Execution
Some time Shows this Error
"The operation could not be performed because OLE DB provider "SQLNCLI" for linked server "ServerName" was unable to begin a distributed transaction."
Another time Shows This Type of Error
OLE DB provider "SQLNCLI" for linked server "70.38.11.49" returned message "Protocol error in TDS stream".
OLE DB provider "SQLNCLI" for linked server "70.38.11.49" returned message "Communication link failure".
Msg 65535, Level 16, State 1, Line 0
Session Provider: Physical connection is not usable [xFFFFFFFF].
OLE DB provider "SQLNCLI" for linked server "70.38.11.49" returned message "Communication link failure".
Msg 65535, Level 16, State 1, Line 0
Session Provider: Physical connection is not usable [xFFFFFFFF].
OLE DB provider "SQLNCLI" for linked server "70.38.11.49" returned message "Communication link failure".
Msg 10054, Level 16, State 1, Line 0
TCP Provider: An existing connection was forcibly closed by the remote host.
I am Using the Windows Xp And SQL Server 2005 in Client side And Windows server 2003 and Sql server 2005 In Net Server
I Set the MSDTC in Both System
How Can i Solve This Problem (And also give the Correct Information For Setting The MSDTC in Windows XP And Windows server 2003)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我可以确认这是网络连接问题。 我以前见过这个。
MSDTC 代理必须能够连接到它们正在协调的所有数据库实例。
有一些 MS 认证的程序来测试这个... google for msdtc ping。
I can confirm it's a network connectivity issue. I have seen this before.
MSDTC agents must be able to connect to all database instances they are coordinating.
There was some MS-certified proceure for testing this... google for msdtc ping.
您还必须检查 IP 网络配置中的 DNS 名称解析。
例如,您有一台名为 server-a.mydomain.com 的服务器,另一台名为 server-b.otherdomain.com,请登录 server-a 并执行ping server-b(不带域)。
如果它响应“Ping 请求无法找到主机服务器-b。请检查名称并重试。”,这就是问题所在。
转到控制面板> 网络连接> 右键单击网卡> 属性> 互联网协议> 属性> 高级> DNS> 按顺序附加此 DNS 后缀。 在这里添加本地域: mydomain.com ,然后添加远程域: otherdomain.com 。 单击“确定”直至退出
现在,如果您ping server-b,它应该返回如下内容:
使用 32 字节数据 Pinging server-b.otherdomain.com [192.168.1.2]:
192.168.1.2 回复:字节=32 时间=12ms TTL=64
来自 192.168.1.2 的回复: bytes=32 time=9ms TTL=64
现在再次尝试执行分布式事务。
You also have to check the DNS name resolution in the IP network configuration.
For example, you have a server called server-a.mydomain.com and another one called server-b.otherdomain.com, log in the server-a and do a ping server-b (without the domain).
If it responds "Ping request could not find host server-b. Please check the name and try again." that is the problem.
Go to the Control Pannel > Network Connections > Right click in the network card > properties > Internet Protocol > Properties > Advanced > DNS > Append this DNS suffix in order. And here add the local domain: mydomain.com and then add the remote domain: otherdomain.com . Click OK until you exit
Now if you do the ping server-b it should repond something like:
Pinging server-b.otherdomain.com [192.168.1.2] with 32 bytes of data:
Reply from 192.168.1.2: bytes=32 time=12ms TTL=64
Reply from 192.168.1.2: bytes=32 time=9ms TTL=64
Now try to again to execute the distributed transaction.
可能性很大,但不久前我在 MSSQL Server 7 上遇到了类似的问题。事实证明,两个系统都需要通过 NetBios 名称相互联系,并且因为它们不是域的一部分(但正在通信)通过 WAN,就像您的情况一样)。
一个简单的解决方案(至少要检查是否是这种情况)是编辑 lmhosts 文件以映射每个计算机的名称及其 IP 地址(在客户端和服务器中)。
看到我当时发的一个有点混乱的帖子:
http://groups.google.com/group/ microsoft.public.sqlserver.server/browse_thread/thread/2c246bd2afc7c4d9
A long shot, but i've encountered a similiar problem a while back, on MSSQL Server 7. It turned out that both system were required to contact each other by NetBios names, and since they were not part of a Domain (but were communicating over the WAN like in your case).
A simple solution, at least to check if this is the case, would be to edit lmhosts file to map the computer name of each one its IP address (both in the client and server).
See a somewhat confused post i made back then:
http://groups.google.com/group/microsoft.public.sqlserver.server/browse_thread/thread/2c246bd2afc7c4d9
我同意上面的帖子,这可能是一个协议问题,但它可能需要使用命名管道作为接口。
或者,运行 DTC 服务的用户帐户可能仅具有本地权限,而没有网络权限。 使用在两台计算机上具有足够权限的域帐户来运行 DTC。
或者您可能需要在流程前端使用 BEGIN DISTRIBUTED TRANSACTION 启动分布式事务。
I agree with the above posting that it might be a protocol issue but it might need to use Named Pipes as the interface.
Or it could be that the user account that the DTC service is runnning under only has local rights and no rights on the network. Use a domain account with sufficient rights on both machines to run DTC under.
Or it could be that you need to start a distributed transaction with BEGIN DISTRIBUTED TRANSACTION at the front-end of your process.
您可能需要查看:
http://support.microsoft.com/kb/306212
和
http://support.microsoft.com/kb/937517
you might want to look at:
http://support.microsoft.com/kb/306212
and
http://support.microsoft.com/kb/937517