一同事在測試伺服器(系統: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'選項。
- exec sp_configure 'show advanced options',1;
- go
- reconfigure;
- go
- exec sp_configure 'remote access',1;
- go
- reconfigure;
- go
- exec sp_configure 'remote admin connections',1;
- go
- reconfigure;
- go
- exec sp_configure 'remote proc trans',1 ;
- go
- reconfigure;
- go
配置DTC步驟
Step 1:Start(開始)-Control Panel(控制皮膚)-System and Security(系統和安全)- Administrative Tools(管理工具)-Component Services(元件服務)(或者Run->dcomcnfg 直接跳出元件服務)。
進入介面點選(Console Root->Componet Services->Computers->My Computer-> Local DTC)
Step 2: 右鍵單擊"Local DTC"的屬性,就可以看到“Tracing”、“Logging”、“Security”三個皮膚。關於設定屬性。可以點選下面的“Learn more about setting these properties”
如下所示,一般只用設定“Security”下的屬性,具體情況,根據實際情況配置,可以參考下面“本地DTC屬性頁:“安全選項”卡說明
注意:如果伺服器開啟了防火牆,那麼必須確保防火牆是否開放了135埠(即允許Distributed Transaction Coordinator程式通過防火牆)