无法开始分布式事务

发布于 2024-12-05 17:59:42 字数 5374 浏览 3 评论 0原文

我尝试对链接服务器运行 SQL,但出现以下错误:

BEGIN DISTRIBUTED TRANSACTION
SELECT TOP 1 * FROM Sessions


OLE DB provider "SQLNCLI" for linked server "ASILIVE" returned message "No transaction is active.".

Msg 7391, Level 16, State 2, Line 3
The operation could not be performed because OLE DB provider "SQLNCLI" for linked server "ASILIVE" was unable to begin a distributed transaction.

提供程序返回两个错误:

错误 #1:

Number: $80040E14
Source: Microsoft OLE DB Provider for SQL Server
Description: OLE DB provider "SQLNCLI" for linked server "ASILIVE" returned message "No transaction is active.".
HelpFile: 
HelpContext: $00000000
SQLState: 01000
NativeError: 7412

错误 #2

Number: $80040E14
Source: Microsoft OLE DB Provider for SQL Server
Description: The operation could not be performed because OLE DB provider "SQLNCLI" for linked server "ASILIVE" was unable to begin a distributed transaction.
HelpFile: 
HelpContext: $00000000
SQLState: 42000
NativeError: 7391

如何我如何让微软更看重功能而不是安全?

或者,至少,我怎样才能让两个 SQL Server 相互通信?

相关问题


所做的无关紧要,但我会无论如何发布它。

  1. 确保分布式事务协调器服务在两台机器上运行:

    在此处输入图像描述

    在此处输入图像描述

  2. 禁用两台计算机上的所有 MSDTC 安全性:

    在此输入图像描述

    在此处输入图像描述

  3. 打开随机选项在链接的服务器:

在此处输入图像描述

  1. 诅咒并发誓。

  2. 砸碎东西。

  3. 检查 SELECT 是否可以使用链接服务器

     从 ASILive.CustomerManagementSystem.dbo.Users 中选择 *
        ....
    
        (受影响的 763 行)
    
  4. 检查客户端服务器是否可以 ping 远程服务器

     C:\Documents and Settings\avatar>ping asicmstest.contoso.com
    
         使用 32 字节数据 Ping asicmstest.contoso.com [10.0.0.40]:
    
         来自 10.0.0.40 的回复:字节=32 时间<1ms TTL=128
         来自 10.0.0.40 的回复:字节=32 时间<1ms TTL=128
         来自 10.0.0.40 的回复:字节=32 时间<1ms TTL=128
         来自 10.0.0.40 的回复:字节=32 时间<1ms TTL=128
    
         10.0.0.40 的 Ping 统计数据:
             数据包:发送 = 4,接收 = 4,丢失 = 0(0% 丢失),
         大约往返时间(以毫秒为单位):
             最小值 = 0ms,最大值 = 0ms,平均值 = 0ms
    
  5. 检查远程服务器是否可以按名称与发起服务器进行通信:

     C:\Documents and Settings\avatar>ping asitestserver.contoso.com
    
         使用 32 字节数据 Ping asitestserver.contoso.com [10.0.0.22]:
    
         10.0.0.22 回复:字节=32 时间<1ms TTL=128
         10.0.0.22 回复:字节=32 时间<1ms TTL=128
         10.0.0.22 回复:字节=32 时间<1ms TTL=128
         10.0.0.22 回复:字节=32 时间<1ms TTL=128
    
         10.0.0.22 的 Ping 统计数据:
             数据包:发送 = 4,接收 = 4,丢失 = 0(0% 丢失),
         大约往返时间(以毫秒为单位):
             最小值 = 0ms,最大值 = 0ms,平均值 = 0ms
    
  6. 检查@@SERVERNAME 与两台服务器上的服务器名称匹配

     SELECT @@SERVERNAME, SERVERPROPERTY('MachineName')
    
       ------------- -------------
       测试服务器 测试服务器
    

     SELECT @@SERVERNAME, SERVERPROPERTY('MachineName')
    
       ---------- ----------
       ASIGROBTEST ASIGROBTEST
    
  7. 尖叫

  8. 在发出查询之前发出SET XACT_ABORT ON:< /p>

    设置 XACT_ABORT ON
    去
    开始分布式交易
    从会话中选择前 1 个 *
    
  9. 授予每个人 完全控制

    HKEY_LOCAL_MACHINE\Software\Microsoft\MSSQLServer
    

    在两台服务器上。

I'm trying to run SQL against a linked server, but I get the errors below :

BEGIN DISTRIBUTED TRANSACTION
SELECT TOP 1 * FROM Sessions


