-
Launch and connect SQL Server Management Studio or use the sqlcmd utility.
-
Execute this stored procedure on master database
EXEC
sp_sqljdbc_xa_install.
-
Configure the RPC and MSDTC ports:
- Use mssql-conf to set the
network.rpcport value. The following
example sets it to 13500:sudo /opt/mssql/bin/mssql-conf set network.rpcport
13500
- Set the
distributedtransaction.servertcpport value. The
following example sets it to 51999:sudo /opt/mssql/bin/mssql-conf set
distributedtransaction.servertcpport 51999
- Restart SQL Server:
sudo systemctl restart
mssql-server
-
Configure the firewall to allow communication on
servertcpport and
port 135. This action enables the RPC endpoint-mapping process and MSDTC process to
communicate externally to other transaction managers and coordinators. Run the following
commands:
sudo firewall-cmd --zone=public --add-port=51999/tcp --permanent
sudo firewall-cmd --zone=public --add-port=135/tcp --permanent
sudo firewall-cmd –reload
-
Configure the Linux server routing table so that RPC communication on port 135 is redirected to SQL
Server's
network.rpcport. Run the following commands:
sudo firewall-cmd --permanent --add-forward-port=port=135:proto=tcp:toport=13500
sudo firewall-cmd –reload
-
At this point, SQL Server should be able to participate in distributed transactions.
To verify that SQL Server is listening, run the
netstat command. (You
might have to first install the net-tools package.)
sudo netstat -tulpn | grep sqlservr
You should see output similar to the
following:
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
-
Restart the SQL server by running the following command:
sudo systemctl restart mssql-server
Note:
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.
Result: For more information, see https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-msdtc?view=sql-server-ver15.