部署 mssql 数据库时运行状况检查失败

问题描述 投票:0回答:2

在 AWS ECS 上部署 mssql 数据库时,运行状况检查失败。

下面是 docker-compose.yml 文件中的服务副本

  sql_server_db:
    image: 'mcr.microsoft.com/mssql/server:2017-latest'
    environment:
        SA_PASSWORD: Password123@
        ACCEPT_EULA: "Y"
    labels:
      - traefik.enable=false
    deploy:
        resources:
            limits:
              cpus: '1'
              memory: 8Gb
            reservations:
              cpus: '0.5'
              memory: 4GB
    healthcheck:
      test: ["/opt/mssql-tools/bin/sqlcmd", "-U", "sa", "-P", "Password123@", "-Q", "SELECT 1"]
      interval: 1m
      retries: 10
      start_period: 60s
docker docker-compose docker-swarm
2个回答
1
投票

我有同样的问题,当检查容器的“检查”时,我收到“SA 登录失败”

这很令人不安,因为密码是相同的(我使用了 .env 变量)......但由于某种原因,特殊字符似乎搞乱了检查。

我只是创建了一个 oneliner 脚本

/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "Select 1"

然后我称其为HC

healthcheck:
      test: ["CMD","bash","/healthcheck.sh", ]

并且有效

我不太喜欢它,但我会保留它,直到找到更好的(我不确定它实际上会失败)


0
投票

我在这样做时遇到了同样的问题,当我挖掘容器并思考

docker exec
命令时,我能够找到这个问题

Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : TCP Provider: Error code 0x2749.
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : SSL Provider: [error:0A000086:SSL routines::certificate verify failed:self-signed certificate].
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to cbe08dee1b32. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : Client unable to establish connection. For solutions related to encryption errors, see https://go.microsoft.com/fwlink/?linkid=2226722.

然后代替这个

healthcheck:
      test: [ "CMD-SHELL", "/opt/mssql-tools18/bin/sqlcmd -U sa -P myPass -Q 'SELECT 1' || exit 1" ]
      interval: 10s
      timeout: 5s
      retries: 5

我更改了命令以接受连接,即使有证书也可以通过添加额外参数

-C
,如下所示

 healthcheck:
          test: [ "CMD-SHELL", "/opt/mssql-tools18/bin/sqlcmd -U sa -P myPass -Q 'SELECT 1' -C || exit 1" ]
          interval: 10s
          timeout: 5s
          retries: 5

然后通过这样做我能够解决问题并绕过证书问题 这对我有用:) 希望有帮助!!!

© www.soinside.com 2019 - 2024. All rights reserved.