【问题标题】:Health-check of a redis job flagged as critical in Nomad在 Nomad 中对标记为关键的 redis 作业进行健康检查
【发布时间】:2018-01-27 06:28:58
【问题描述】:

在 Nomad (0.6) 中部署 Redis 作业时,我无法在 Consul 中使其正常运行。

我在一个容器中启动 Consul,并在 localhost 上提供 8500 端口。


$ docker container run --name consul -d -p 8500:8500 consul

当我运行 nomad 时,它正确连接到 Consul,正如我们在日志中看到的那样。


$ nomad agent -dev
    No configuration files loaded
==> Starting Nomad agent...
==> Nomad agent configuration:

                Client: true
             Log Level: DEBUG
                Region: global (DC: dc1)
                Server: true
               Version: 0.6.0

==> Nomad agent started! Log data will stream in below:
...
    2017/08/18 15:45:28.373766 [DEBUG] client.consul: bootstrap contacting following Consul DCs: ["dc1"]
    2017/08/18 15:45:28.377703 [INFO] client.consul: discovered following Servers: 127.0.0.1:4647
    2017/08/18 15:45:28.378851 [INFO] client: node registration complete
    2017/08/18 15:45:28.378895 [DEBUG] client: periodically checking for node changes at duration 5s
    2017/08/18 15:45:28.379232 [DEBUG] consul.sync: registered 1 services, 1 checks; deregistered 0 services, 0 checks
...

然后我使用以下配置文件运行 redis 作业


job "nomad-redis" {
  datacenters = ["dc1"]
  type = "service"

  group "cache" {

    task "redis" {
      driver = "docker"

      config {
        image = "redis:3.2"
        port_map {
          db = 6379
        }
      }

      resources {
        cpu    = 500 # 500 MHz
        memory = 256 # 256MB
        network {
          mbits = 10
          port "db" {}
        }
      }

      service {
        name = "redis"
        port = "db"
        check {
          name     = "alive"
          type     = "tcp"
          interval = "10s"
          timeout  = "2s"
        }
      }
    }
  }
}

Redis 服务已添加到 consul 中,但它看起来很关键。似乎无法进行健康检查。据我了解,检查是在任务中完成的。有什么我想念的吗?

【问题讨论】:

    标签: consul nomad


    【解决方案1】:

    在 localhost 或连接到主机网络 (--net=host) 的容器中运行 Consul 修复了问题。

    【讨论】:

    • 你不能在 docker swarm 中使用 --net=host
    猜你喜欢
    • 2019-11-03
    • 1970-01-01
    • 2014-10-02
    • 2019-09-29
    • 1970-01-01
    • 1970-01-01
    • 2018-06-15
    • 1970-01-01
    • 2020-03-15
    相关资源
    最近更新 更多