[英]How do I enable MSDTC on SQL Server?
Is this even a valid question?这甚至是一个有效的问题吗? I have a .NET Windows app that is using MSTDC and it is throwing an exception:
我有一个使用 MSTDC 的 .NET Windows 应用程序,它抛出异常:
System.Transactions.TransactionManagerCommunicationException: Network access for Distributed Transaction Manager (MSDTC) has been disabled.
System.Transactions.TransactionManagerCommunicationException:分布式事务管理器 (MSDTC) 的网络访问已被禁用。 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.
请使用组件服务管理工具在 MSDTC 的安全配置中为网络访问启用 DTC ---> System.Runtime.InteropServices.COMException (0x8004D024):事务管理器已禁用对远程/网络事务的支持。 (Exception from HRESULT: 0x8004D024) at System.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction(UInt32 propgationTokenSize, Byte[] propgationToken, IntPtr managedIdentifier, Guid& transactionIdentifier, OletxTransactionIsolationLevel& isolationLevel, ITransactionShim& transactionShim)....
(来自 HRESULT 的异常:0x8004D024)在 System.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction(UInt32 propgationTokenSize, Byte[] propgationToken, IntPtr managedIdentifier, Guid& transactionIdentifier, OletxTransactionIsolationLevel&isolationLevel&translationLevel&IShimShimShim)....
I followed the Kbalertz guide to enable MSDTC on the PC on which the app is installed, but the error still occurs.我按照Kbalertz 指南在安装了该应用程序的 PC 上启用了 MSDTC ,但仍然出现错误。
I was wondering if this was a database issue?我想知道这是不是数据库问题? If so, how can I resolve it?
如果是这样,我该如何解决?
Use this for windows Server 2008 r2 and Windows Server 2012 R2 用于Windows Server 2008 r2和Windows Server 2012 R2
Click Start , click Run , type dcomcnfg and then click OK to open Component Services . 单击“ 开始” ,单击“运行” ,键入dcomcnfg ,然后单击“ 确定”以打开“ 组件服务” 。
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 . 在控制台树中,单击以展开“ 组件服务” ,单击以展开“ 计算机” ,单击以展开“ 我的电脑” ,单击以展开“ 分布式事务处理协调器” ,然后单击“ 本地DTC” 。
Right click Local DTC and click Properties to display the Local DTC Properties dialog box. 右键单击“ 本地DTC” ,然后单击“ 属性”以显示“ 本地DTC属性”对话框。
Click the Security tab. 单击“ 安全”选项卡。
Check mark "Network DTC Access" checkbox. 选中“网络DTC访问”复选框。
Finally check mark "Allow Inbound" and "Allow Outbound" checkboxes. 最后选中“允许入站”和“允许出站”复选框。
Click Apply , OK . 单击应用 , 确定 。
A message will pop up about restarting the service. 将弹出有关重新启动服务的消息。
Click OK and That's all. 单击“ 确定” ,这就是全部。
Reference : https://msdn.microsoft.com/en-us/library/dd327979.aspx 参考: 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
注意:有时本地计算机或服务器上的网络防火墙可能会中断您的连接,因此请确保为
C:\\Windows\\System32\\msdtc.exe
创建“允许入站”和“允许出站”连接的规则
Do you even need MSDTC? 你甚至需要MSDTC吗? The escalation you're experiencing is often caused by creating multiple connections within a single TransactionScope.
您遇到的升级通常是由在单个TransactionScope中创建多个连接引起的。
If you do need it then you need to enable it as outlined in the error message. 如果确实需要它,则需要按照错误消息中的说明启用它。 On XP:
在XP上:
I've found that the best way to debug is to use the microsoft tool called DTCPing 我发现最好的调试方法是使用名为DTCPing的微软工具
I've had my fare deal of problems in our old company network, and I've got a few tips: 我在旧的公司网络中遇到了问题,我有一些提示:
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. 根据我的经验,如果DTCPing能够设置从客户端发起并从服务器启动的DTC连接,那么您的交易不再是问题。
Can also see here on how to turn on MSDTC from the Control Panel's services.msc. 还可以在此处查看如何从控制面板的services.msc打开MSDTC。
On the server where the trigger resides, you need to turn the MSDTC service on.
在触发器所在的服务器上,您需要打开MSDTC服务。 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.
找到名为“分布式事务处理协调器”的服务并右键单击(在其上并选择)>启动。
MSDTC must be enabled on both systems, both server and client. 必须在服务器和客户端两个系统上启用MSDTC。
Also, make sure that there isn't a firewall between the systems that blocks RPC. 此外,请确保阻止RPC的系统之间没有防火墙。
DTCTest is a nice litt app that helps you to troubleshoot any other problems. DTCTest是一个很好的小应用程序,可以帮助您解决任何其他问题。
@Dan, @担,
Do I not need msdtc enabled for transactions to work?
我是否不需要启用msdtc才能使事务有效?
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.
确保您只在交易中打开一个连接并且不会升级 - 性能也会好得多。
MSDTC can be configured with MsDtc PowerShell module, eg: 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
Run on each of the machines that will be supporting the distributed transactions (ie where the MSDTC service is running).在支持分布式事务的每台机器上运行(即运行 MSDTC 服务的机器)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.