How to configure the Microsoft Distributed Transaction Coordinator (MSDTC) on Linux

APPLIES TO: SQL Server (Linux only) Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse

This article describes how to configure the Microsoft Distributed Transaction Coordinator (MSTDC) on Linux. MSDTC support on Linux was introduced in SQL Server 2019 preview.

Overview

https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-msdtc?view=sqlallproducts-allversions

sqlserver  不支持该命令 

已经确认

Distributed transactions are enabled on SQL Server on Linux by introducing MSDTC and RPC endpoint mapper functionality within SQL Server. By default, an RPC endpoint-mapping process listens on port 135 for incoming RPC requests and routes that to appropriate components (such as the MSDTC service). A process requires super user privilege to bind to well-known ports (port numbers less than 1024) on Linux. To avoid starting SQL Server with root privileges for the RPC endpoint mapper process, system administrators must use iptables to create NAT translation to route traffic on port 135 to SQL Server's RPC endpoint-mapping process.

SQL Server 2019 introduces two configuration parameters for the mssql-conf utility.

mssql-conf setting Description
network.rpcport The TCP port that the RPC endpoint mapper process binds to.
network.servertcpport The port that the MSDTC server listens to. If not set, the MSDTC service uses a random ephemeral port on service restarts, and firewall exceptions will need to be re-configured to ensure that MSDTC service can continue communication.

For more information about these settings and other related MSDTC settings, see Configure SQL Server on Linux with the mssql-conf tool.

Supported MSDTC configurations

The following MSDTC configurations are supported:

  • OLE-TX Distributed transactions against SQL Server on Linux for JDBC and ODBC providers.
  • XA Distributed transactions against SQL Server on Linux using JDBC providers.
  • Distributed transactions on Linked server.

For limitations and known issues for MSDTC in preview, see Release notes for SQL Server 2019 preview on Linux.

MSDTC configuration steps

There are three steps to configure MSDTC communication and functionality. If the necessary configuration steps are not done, SQL Server will not enable MSDTC functionality.

  • Configure network.rpcport and distributedtransaction.servertcpport using mssql-conf.
  • Configure the firewall to allow communication on rpcport, servertcpport, and port 135.
  • Configure Linux server routing so that RPC communication on port 135 is redirected to SQL Server's network.rpcport.

The following sections provide detailed instructions for each step.

Configure RPC and MSDTC ports

First, configure network.rpcport and distributedtransaction.servertcpport using mssql-conf.

  1. Use mssql-conf to set the network.rpcport value. The following example sets it to 13500.

    bashCopy
    sudo /opt/mssql/bin/mssql-conf set network.rpcport 13500
  2. Set the distributedtransaction.servertcpport value. The following example sets it to 51999.

    bashCopy
    sudo /opt/mssql/bin/mssql-conf set distributedtransaction.servertcpport 51999
  3. Restart SQL Server.

    bashCopy
    sudo systemctl restart mssql-server

Configure the firewall

The final step is to configure the firewall to allow communication on rpcport, servertcpport, and port 135. This enables the RPC endpoint-mapping process and MSDTC process to communicate externally to other transaction managers and coordinators. The actual steps for this will vary depending on your Linux distribution and firewall.

The following example shows how to create these rules on Ubuntu.

bashCopy
sudo ufw allow from any to any port 51999 proto tcp
sudo ufw allow from any to any port 135 proto tcp

The following example shows how this could be done on Red Hat Enterprise Linux (RHEL):

bashCopy
sudo firewall-cmd --zone=public --add-port=51999/tcp --permanent
sudo firewall-cmd --zone=public --add-port=135/tcp --permanent
sudo firewall-cmd --reload

It is important to configure the firewall before configuring port routing in the next section. Refreshing the firewall can clear the port routing rules in some cases.

Configure port routing