OLE DB provider "SQLNCLI" for linked server "ASILIVE" returned message "No transaction is active.".

Msg 7391, Level 16, State 2, Line 3
The operation could not be performed because OLE DB provider "SQLNCLI" for linked server "ASILIVE" was unable to begin a distributed transaction.

There are two errors returned by the provider:

Error #1:

Number: $80040E14
Source: Microsoft OLE DB Provider for SQL Server
Description: OLE DB provider "SQLNCLI" for linked server "ASILIVE" returned message "No transaction is active.".
HelpFile: 
HelpContext: $00000000
SQLState: 01000
NativeError: 7412

Error #2

Number: $80040E14
Source: Microsoft OLE DB Provider for SQL Server
Description: The operation could not be performed because OLE DB provider "SQLNCLI" for linked server "ASILIVE" was unable to begin a distributed transaction.
HelpFile: 
HelpContext: $00000000
SQLState: 42000
NativeError: 7391

How do I get Microsoft to favor functionality over security?

Or, at least, how can I get two SQL Severs to talk to each other?

Related questions


What I have done is irrelevant, but I'll post it anyway.

  1. Ensure Distributed Transaction Coordinator service is running on both machies:

    enter image description here

    enter image description here

  2. Disable all MSDTC security on both machines:

    enter image description here

    enter image description here

  3. Turn on random options on the linked server:

enter image description here

  1. Cursed and swore.

  2. Smashed things.

  3. Checked that a SELECT can use the linked server:

        SELECT * FROM ASILive.CustomerManagementSystem.dbo.Users
        ....
    
        (763 row(s) affected)
    
  4. Checked that client server can ping the remote server:

         C:\Documents and Settings\avatar>ping asicmstest.contoso.com
    
         Pinging asicmstest.contoso.com [10.0.0.40] with 32 bytes of data:
    
         Reply from 10.0.0.40: bytes=32 time<1ms TTL=128
         Reply from 10.0.0.40: bytes=32 time<1ms TTL=128
         Reply from 10.0.0.40: bytes=32 time<1ms TTL=128
         Reply from 10.0.0.40: bytes=32 time<1ms TTL=128
    
         Ping statistics for 10.0.0.40:
             Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
         Approximate round trip times in milli-seconds:
             Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
  5. Checked that the remote server can commnicate back, by name, to the initiating server:

         C:\Documents and Settings\avatar>ping asitestserver.contoso.com
    
         Pinging asitestserver.contoso.com [10.0.0.22] with 32 bytes of data:
    
         Reply from 10.0.0.22: bytes=32 time<1ms TTL=128
         Reply from 10.0.0.22: bytes=32 time<1ms TTL=128
         Reply from 10.0.0.22: bytes=32 time<1ms TTL=128
         Reply from 10.0.0.22: bytes=32 time<1ms TTL=128
    
         Ping statistics for 10.0.0.22:
             Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
         Approximate round trip times in milli-seconds:
             Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
  6. Checked that @@SERVERNAME matches the server name on both servers:

       SELECT @@SERVERNAME, SERVERPROPERTY('MachineName')
    
       -------------  -------------
       ASITESTSERVER  ASITESTSERVER
    

    and

       SELECT @@SERVERNAME, SERVERPROPERTY('MachineName')
    
       ----------  ----------
       ASIGROBTEST  ASIGROBTEST
    
  7. Screamed

  8. Issued SET XACT_ABORT ON before issuing my query:

    SET XACT_ABORT ON
    GO
    BEGIN DISTRIBUTED TRANSACTION
    SELECT TOP 1 * FROM Sessions
    
  9. Granted Everyone Full Control to:

    HKEY_LOCAL_MACHINE\Software\Microsoft\MSSQLServer
    

    on both servers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

瑾兮 2024-12-12 17:59:42

发现了,远程服务器上的MSDTC是本地服务器的克隆。

从 Windows 应用程序事件日志:

事件类型:错误
事件来源:MSDTC
活动类别:CM
事件 ID:4101
日期:2011年9月19日
时间:下午 1:32:59
用户:不适用
计算机:ASITESTSERVER
说明:

本地 MS DTC 检测到
ASICMSTEST 上的 MS DTC 与本地 MS 具有相同的唯一标识
故障码。这意味着两个 MS DTC 将无法通信
与彼此。如果系统之一通常会出现此问题
使用不受支持的克隆工具进行克隆。 MS DTC 要求
使用受支持的克隆工具(例如 SYSPREP)来克隆系统。
从命令运行“msdtc -uninstall”,然后运行“msdtc -install”
提示将解决问题。注意:运行“msdtc -uninstall”将
导致系统丢失所有 MS DTC 配置信息。

