0

我运行了这段代码:

job "zookeeper" {

    constraint {
        attribute = "${attr.unique.network.ip-address}"
        value     = "130.250.58.163"
    }

    datacenters = ["nosql_dc"]

    type = "service"
    group "zookeeper" {
        count = 1
        restart {
          attempts = 0
        }

        task "instance" {
            driver = "raw_exec"
            kill_timeout = "60s"
            resources {
                network {
                    port "zookeeper_port" {
                        static = 2181
                    }
                }
            }

            config {
                command = "/nosql/zookeeper/bin/zkServer.sh"
                args = ["start"]
            }

            service {
                    name = "zookeeper"
                    port = "zookeeper_port"

                    check {
                      name     = "Zookeeper Check"
                      type     = "tcp"
                      interval = "30s"
                      timeout  = "10s"
                      port     = "zookeeper_port"
                    }
            }
        }
    }
}

一切看起来都不错,但似乎 nomad 杀死了进程

运行后的结果:

图片 => 运行后的结果

仍然错误:

图片 => 仍然错误

当我检查ps -ef | grep zoo该过程时不存在。

4

1 回答 1

1

Nomad 认为程序作为未启动的服务器运行。我假设 Nomad 没有达到 PID。

解决方案是:以前端模式启动程序。这适用于所有程序。

config {
          command = "/nosql/zookeeper/bin/zkServer.sh"
          args = ["start-foreground"]
}
于 2018-07-17T10:08:32.503 回答