Configure the Linux server routing table so that RPC communication on port 135 is redirected to SQL Server's network.rpcport. Configuration mechanism for port forwarding on different distribution may differ. On distributions which do not use firewalld service, iptable rules are an efficient mechanism to achieve this. Example of such distrubution are Ubuntu 16.04 and SUSE Enterprise Linux v12. The iptable rules may not persist during reboots, so the following commands also provide instructions for restoring the rules after a reboot.

  1. Create routing rules for port 135. In the following example, port 135 is directed to the RPC port, 13500, defined in the previous section. Replace <ipaddress> with the IP address of your server.

    bashCopy
    iptables -t nat -A PREROUTING -d <ip> -p tcp --dport 135 -m addrtype --dst-type LOCAL  \
    -j DNAT --to-destination <ip>:13500 -m comment --comment RpcEndPointMapper
    iptables -t nat -A OUTPUT -d <ip> -p tcp --dport 135 -m addrtype --dst-type LOCAL \
    -j DNAT --to-destination <ip>:13500 -m comment --comment RpcEndPointMapper

    The --comment RpcEndPointMapper parameter in the previous commands assists with managing these rules in later commands.

  2. View the routing rules you created with the following command:

    bashCopy
    iptables -S -t nat | grep "RpcEndPointMapper"
  3. Save the routing rules to a file on your machine.

    bashCopy
    iptables-save > /etc/iptables.conf
  4. To reload the rules after a reboot, add the following command to /etc/rc.local (for Ubuntu or RHEL) or to /etc/init.d/after.local (for SLES):

    bashCopy
    iptables-restore < /etc/iptables.conf

The iptables-save and iptables-restore commands provide a basic mechanism to save and restore iptables entries. Depending on your Linux distribution, there might be more advanced or automated options available. For example, an Ubuntu alternative is the iptables-persistent package to make entries persistent.

On distributions which use firewalld service, the same service can be used for both opening the port on the server and internal port forwarding. For example, on Red Hat Enterprise Linux, you should use firewalld service (via firewall-cmd configuration utility with -add-forward-port or similar options) to create and manage persistent port forwarding rules instead of using iptables.

bashCopy
firewall-cmd --permanent --add-forward-port=port=135:proto=tcp:toport=13500

Important

The previous steps assume a fixed IP address. If the IP address for your SQL Server instance changes (due to manual intervention or DHCP), you must remove and recreate the routing rules if they were created with iptables. If you need to recreate or delete existing routing rules, you can use the following command to remove old RpcEndPointMapper rules:

bashCopy
iptables -S -t nat | grep "RpcEndPointMapper" | sed 's/^-A //' | while read rule; do iptables -t nat -D $rule; done

Verify

At this point, SQL Server should be able to participate in distributed transactions. To verify that SQL Server is listening, run the netstatcommand (if you are using RHEL, you might have to first install the net-tools package):

bashCopy
sudo netstat -tulpn | grep sqlservr

You should see output similar to the following:

bashCopy
tcp 0 0 0.0.0.0:1433 0.0.0.0:* LISTEN 13911/sqlservr
tcp 0 0 127.0.0.1:1434 0.0.0.0:* LISTEN 13911/sqlservr
tcp 0 0 0.0.0.0:13500 0.0.0.0:* LISTEN 13911/sqlservr
tcp 0 0 0.0.0.0:51999 0.0.0.0:* LISTEN 13911/sqlservr
tcp6 0 0 :::1433 :::* LISTEN 13911/sqlservr
tcp6 0 0 ::1:1434 :::* LISTEN 13911/sqlservr
tcp6 0 0 :::13500 :::* LISTEN 13911/sqlservr
tcp6 0 0 :::51999 :::* LISTEN 13911/sqlservr

However, after a restart, SQL Server does not start listening on the servertcpport until the first distributed transaction. In this case, you would not see SQL Server listening on port 51999 in this example until the first distributed transaction.

Next steps

For more information about SQL Server on Linux, see SQL Server on Linux.

