如何在aws中群集rabbitmq

我尝试了所有可能的组合,尝试在AWS环境中对rabbitmq进行群集。 但要回顾一下:

  1. closures并删除我的本地Ubuntu 14上的erlang和rabbit发行版
  2. 尝试了networking上的自动configuration模块
  3. 默认安装的ubuntu 14版本将不会削减它。
  4. erlang cookie匹配 – 这在下面演示

主机名称不匹配是唯一的难题。 节点本身认为它的主机名分别是“q1”或“q2”。 当我尝试将容器的主机名设置为主机的私有DNS名称(因此它可以连接到其他节点)容器中的兔子实例崩溃。 不低于如何hostname生产q2但我炮轰到亚马逊的私人dns?

 root@q2:~# hostname q2 root@q2:~# exit christian@q2:~$ logout Connection to ip-10-0-3-101.us-west-2.compute.internal closed. 

我正在使用最新的rabbitmq docker镜像。

 docker run -d --restart always --hostname q1 --name rabbitmq -p 4369:4369 -p 15671:15671 -p 25672:25672 -p 15672:15672 -p 5672:5672 -e RABBITMQ_HIPE_COMPILE=1 -e RABBITMQ_ERLANG_COOKIE='ilikecookies' rabbitmq:3-management 

服务启动得很好

 root@q1:~# curl -I localhost:15672 HTTP/1.1 200 OK Content-Length: 1419 Content-Type: text/html Date: Fri, 20 Jan 2017 22:46:12 GMT last-modified: Fri, 20 Jan 2017 22:38:45 GMT Server: MochiWeb/1.0 (Any of you quaids got a smint?) 

这里是来自主机q1的cookie

 root@q1:~# docker exec -it rabbitmq /bin/bash root@q1:/# cat /var/lib/rabbitmq/.erlang.cookie ilikecookies root@q1:/# 

现在我试图将它(来自主机q2,主机q1)

 root@q2:~# docker exec -it rabbitmq /bin/bash root@q2:/# rabbitmqctl stop_app Stopping node rabbit@q2 ... root@q2:/# rabbitmqctl join_cluster rabbit@ip-10-0-3-56.us-west-2.compute.internal Clustering node rabbit@q2 with 'rabbit@ip-10-0-3-56.us-west-2.compute.internal' ... Error: unable to connect to nodes ['rabbit@ip-10-0-3-56.us-west-2.compute.internal']: nodedown DIAGNOSTICS =========== attempted to contact: ['rabbit@ip-10-0-3-56.us-west-2.compute.internal'] rabbit@ip-10-0-3-56.us-west-2.compute.internal: * connected to epmd (port 4369) on ip-10-0-3-56.us-west-2.compute.internal * epmd reports node 'rabbit' running on port 25672 * TCP connection succeeded but Erlang distribution failed * suggestion: hostname mismatch? * suggestion: is the cookie set correctly? * suggestion: is the Erlang distribution using TLS? current node details: - node name: 'rabbitmq-cli-41@q2' - home dir: /var/lib/rabbitmq - cookie hash: quN0y0GUm2Zxv8VYc2eX9A== root@q2:/# cat /var/lib/rabbitmq/.erlang.cookie ilikecookies root@q2:/# 

问题是你如何得到这些东西集群? 什么是缺less的成分? 错误信息在networking上没有任何意义。 有没有人有这方面的经验?

更新这些实例的AWS安全组:

 Custom TCP Rule TCP 1024 - 65535 0.0.0.0/0 

好,我知道了!

每个节点的主机名必须在容器内部排队。

在主机上(q2),我查看了hosts文件中知道的主机:

 # This file was generated by OpsWorks # any manual changes will be removed on the next update. # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts # OpsWorks Layer State 127.0.0.1 localhost.localdomain localhost 127.0.1.1 q2.localdomain q2 10.0.3.56 q1.localdomain q1 10.0.3.101 q2.localdomain q2 root@q2:/# ping q1 PING q1.local (10.0.3.56): 56 data bytes ^C--- q1.local ping statistics --- 2 packets transmitted, 0 packets received, 100% packet loss 

然后,我想到,主机知道什么并不重要,这是docker集装箱知道的。 所以,我把箱子装进箱子,做同样的事情:

 root@q2:/# cat /etc/hosts 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 172.17.0.2 q2.local 

现在我们正在做点什么! 所以,我添加了一个节点主节点的条目:

 root@q2:/# echo "10.0.3.56 q1.local q1" >> /etc/hosts root@q2:/# which ping /bin/ping root@q2:/# ping q1 PING q1.local (10.0.3.56): 56 data bytes 

然后,又在容器内摆动了一下

 root@q2:/# rabbitmqctl stop_app Stopping node rabbit@q2 ... root@q2:/# rabbitmqctl join_cluster rabbit@q1 Clustering node rabbit@q2 with rabbit@q1 ... root@q2:/# 

而现在,每个节点都认识到它是聚集的! 活泉!

我认为用docker进行集群我想修改docker命令,将hosts /etc/hosts文件挂载到docker映像中,用-v /etc/hosts:/etc/hosts:ro ,然后这应该只是神奇的

我忘了提到的另一个步骤:当地的Ubuntu盒子里有一个erlang的古老版本,我不得不删除它(也有兔子)。

此项目将自动化AWS ECS中的群集过程。 它应该使这个过程不那么痛苦,而且对失败更有弹性。
https://github.com/malawson/rabbitmq-ecs-autoclustering