有关详细信息,请参阅帮助和支持中心:
http://go.microsoft.com/fwlink/events.asp

运行

msdtc -uninstall
msdtc -install

然后停止并重新启动 SQL Server 服务修复了该问题。

Found it, MSDTC on the remote server was a clone of the local server.

From the Windows Application Events Log:

Event Type: Error
Event Source: MSDTC
Event Category: CM
Event ID: 4101
Date: 9/19/2011
Time: 1:32:59 PM
User: N/A
Computer: ASITESTSERVER
Description:

The local MS DTC detected that
the MS DTC on ASICMSTEST has the same unique identity as the local MS
DTC. This means that the two MS DTC will not be able to communicate
with each other. This problem typically occurs if one of the systems
were cloned using unsupported cloning tools. MS DTC requires that the
systems be cloned using supported cloning tools such as SYSPREP.
Running 'msdtc -uninstall' and then 'msdtc -install' from the command
prompt will fix the problem. Note: Running 'msdtc -uninstall' will
result in the system losing all MS DTC configuration information.

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.

Running

msdtc -uninstall
msdtc -install

and then stopping and restarting SQL Server service fixed it.

辞旧 2024-12-12 17:59:42

我能够通过禁用“启用 RPC 分布式事务升级”(即将其设置为 False)来解决此问题(正如其他人在评论中提到的那样):

在此处输入图像描述

根据要求@WonderWorker,您可以通过 SQL 脚本执行此操作:

EXEC master.dbo.sp_serveroption
     @server = N'[mylinkedserver]',
     @optname = N'remote proc transaction promotion',
     @optvalue = N'false'

I was able to resolve this issue (as others mentioned in comments) by disabling "Enable Promotion of Distributed Transactions for RPC" (i.e. setting it to False):

enter image description here

As requested by @WonderWorker, you can do this via SQL script:

EXEC master.dbo.sp_serveroption
     @server = N'[mylinkedserver]',
     @optname = N'remote proc transaction promotion',
     @optvalue = N'false'
墟烟 2024-12-12 17:59:42

好的,服务已启动,它们之间有一个以太网路径,名称解析工作,链接服务器工作,并且您禁用了事务身份验证。

我的直觉说防火墙有问题,但我想到了一些事情......

  1. 这些机器是否在同一个域中? (是的,禁用身份验证应该不重要)
  2. 计算机上是否运行防火墙? DTC 对于防火墙来说可能有点麻烦,因为它使用一系列端口,请参阅 http://support.microsoft .com/kb/306843 暂时,为了确定问题,我会禁用防火墙。DTC
  3. ping 说什么? http://www.microsoft.com/download/en/details.aspx ?id=2868
  4. SQL 服务以什么帐户运行?

OK, so services are started, there is an ethernet path between them, name resolution works, linked servers work, and you disabled transaction authentication.