[官网]How to configure the Microsoft Distributed Transaction Coordinator (MSDTC) on Linux的更多相关文章

  1. The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction.

    同事反馈一个系统在运行一个存储过程时遇到了下面错误: Msg 1206, Level 18, State 169, Procedure xxxxxx, Line 118The Microsoft Di ...

  2. 解决启动Distributed Transaction Coordinator服务出错的问题

    解决启动Distributed Transaction Coordinator服务出错的问题   "Windows 不能在 本地计算机 启动 Distributed Transaction ...

  3. Distributed Transaction Coordinator(DTC)一些问题的解决方法

    有时运行某个程序或者安装SQL Server时报错. 错误信息: 事务管理器不可用.(从 HRESULT 异常: 0x8004D01B) 启动服务Distributed Transaction Coo ...

  4. Distributed Transaction Coordinator 无法启动

    有时候我们需要进行COM应用程序的权限设置,控制面板-->管理工具-->组件服务-->然后依此展开:组件服务-->计算机-->我的电脑-->DCOM 配置,接下来找 ...

  5. 无法启动DISTRIBUTED TRANSACTION COORDINATOR解决方法

    有时候我们需要进行COM应用程序的权限设置,控制面板-->管理工具-->组件服务-->然后依此展开:组件服务-->计算机-->我的电脑-->DCOM 配置,接下来找 ...

  6. [官网]How to use distributed transactions with SQL Server on Docker

    How to use distributed transactions with SQL Server on Docker https://docs.microsoft.com/en-us/sql/l ...

  7. MS SQL 错误:The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "test" was unable to begin a distributed transaction.

       一同事在测试服务器(系统:Windows 2008 R2 Standard 数据库:SQL SERVER 2008 R2)通过链接服务器test使用分布式事务测试时出错,出错信息如下: set ...

  8. Nuget 自定义配置(官网)

    <?xml version="1.0" encoding="utf-8"?> <configuration> <config> ...

  9. Visual C++ 2013 and Visual C++ Redistributable Package 更新版官网下载地址

    Visual C++ 2013 and Visual C++ Redistributable Visual C++ 2013 and Visual C++ Redistributable Packag ...

随机推荐

  1. Linux /var/log下的各种日志文件详解

    1)/var/log/secure:记录登录系统存取数据的文件;例如:pop3,ssh,telnet,ftp等都会记录在此. 2)/var/log/wtmp:记录登录这的信息记录,被编码过,所以必须以 ...

  2. 我为什么要谈KeepAlive(文末增加nginx 负载tcp长连接保持 demo)

    http://blog.sina.com.cn/s/blog_e59371cc0102ux5w.html 最近工作中遇到一个问题,想把它记录下来,场景是这样的: 从上图可以看出,用户通过Client访 ...

  3. 阿里中间件——消息中间件Notify和MetaQ

    3.1.Notify Notify是淘宝自主研发的一套消息服务引擎,是支撑双11最为核心的系统之一,在淘宝和支付宝的核心交易场景中都有大量使用.消息系统的核心作用就是三点:解耦,异步和并行.下面让我以 ...

  4. UVA12265-Selling Land(单调栈)

    Problem UVA12265-Selling Land Accept: 137  Submit: 782Time Limit: 3000 mSec Problem Description Inpu ...

  5. IRT模型的参数估计方法(EM算法和MCMC算法)

    1.IRT模型概述 IRT(item response theory 项目反映理论)模型.IRT模型用来描述被试者能力和项目特性之间的关系.在现实生活中,由于被试者的能力不能通过可观测的数据进行描述, ...

  6. 图上最短路(Dijkstra, spfa)

    单源最短路径 题目描述 如题,给出一个有向图,请输出从某一点出发到所有点的最短路径长度. 输入输出格式 输入格式: 第一行包含三个整数N.M.S,分别表示点的个数.有向边的个数.出发点的编号. 接下来 ...

  7. 字符串相关的hash值(一)

  8. IntelliJ IDEA 高效率配置

    之前学习和开发的时候一直用Eclipse,现在转战IDEA,记录一下IDEA的个性化设置,有助于提高效率.(参考:http://www.cnblogs.com/huaxingtianxia/p/586 ...

  9. 串行FLASH文件系统FatFs---转自野火论坛

    为了支持长文件名,需要用到FATFS源码中的cc936.c的两个函数ff_convert,ff_wtoupper:这里面直接用了两个大数组(127KB)来做unicode转gbk(OEM)的对照表,这 ...

  10. Java发送Email邮件及SpringBoot集成

    一:普通方式发送 1.导包 <!--Java MAil 发送邮件API--> <dependency> <groupId>javax.mail</groupI ...