![Nomad 上的 Rabbitmq 集群](https://linux22.com/image/783556/Nomad%20%E4%B8%8A%E7%9A%84%20Rabbitmq%20%E9%9B%86%E7%BE%A4.png)
我想在 Nomad 集群中创建一个 RabbitMQ 集群。目前我可以运行 RabbitMQ Docker 容器,但无法基于 Consul Discovery 创建集群。Containters 启动后,我在每个节点上都收到了以下消息:
[warning] <0.229.0> Could not auto-cluster with node [email protected]: {badrpc,nodedown}
[warning] <0.229.0> Could not auto-cluster with node rabbit@test-nomad1: {badrpc,nodedown}
[warning] <0.229.0> Could not auto-cluster with node rabbit@test-nomad2: {badrpc,nodedown}
[warning] <0.229.0> Could not auto-cluster with node rabbit@test-nomad3: {badrpc,nodedown}
我的问题在哪里?我在想也许需要先启动一个节点,并且我已经使用 prestart 添加了一个容器,但这对我没有帮助。我的游牧工作:
job "test" {
datacenters = ["dc1"]
group "test-group" {
count = 4
update {
max_parallel = 1
}
migrate {
max_parallel = 1
health_check = "checks"
min_healthy_time = "30s"
healthy_deadline = "60s"
}
task "rabbit" {
driver = "docker"
config {
image = "<my_registry>/rabbitmq:consul"
force_pull = true
hostname = "${attr.unique.hostname}"
port_map {
amqp = 5672
ui = 15672
discovery = 4369
clustering = 25672
}
auth {
server_address = "<my_registry>"
username = "user"
password = "pass"
}
}
env {
RABBITMQ_ERLANG_COOKIE = "RabbitMQ"
RABBITMQ_DEFAULT_USER = "test"
RABBITMQ_DEFAULT_PASS = "test"
CONSUL_HOST = "10.14.1.109"
CONSUL_SVC_PORT = "${NOMAD_HOST_PORT_amqp}"
CONSUL_SVC_TAGS = "amqp"
}
resources {
network {
port "amqp" { static = 5672 }
port "ui" { static = 15672 }
port "discovery" { static = 4369 }
port "clustering" { static = 25672 }
}
}
service {
name = "rabbitmq"
port = "ui"
tags = ["management", "http"]
}
}
}
}
Rabbitmq配置:
loopback_users.guest = false
listeners.tcp.default = 5672
hipe_compile = false
management.listener.port = 15672
management.listener.ssl = false
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_consul
cluster_formation.consul.acl_token = <my_token>
cluster_formation.consul.host = 10.14.1.109
cluster_formation.consul.svc_addr_auto = true
cluster_formation.consul.svc_addr_use_nodename = false
在领事服务中我看到了兔子 谢谢你的帮助!
答案1
问题已修复,docker 容器未配置为获取 consul dns。如何修复它https://awesomeprogrammer.com/blog/2021/12/22/consul-dns-services-discovery-in-docker-gotchas/