如何在 SQL Server 上启用 MSDTC?

发布于 2024-07-05 02:16:21 字数 784 浏览 7 评论 0原文

这甚至是一个有效的问题吗? 我有一个使用 MSTDC 的 .NET Windows 应用程序,它抛出异常:

System.Transactions.TransactionManagerCommunicationException:分布式事务管理器 (MSDTC) 的网络访问已被禁用。 请启用 DTC 使用组件服务管理工具在 MSDTC 的安全配置中进行网络访问 ---> System.Runtime.InteropServices.COMException(0x8004D024):事务管理器已禁用其对远程/网络的支持 交易。 (HRESULT 异常:0x8004D024)位于 System.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction(UInt32) propgationTokenSize、Byte[] propgationToken、IntPtr 托管标识符、 指导& transactionIdentifier、OletxTransactionIsolationLevel& 隔离级别、ITransactionShim& 交易垫片)....

我按照 Kbalertz 指南在 PC 上启用 MSDTC安装了该应用程序,但仍然出现错误。

我想知道这是数据库问题吗? 如果是这样,我该如何解决?

Is this even a valid question? I have a .NET Windows app that is using MSTDC and it is throwing an exception:

System.Transactions.TransactionManagerCommunicationException: Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for
network access in the security configuration for MSDTC using the Component Services Administrative tool ---> System.Runtime.InteropServices.COMException (0x8004D024): The transaction manager has disabled its support for remote/network
transactions. (Exception from HRESULT: 0x8004D024) at System.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction(UInt32
propgationTokenSize, Byte[] propgationToken, IntPtr managedIdentifier,
Guid& transactionIdentifier, OletxTransactionIsolationLevel&
isolationLevel, ITransactionShim& transactionShim)....

I followed the Kbalertz guide to enable MSDTC on the PC on which the app is installed, but the error still occurs.

I was wondering if this was a database issue? If so, how can I resolve it?

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

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

发布评论

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

