一同事在测试服务器(系统:windows 2008 r2 standard 数据库:sql server 2008 r2)通过链接服务器test使用分布式事务测试时出错,出错信息如下:
set xact_abort on
begin tran
update test.mydb.dbo.test_one set name='test' where id= 3 ;
commit
ole
db provider "sqlncli10" for linked server "test" returned message "the
transaction manager has disabled its support for remote/network
transactions.".
消息 7391,级别 16,状态 2,第 5 行
the
operation could not be performed because ole db provider "sqlncli10"
for linked server "test" was unable to begin a distributed transaction.
出现这个错误时因为这台服务器,或者链接服务器那台服务器没有配置好ms dtc(microsoft distributed transaction coordinator 微软 分布式事务协调器)。
首先确保开启了 'remote access'、 'remote admin connections'、 'remote proc trans'选项。
code snippet
exec sp_configure 'show advanced options',1;
go
reconfigure;
exec sp_configure 'remote access',1;
exec sp_configure 'remote admin connections',1;
exec sp_configure 'remote proc trans',1 ;
配置dtc步骤
step 1:start(开
始)-control panel(控制面板)-system and security(系统和安全)- administrative
tools(管理工具)-component services(组件服务)(或者run->dcomcnfg 直接跳出组件服务)。
进入界面点击(console root->componet services->computers->my computer-> local dtc)
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnL2YDN5cjN0MTM4MTMxUDMvw1MwQTMwIzLcJDN1MzNvw1ZvxmYvwVbvNmLn9GbiRXauNmLzV2Zh1Wavw1LcpDc0RHaiojIsJye.png)
step 2: 右键单击"local dtc"的属性,就可以看到“tracing”、“logging”、“security”三个面板。关于设置属性。可以点击下面的“learn more about setting these properties”
如下所示,一般只用设置“security”下的属性,具体情况,根据实际情况配置,可以参考下面“本地dtc属性页:“安全选项”卡说明
注意:如果服务器开启了防火墙,那么必须确保防火墙是否开放了135端口(即允许distributed transaction coordinator程序通过防火墙)