我正在设置一个rabbitmq群集,并在此过程的一个步骤中遇到问题。它直接来自rabbitmq聚类指南。
root@celery:~# rabbitmqctl status
Status of node celery@celery ...
[{pid,20410},
{running_applications,[{rabbit,"RabbitMQ","2.5.1"},
{os_mon,"CPO CXC 138 46","2.2.4"},
{sasl,"SASL CXC 138 11","2.1.8"},
{mnesia,"MNESIA CXC 138 12","4.4.12"},
{stdlib,"ERTS CXC 138 10","1.16.4"},
{kernel,"ERTS CXC 138 10","2.13.4"}]},
{os,{unix,linux}},
{erlang_version,"Erlang R13B03 (erts-5.7.4) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},
{memory,[{total,25296704},
{processes,9680280},
{processes_used,9662720},
{system,15616424},
{atom,1099393},
{atom_used,1082732},
{binary,89768},
{code,11606637},
{ets,726848}]}]
...done.
root@celery:~# rabbitmqctl cluster_status
Cluster status of node celery@celery ...
[{nodes,[{disc,[celery@celery]}]},{running_nodes,[celery@celery]}]
...done.
root@celery:~# rabbitmqctl stop_app
Stopping node celery@celery ...
...done.
root@celery:~# rabbitmqctl reset
Resetting node celery@celery ...
...done.
root@celery:~# rabbitmqctl cluster worker1@worker1
Clustering node celery@celery with [worker1@worker1] ...
Error: {failed_to_cluster_with,[worker1@worker1],
"Mnesia could not connect to some nodes."}
一个节点无法连接到另一个节点的可能原因是什么?
以下是我关注的指南:http://www.rabbitmq.com/clustering.html
答案 0 :(得分:5)
我跳进了freenode上的#rabbitmq频道。以下是后面的讨论:
14:29 shakakai: hey all, i'm having a little issue with clustering rabbitmq http://stackoverflow.com/questions/6948624/mnesia-cant-connect-to-another-node
14:30 shakakai: has anyone run into that problem before?
14:30 daysmen has left IRC (Read error: Connection reset by peer)
14:30 antares_: shakakai: make sure that epmd is running on every node
14:30 antares_: shakakai: and that port it uses (4369) is open in your firewall
14:31 |Blaze|: shakakai: is your dns correct? Can you ping worker1 from celery and celery from worker1
14:31 shakakai: |Blaze|: hmm...i'll check
14:31 daysmen has joined (~quassel@host-84-13-157-50.opaltelecom.net)
14:32 shakakai: |Blaze|: this is where I'm a little confused, the rabbitmq nodename is worker1@worker1 but the fqdn to ping the box is "ping worker1.mydomain.com"
14:33 |Blaze|: can you "ping worker1"
14:34 shakakai: |Blaze|: no
14:34 |Blaze|: k, you'll need to fix that
14:34 hyperboreean has left IRC (Ping timeout: 250 seconds)
14:37 shakakai: |Blaze|: gotcha, so I setup a hosts file and i should be good
14:37 |Blaze|: yup
14:37 |Blaze|: in both directions
TL; DR
确保您可以从正在聚类的每个框中ping兔子节点名称。如果不能,请为每个兔子节点设置主机文件。
答案 1 :(得分:1)
我安装Docker RabbitMQ的过程中也遇到了类似的问题。
主要原因是/var/lib/RabbitMQ/mnesia/rabbit/cluster_nodes.config
上的错误配置文件无法连接。
Mnesia是用Erlang编程语言编写的分布式,软实时数据库管理系统
有几种方法可以解决此问题:
rabbit@cb43449d5d72
// log info
...
rabbitmq | Starting broker...2019-11-27 16:18:22.621 [info] <0.304.0>
rabbitmq | node : rabbit@cb43449d5d72
...
// This is the wrong configuration file:
$ cat ./mnesia/rabbit/cluster_nodes.config
{[rabbit@cb43449d5d72,rabbit@dc3288264c34],[rabbit@dc3288264c34]}.
// Update it with correctly config node name, and restart RabbitMQ server:
$ cat ./mnesia/rabbit/cluster_nodes.config
{[rabbit@cb43449d5d72],[rabbit@cb43449d5d72]}.
mnesia
目录并配置正确的node
名称,该名称与rabbit@my-rabbit
中/etc/hosts
中的127.0.0.1 my-rabbit
类似,$ find . -name cluster_nodes.config
./mnesia/rabbit/cluster_nodes.config
./mnesia/rabbit@my-rabbit/cluster_nodes.config
$ cat ./mnesia/rabbit@my-rabbit/cluster_nodes.config
{['rabbit@my-rabbit'],['rabbit@my-rabbit']}.
操作,您应该会看到以下配置详细信息$a = intval("-945");
$b = floatval('9.45')*100;
$c = $a + $b;
var_dump($a);
var_dump($b);
var_dump($c);
$a = intval("-355");
$b = floatval('3.55')*100;
$c = $a + $b;
var_dump($a);
var_dump($b);
var_dump($c);
答案 2 :(得分:0)
在让群集运行良好之前,有几件事需要检查: 0)确保在每个节点上运行完全相同的rabbitmq版本 1)设置网络,直到您能够互相ping每个服务器 2)cookies - 你必须在每台服务器上的.erlang.cookie文件中获得完全相同的erlang cookie 一个技巧是有用的是从一个节点尝试此命令,看看你是否可以从rabbitmq到达另一个节点 rabbitmqctl eval'net_adm:ping(rabbit @ othernode)。'
如果没有问题,这应该说是Pang,如果它是nok或pong 小心不要忘记接近eval表达式末尾的点。经过几个小时的试验失败后,我的工作正常。
3)请记住,如果此节点不是最后一个停止的节点,则重新启动群集节点时可能会出现问题 - 它不会在最后一次停止重新启动之前启动。 当以上所有(0到2)都正确时,3可能是你问题的根本原因......
希望这个帮助, 干杯, JB
答案 3 :(得分:-1)
我读过的一件事是,erlang cookie需要在所有集群节点上,以便它们可以进行通信。我相信它存在于/var/lib/rabbitmq/.erlang.cookie
中