简体   繁体   English

Docker (Linux) 和 Windows 主机中 SQL Server 的 MSDTC 配置问题

[英]MSDTC configuration issues with SQL Server in Docker (Linux) and Windows Host

I'm migrating a local SQL Server development database to run in a Linux docker container (on the same dev machine).我正在迁移本地 SQL Server 开发数据库以在 Linux docker 容器(在同一台开发机器上)中运行。 When running my integration tests in Visual Studio 2019 on Windows, I receive MSDTC errors:在 Windows 上的 Visual Studio 2019 中运行我的集成测试时,我收到 MSDTC 错误:

Exception thrown: 'System.Transactions.TransactionManagerCommunicationException' in System.Data.dll An exception of type 'System.Transactions.TransactionManagerCommunicationException' occurred in System.Data.dll but was not handled in user code Communication with the underlying transaction manager has failed.抛出异常:System.Data.dll 中的“System.Transactions.TransactionManagerCommunicationException” System.Data.dll 中发生类型为“System.Transactions.TransactionManagerCommunicationException”的异常,但未在用户代码中处理 与底层事务管理器的通信失败。

Here's my latest iteration of SQL Server in my docker-compose:这是我在 docker-compose 中最新的 SQL Server 迭代:

services:
  sqlserver:
    image: mcr.microsoft.com/mssql/server:2019-latest
    container_name: SqlServer
    restart: always
    environment:
      - ACCEPT_EULA=Y
      - SA_PASSWORD=verySecretPassword
      - MSSQL_RPC_PORT=13500
      - MSSQL_DTC_TCP_PORT=51000
    ports:
      - "1401:1433"
      - "135:13500"
      - "51000:51000"
    volumes:
      - sqldata:/var/opt/mssql

I've tried all sorts of ways to adjust the RPC port to get this working.我尝试了各种方法来调整 RPC 端口以使其正常工作。 This is the main MS article . 这是主要的 MS 文章 I've tried port 135:135 but it gives the same error.我试过端口135:135但它给出了同样的错误。 The note in the article at the bottom appears to be related to my issue.底部文章中的注释似乎与我的问题有关。

For SQL Server outside of a container or for non-root containers, a different ephemeral port, such as 13500, must be used in the container and traffic to port 135 must then be routed to that port.对于容器外部的 SQL Server 或非根容器,必须在容器中使用不同的临时端口,例如 13500,然后必须将到端口 135 的流量路由到该端口。 You would also need to configure port routing rules within the container from the container port 135 to the ephemeral port.您还需要在容器内配置从容器端口 135 到临时端口的端口路由规则。

Also, if you decide to map the container's port 135 to a different port on the host, such as 13500, then you have to configure port routing on the host.此外,如果您决定将容器的端口 135 映射到主机上的其他端口,例如 13500,则必须在主机上配置端口路由。 This enables the docker container to participate in distributed transactions with the host and with other external servers.这使 docker 容器能够参与与主机和其他外部服务器的分布式事务。

SQL Server 2019 containers run as a non-root user. SQL Server 2019 容器以非 root 用户身份运行。 I've tried port routing using netsh in windows... and also the MS article links to how to perform port forwarding in Ubuntu... which I'm unable to do even when logged in as root in the SQL Server container... iptables is not installed, and it doesn't let me apt-get install it??我已经尝试过在 Windows 中使用 netsh 进行端口路由......还有 MS 文章链接到如何在 Ubuntu 中执行端口转发......即使在 SQL Server 容器中以 root 身份登录时我也无法做到...... .iptables 没有安装,也不让我apt-get install ?? I also updated the DTC options in windows to make it as open as possible, but it had no effect.我还更新了 Windows 中的 DTC 选项,使其尽可能打开,但没有任何效果。 Not sure what the secret sauce is.不知道秘方是什么。 Hoping someone else has a similar setup that works.希望其他人有类似的设置。

MSDTC 选项

Thanks for the tip on msdtc config, I got mine working with this compose:感谢有关msdtc配置的提示,我开始使用此组合:

version: '3.4'

services:
  sqlserver:
    image: mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04
    container_name: sqlserver
    user: root
    environment:
      - ACCEPT_EULA=Y
      - SA_PASSWORD=[yourPwd]
      - MSSQL_RPC_PORT=135
      - MSSQL_DTC_TCP_PORT=51000
    ports:
      - "1433:1433"
      - "135:135"
      - "51000:51000"
    volumes:
      - D:\DockerVolumes\sqlserver:/var/opt/mssql/data

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 Linux 主机使用 Windows 身份验证对 SQL 服务器和 ZD233B99A3CCB7966A032466 - How to use Windows authentication for SQL Server from a Linux host with SQLAlchemy? 无法绑定在 Linux SQL 服务器中安装 Windows 文件夹 Z05B6053C41A2130AFDZimageBDAE1 - Unable to bind mount a Windows folder in a Linux SQL Server docker image 如何在SQL Server 2014上启用MSDTC? - How to enable MSDTC on SQL Server 2014? 如何在 SQL Server 上启用 MSDTC? - How do I enable MSDTC on SQL Server? 如何从 .net Core Linux Docker 容器(使用 Docker for Windows)连接到 Internet 上的 Sql Server? - How can I connect to a Sql Server on the internet from a .net Core Linux Docker container (using Docker for Windows)? SQL VM 和主机之间的链接服务器配置 - SQL Linked server configuration between VM and Host SQL Server Docker 容器可以在 Windows Server core 2022 上运行吗(“linux”不能在这个平台上使用) - Can a SQL Server Docker container run on Windows Server core 2022 ("linux" cannot be used on this platform) 如何从 windows Z05B6053C415A2134EAD6 容器中的 .NET 应用程序连接到在主机上运行的 SQL 服务器 - How do you connect to SQL Server running on the host from a .NET app in a windows docker container 来自Premise SQL Server上的Azure链接的SQL Server-MSDTC异常 - Azure Linked SQL server from on Premise SQL Server - MSDTC exception Docker容器中的SQL Server配置管理器 - SQL Server Configuration Manager in docker container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM