Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server - Linux
This article describes how to configure the Microsoft Distributed Transaction Coordinator (MSDTC) on Linux.
MSDTC on Linux is supported on SQL Server 2017 (14.x) Cumulative Update 16 and later versions.
Overview
You enable distributed transactions on SQL Server on Linux by introducing MSDTC and remote procedure call (RPC) endpoint mapper functionality within SQL Server. By default, an RPC endpoint-mapping process listens on port 135 for incoming RPC requests and provides registered components information to remote requests. Remote requests can use the information returned by endpoint mapper to communicate with registered RPC components, such as MSDTC services.
A process requires super user privileges 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 Network Address Translation to route traffic on port 135 to the SQL Server instance's RPC endpoint-mapping process.
MSDTC uses 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. |
distributedtransaction.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 need to be reconfigured 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 transaction standards
The following MSDTC configurations are supported:
| Transaction standard | Data sources | ODBC driver | JDBC driver |
|---|---|---|---|
| OLE-TX transactions | SQL Server on Linux | Yes | No |
| XA distributed transactions | SQL Server, other ODBC, and JDBC data sources that support XA | Yes (requires 17.3 or later versions) | Yes |
| Distributed transactions on linked server | SQL Server | Yes | No |
For more information, see Understanding XA Transactions.
MSDTC configuration steps
Complete the following three steps to configure MSDTC communication and functionality for SQL Server.
- Configure
network.rpcportanddistributedtransaction.servertcpportwith mssql-conf. - Configure the firewall to allow communication on
distributedtransaction.servertcpportand port 135. - Configure Linux server routing so that RPC communication on port 135 is redirected to the SQL Server instance's
network.rpcport.
The following sections provide detailed instructions for each step.
Configure RPC and MSDTC ports
Configure network.rpcport and distributedtransaction.servertcpport with mssql-conf. This step is specific to SQL Server and common across all supported distributions.
Use mssql-conf to set the
network.rpcportvalue. The following example sets it to 13500.sudo /opt/mssql/bin/mssql-conf set network.rpcport 13500Set the
distributedtransaction.servertcpportvalue. The following example sets it to 51999.sudo /opt/mssql/bin/mssql-conf set distributedtransaction.servertcpport 51999Restart SQL Server.
sudo systemctl restart mssql-server
Configure the firewall
Configure the firewall to allow communication on servertcpport and port 135. This step enables the RPC endpoint-mapping process and MSDTC process to communicate externally to other transaction managers and coordinators. The actual procedure varies depending on your Linux distribution and firewall.
The following example shows how to create these rules on Ubuntu.
sudo ufw allow from any to any port 51999 proto tcp
sudo ufw allow from any to any port 135 proto tcp
sudo ufw allow from any to any port 13500 proto tcp
It's 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 the SQL Server instance's network.rpcport. The configuration mechanism for port forwarding might differ on different distributions. The following sections provide guidance for Ubuntu, SUSE Enterprise Linux (SLES), and Red Hat Enterprise Linux (RHEL).
Ubuntu and SLES don't use the firewalld service, so iptables rules are an efficient mechanism to achieve port routing. The iptables rules might not persist during restarts, so the following commands also provide instructions for restoring the rules after a restart.
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.sudo 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 sudo 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 RpcEndPointMapperThe
--comment RpcEndPointMapperparameter in the previous commands helps you manage these rules in later commands.View the routing rules you created with the following command:
sudo iptables -S -t nat | grep "RpcEndPointMapper"Save the routing rules to a file on your machine.
sudo iptables-save > /etc/iptables.confTo reload the rules after a restart, add the following command to
/etc/rc.local(for Ubuntu) or to/etc/init.d/after.local(for SLES):iptables-restore < /etc/iptables.confNote
You must have super user (sudo) privileges to edit the
rc.localorafter.localfiles.
The iptables-save and iptables-restore commands, along with rc.local/after.local startup configuration, 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.
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 you created them with iptables. If you need to recreate or delete existing routing rules, use the following command to remove old RpcEndPointMapper rules:
sudo 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 netstat command. If you're using RHEL, you might have to first install the net-tools package:
sudo netstat -tulpn | grep sqlservr
You should see output similar to the following example:
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 doesn't start listening on the servertcpport until the first distributed transaction. In this case, you wouldn't see SQL Server listening on port 51999 in this example until the first distributed transaction.
Configure authentication on RPC communication for MSDTC
MSDTC for SQL Server on Linux doesn't use authentication on RPC communication by default. However, when the host machine is joined to an Active Directory domain, you can configure MSDTC to use authenticated RPC communication by using the following mssql-conf settings:
| Setting | Description |
|---|---|
distributedtransaction.allowonlysecurerpccalls |
Configure secure only RPC calls for distributed transactions. The default value is 0. |
distributedtransaction.fallbacktounsecurerpcifnecessary |
Configure security only RPC calls for distributed transactions. The default value is 0. |
distributedtransaction.turnoffrpcsecurity |
Enable or disable RPC security for distributed transactions. The default value is 0. |
Supportability and compatibility
Active Directory
Microsoft recommends using MSDTC with RPC enabled if SQL Server is enrolled in an Active Directory configuration. If you configure SQL Server to use Active Directory authentication, MSDTC uses mutual authentication RPC security by default.
Windows and Linux
If a client on a Windows operating system needs to enlist into distributed transaction with SQL Server on Linux, it must have the following minimum version of Windows operating system:
| Operating system | Minimum version | OS build |
|---|---|---|
| Windows Server | 1903 | 18362.30.190401-1528 |
| Windows 10 | 1903 | 18362.267 |