搭建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的方向解决问题,那就悲剧了。。。


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值