My gut says firewall issue, but a few things come to mind...

  1. Are the machines in the same domain? (yeah, shouldn't matter with disabled authentication)
  2. Are firewalls running on the the machines? DTC can be a bit of pain for firewalls as it uses a range of ports, see http://support.microsoft.com/kb/306843 For the time being, I would disable firewalls for the sake of identifying the problem
  3. What does DTC ping say? http://www.microsoft.com/download/en/details.aspx?id=2868
  4. What account is the SQL Service running as ?
够钟 2024-12-12 17:59:42

对我来说,它与防火墙设置有关。转到您的防火墙设置,允许 DTC 服务并且它起作用了。在此处输入图像描述

For me, it relate to Firewall setting. Go to your firewall setting, allow DTC Service and it worked.enter image description here

罗罗贝儿 2024-12-12 17:59:42

如果服务器已集群并且存在集群 DTC,则必须禁用集群 DTC 而非本地 DTC 上的安全性。

If the servers are clustered and there is a clustered DTC you have to disable security on the clustered DTC not the local DTC.

森罗 2024-12-12 17:59:42

我上次使用 MSDTC 的经历和今天的这个错误结果证明是 DNS 问题。您询问机器是否位于同一域中是正确的,EBarr。顺便说一句,这个问题的清单很棒!

我的情况:我需要子域中的服务器能够通过防火墙针对父域中的服务器运行分布式事务。多年来我经常使用链接服务器,因此我在 SQL 中为链接服务器和 MSDTC 中设置了所有常用设置,Ian 在上面详细记录了这些设置。我为 MSDTC 设置了一系列 TCP 端口 (5000-5200) 以在两台服务器上使用,并在端口 1433 和 5000-5200 的盒子之间安排了一个防火墙漏洞。那应该有效。链接服务器测试正常,我可以通过链接服务器很好地查询远程 SQL 服务器,但我无法让它允许分布式事务。我什至可以看到来自 DEV 服务器的 QA 服务器上的连接,但有些东西没有返回。

我可以使用 FQDN 从 QA PING DEV 服务器,例如: PING DEVSQL.dev.domain.com

我无法仅使用计算机名称 PING DEV 服务器: PING DEVSQL

DEVSQL 服务器应该是两个域的成员,但是该名称未在父域的 DNS 中解析...父域中 DEVSQL 的计算机帐户发生了问题。一旦我们将 DEVSQL 添加到父域的 DNS,并且“PING DEVSQL”可以从远程 QA 服务器工作,这个问题就为我们解决了。

我希望这有帮助!

My last adventure with MSDTC and this error today turned out to be a DNS issue. You're on the right track asking if the machines are on the same domain, EBarr. Terrific list for this issue, by the way!

My situation: I needed a server in a child domain to be able to run distributed transactions against a server in the parent domain through a firewall. I've used linked servers quite a bit over the years, so I had all the usual settings in SQL for a linked server and in MSDTC that Ian documented so nicely above. I set up MSDTC with a range of TCP ports (5000-5200) to use on both servers, and arranged for a firewall hole between the boxes for ports 1433 and 5000-5200. That should have worked. The linked server tested OK and I could query the remote SQL server via the linked server nicely, but I couldn't get it to allow a distributed transaction. I could even see a connection on the QA server from the DEV server, but something wasn't making the trip back.

I could PING the DEV server from QA using a FQDN like: PING DEVSQL.dev.domain.com

I could not PING the DEV server with just the machine name: PING DEVSQL

The DEVSQL server was supposed to be a member of both domains, but the name wasn't resolving in the parent domain's DNS... something had happened to the machine account for DEVSQL in the parent domain. Once we added DEVSQL to the DNS for the parent domain, and "PING DEVSQL" worked from the remote QA server, this issue was resolved for us.

I hope this helps!

淡淡绿茶香 2024-12-12 17:59:42

如果您的目标服务器位于其他云或数据中心,则需要在源服务器中添加 MSDTC 服务(目标服务器) 的主机条目。

如果问题没有解决,请在启用 MSDTC 设置后尝试此操作。

If your Destination server is on another cloud or data-center then need to add host-entry of MSDTC service(Destination Server) in your source server.

Try this one if problem doesn't resolved, After enable the MSDTC settings.

情深如许 2024-12-12 17:59:42

除了安全设置之外,我还必须在两台服务器上打开一些端口才能运行事务。我必须打开端口 59640,但根据以下建议,端口 135 必须打开。
http://support.microsoft.com/kb/839279

Apart from the security settings, I had to open some ports on both servers for the transaction to run. I had to open port 59640 but according to the following suggestion, port 135 has to be open.
http://support.microsoft.com/kb/839279

甜`诱少女 2024-12-12 17:59:42

我遇到了同样的错误,我设法通过在源服务器上正确配置 MSDTC 以允许出站并允许 DTC 通过 Windows 防火墙来解决该问题。

允许分布式事务协调器,勾选域,私有和公共选项

I was getting the same error and i managed to solve it by configuring the MSDTC properly on the source server to allow outbound and allowed the DTC through the windows firewall.

Allow the Distributed Transaction Coordinator, tick domain , private and public options

你好,陌生人 2024-12-12 17:59:42

允许 DTC 勾选“私有”、“公共”以及“域”的防火墙设置就可以解决问题。仅域名是不够的(感觉应该是这样,但不是)。

The Firewall settings to Allow the DTC the ticking Private and Public as well as Domain did the trick. Just Domain is not enough (it feels like it should be, but nah).

黑寡妇 2024-12-12 17:59:42

昨天我遇到了类似的问题,所以我想我会分享我的经验和解决方案。

我们尝试使用链接服务器将行从源表插入到目标表,但收到错误“无法开始分布式事务”

在尝试了多种方法后,我们发现发现问题是我们直接在同义词中使用目标表名

我们最终在目标服务器中创建了一个插入行的存储过程,并从我们的源同义词中调用了该存储过程,一切顺利,希望它有帮助。

Yesterday i had a similiar issue so i thought i will share my experience and the solution.

We were trying to insert rows from source to a destination table using linked server, but we were getting the error "Unable to begin a distributed transaction"

After trying multiple things we found out that the problem was we were using the destination table name directly in the synonyms

We ended up creating a stored procedure in the destination server which inserts the row, and from our source synonyms we called the stored procedure and wollah everything worked out, Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文