搭建rabbitmq集群

网上有很多教程,可是步骤都缺的漏的,或者太笼统

环境:

Linux mqslave 2.6.32-504.16.2.el6.x86_64 #1 SMP Wed Apr 22 06:48:29 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)

ncurses-5.7.tar.gz

otp_src_17.5.tar.gz 

rabbitmq-server-generic-unix-3.5.3.tar.gz


安装目标环境上,有一个master和一个slave

1、先安装erlang,过程有点久;

2、解压rabbitmq;

3、在/etc/hosts 上配置域名解析,然后配置/etc/hostname, /etc/sysconfig/network更新主机名,重启生效;

4、将master机器上的$HOME/.erlang.cookie文件拷贝覆盖到slave的对应文件,两个节点才能通信;

5、rabbitqmq/etc/rabbitmq/rabbitmq.config配置;

两边都是:{cluster_nodes, {['rabbit@mqmaster','rabbit@mqslave'], disc}}。

也可以通过rabbitmqctl stop_app\rabbitmqctl join_cluster rabbit@mqmaster 这种命令行形式来添加。

6、rabbitmqctl stop、rabbitmq-server -detached;

通过http://yourip:15672/可以看到有两个节点!(得先./rabbitmq-plugins enable rabbitmq_management和解决账户登录的问题)。

7、配置policy

rabbitmqctl set_policy ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'


注意:

如果没配置好hostname可能导致:

[root@rabbit rabbitmq]# rabbitmqctl join_cluster rabbit@mqmaster
Clustering node rabbit@rabbit with rabbit@mqmaster ...
Error: unable to connect to nodes [rabbit@mqmaster]: nodedown

DIAGNOSTICS
===========

attempted to contact: [rabbit@mqmaster]

rabbit@mqmaster:
  * connected to epmd (port 4369) on mqmaster
  * 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-16082@mqslave'
- home dir: /root
- cookie hash: tfghv00J/Y3gQe1b8fkW9A==

你要是研究‘is the Erlang distribution using TLS’然后往配置ssl的方向解决问题,那就悲剧了。。。


你可能感兴趣的:(linux,环境架构)