评论(7

堇色安年 2024-07-12 02:16:21

@担,

我不需要启用msdtc吗
交易能发挥作用吗?

仅分布式事务 - 涉及多个连接的事务。 请双重确保您只在事务中打开一个连接,并且它不会升级 - 性能也会好得多。

@Dan,

Do I not need msdtc enabled for
transactions to work?

Only distributed transactions - Those that involve more than a single connection. Make doubly sure you are only opening a single connection within the transaction and it won't escalate - Performance will be much better too.

路弥 2024-07-12 02:16:21

MSDTC 可以使用 MsDtc PowerShell 模块进行配置,例如:

# Import the module
Import-Module -Name MsDtc

# Set the DTC config
$dtcNetworkSetting = @{
    DtcName                           = 'Local'
    AuthenticationLevel               = 'NoAuth'
    InboundTransactionsEnabled        = $true
    OutboundTransactionsEnabled       = $true
    RemoteClientAccessEnabled         = $true
    RemoteAdministrationAccessEnabled = $true
    XATransactionsEnabled             = $false
    LUTransactionsEnabled             = $true
}
Set-DtcNetworkSetting @dtcNetworkSetting

# Restart the MsDtc service
Get-Service -Name MsDtc | Restart-Service

在每台将支持分布式事务的计算机上运行(即运行 MSDTC 服务的计算机)。

MSDTC can be configured with MsDtc PowerShell module, e.g.:

# Import the module
Import-Module -Name MsDtc

# Set the DTC config
$dtcNetworkSetting = @{
    DtcName                           = 'Local'
    AuthenticationLevel               = 'NoAuth'
    InboundTransactionsEnabled        = $true
    OutboundTransactionsEnabled       = $true
    RemoteClientAccessEnabled         = $true
    RemoteAdministrationAccessEnabled = $true
    XATransactionsEnabled             = $false
    LUTransactionsEnabled             = $true
}
Set-DtcNetworkSetting @dtcNetworkSetting

# Restart the MsDtc service
Get-Service -Name MsDtc | Restart-Service

Run on each of the machines that will be supporting the distributed transactions (i.e. where the MSDTC service is running).

情场扛把子 2024-07-12 02:16:21

必须在服务器和客户端这两个系统上启用 MSDTC。

另外,请确保系统之间不存在阻止 RPC 的防火墙。
DTCTest 是一个很好的小应用程序,可以帮助您解决任何其他问题。

MSDTC must be enabled on both systems, both server and client.

Also, make sure that there isn't a firewall between the systems that blocks RPC.
DTCTest is a nice litt app that helps you to troubleshoot any other problems.

旧瑾黎汐 2024-07-12 02:16:21

您还需要 MSDTC 吗? 您遇到的升级通常是由于在单个 TransactionScope 内创建多个连接引起的。

如果您确实需要它,那么您需要按照错误消息中的概述启用它。 在 XP 上:

  • 转到管理工具 -> 组件服务
  • 展开组件服务 -> 计算机 ->
  • 右键-> 属性-> MSDTC 选项卡
  • 点击安全配置按钮

Do you even need MSDTC? The escalation you're experiencing is often caused by creating multiple connections within a single TransactionScope.

If you do need it then you need to enable it as outlined in the error message. On XP:

  • Go to Administrative Tools -> Component Services
  • Expand Component Services -> Computers ->
  • Right-click -> Properties -> MSDTC tab
  • Hit the Security Configuration button
你丑哭了我 2024-07-12 02:16:21

我发现最好的调试方法是使用名为 DTCPing

  1. 将文件复制到服务器(DB)和客户端(应用程序服务器/客户端电脑)
    • 在服务器和客户端启动
    • 在服务器端:填写客户端netbios计算机名称并尝试建立DTC连接
    • 重新启动这两个应用程序。
    • 在客户端:填写服务器netbios计算机名称并尝试建立DTC连接

我在我们的旧公司网络中遇到了很多问题,我有一些提示:

  • 如果您收到错误消息“Gethostbyname失败”这意味着计算机无法通过其 netbios 名称找到另一台计算机。 例如,服务器可以解析并 ping 客户端,但这在 DNS 级别上起作用。 不在 netbios 查找级别上。 使用 WINS 服务器或更改 LMHOST(脏)将解决此问题。
  • 如果您收到错误“访问被拒绝”,则表明安全设置不匹配。 您应该比较 msdtc 的安全选项卡并使服务器和客户端匹配。 另一件需要注意的事情是 RestrictRemoteClients 值。 根据您的操作系统版本,更重要的是服务包,该值可能会有所不同。
  • 其他连接问题:

根据我的经验,如果 DTCPing 能够建立从客户端发起和从服务器发起的 DTC 连接,那么您的事务就不再是问题了。

I've found that the best way to debug is to use the microsoft tool called DTCPing

  1. Copy the file to both the server (DB) and the client (Application server/client pc)
    • Start it at the server and the client
    • At the server: fill in the client netbios computer name and try to setup a DTC connection
    • Restart both applications.
    • At the client: fill in the server netbios computer name and try to setup a DTC connection

I've had my fare deal of problems in our old company network, and I've got a few tips:

  • if you get the error message "Gethostbyname failed" it means the computer can not find the other computer by its netbios name. The server could for instance resolve and ping the client, but that works on a DNS level. Not on a netbios lookup level. Using WINS servers or changing the LMHOST (dirty) will solve this problem.
  • if you get an error "Acces Denied", the security settings don't match. You should compare the security tab for the msdtc and get the server and client to match. One other thing to look at is the RestrictRemoteClients value. Depending on your OS version and more importantly the Service Pack, this value can be different.
  • Other connection problems:
    • The firewall between the server and the client must allow communication over port 135. And more importantly the connection can be initiated from both sites (I had a lot of problems with the firewall people in my company because they assumed only the server would open an connection on to that port)
    • The protocol returns a random port to connect to for the real transaction communication. Firewall people don't like that, they like to restrict the ports to a certain range. You can restrict the RPC dynamic port generation to a certain range using the keys as described in How to configure RPC dynamic port allocation to work with firewalls.

In my experience, if the DTCPing is able to setup a DTC connection initiated from the client and initiated from the server, your transactions are not the problem any more.

栩栩如生 2024-07-12 02:16:21

还可以在此处查看如何从控件打开 MSDTC面板的 services.msc。

在触发器所在的服务器上,需要开启MSDTC
服务开启。 您可以通过单击“开始”>“ 设置> 控制面板> 管理工具 > 服务。 找到名为“分布式事务协调器”的服务并右键单击(在其上并单击
选择)> 开始。

Can also see here on how to turn on MSDTC from the Control Panel's services.msc.

On the server where the trigger resides, you need to turn the MSDTC
service on. You can this by clicking START > SETTINGS > CONTROL PANEL > ADMINISTRATIVE TOOLS > SERVICES. Find the service called 'Distributed Transaction Coordinator' and RIGHT CLICK (on it and
select) > Start.

徒留西风 2024-07-12 02:16:21

对于 Windows Server 2008 r2 和 Windows Server 2012 R2 使用此

  1. 单击开始,单击运行,键入dcomcnfg,然后单击确定打开组件服务

  2. 在控制台树中,单击展开组件服务,单击展开计算机,单击展开我的电脑,单击展开< strong>分布式事务协调器,然后单击本地 DTC

  3. 右键单击本地 DTC,然后单击属性以显示本地 DTC 属性对话框。

  4. 单击安全选项卡。

  5. 选中“网络 DTC 访问”复选框。

  6. 最后选中“允许入站”“允许出站”复选框。

  7. 单击应用确定

  8. 将会弹出一条关于重新启动服务的消息。

  9. 单击确定即可。

参考:https://msdn.microsoft.com/en-us/library/dd327979 .aspx

注意:有时,本地计算机或服务器上的网络防火墙可能会中断您的连接,因此请确保您创建“允许入站” 和 < strong>“允许出站”连接C:\Windows\System32\msdtc.exe

Use this for windows Server 2008 r2 and Windows Server 2012 R2

  1. Click Start, click Run, type dcomcnfg and then click OK to open Component Services.

  2. In the console tree, click to expand Component Services, click to expand Computers, click to expand My Computer, click to expand Distributed Transaction Coordinator and then click Local DTC.

  3. Right click Local DTC and click Properties to display the Local DTC Properties dialog box.

  4. Click the Security tab.

  5. Check mark "Network DTC Access" checkbox.

  6. Finally check mark "Allow Inbound" and "Allow Outbound" checkboxes.

  7. Click Apply, OK.

  8. A message will pop up about restarting the service.

  9. Click OK and That's all.

Reference : https://msdn.microsoft.com/en-us/library/dd327979.aspx

Note: Sometimes the network firewall on the Local Computer or the Server could interrupt your connection so make sure you create rules to "Allow Inbound" and "Allow Outbound" connection for C:\Windows\System32\msdtc.exe

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