标签:取出 消息 群集 需要 src clu sys run 方便
Rabbitmq是目前流行的开源消息队列系统,用erlang语言开发。Rabbitmq是amqp(高级消息队列协议)的标准实现。群集非常方便,因为erlang天生就是一门分布式语言,但其本身并不支持负载均衡。首先我们需要配置三个节点的hosts文件,将如下内容分别加入到三台服务器上。
192.168.252.130 rabbitmq01
192.168.252.166 rabbitmq02
192.168.252.167 rabbitmq03
centos7-1(ip 192.168.252.130)
vim /etc/hostname //修改主机名
mq01.localdomain //删除原有内容并添加此内容
vim /etc/hosts
192.168.252.130 mq01
192.168.252.166 mq02
192.168.252.167 mq03
yum install -y epel-release
yum install -y rabbitmq-server
ln -s /usr/lib/rabbitmq//bin/* /usr/bin/
rabbitmq-plugins list //查看插件安装状况
rabbitmq-plugins enable rabbitmq_management //开启管理功能
systemctl start rabbitmq-server.service //开启服务
rabbitmqctl cluster_status //检查集群状态
Cluster status of node rabbit@mq01 ...br/>[{nodes,[{disc,[rabbit@mq01]}]},
{running_nodes,[rabbit@mq01]},br/>{cluster_name,<<"rabbit@mq01">>},
{partitions,[]}]
...done.
centos7-2(ip 192.168.252.166)
vim /etc/hostname //修改主机名
mq02.localdomain //删除原有内容并添加此内容
vim /etc/hosts
192.168.252.130 mq01
192.168.252.166 mq02
192.168.252.167 mq03
yum install -y epel-release
yum install -y rabbitmq-server
ln -s /usr/lib/rabbitmq//bin/* /usr/bin/
rabbitmq-plugins enable rabbitmq_management //开启管理功能
systemctl start rabbitmq-server.service //开启服务
rabbitmqctl cluster_status //检查集群状态
Cluster status of node rabbit@mq02 ...br/>[{nodes,[{disc,[rabbit@mq02]}]},
{running_nodes,[rabbit@mq02]},br/>{cluster_name,<<"rabbit@mq02">>},
{partitions,[]}]
centos7-3(ip 192.168.252.167)
vim /etc/hostname //修改主机名
mq03.localdomain //删除原有内容并添加此内容
vim /etc/hosts
192.168.252.130 mq01
192.168.252.166 mq02
192.168.252.167 mq03
yum install -y epel-release
yum install -y rabbitmq-server
ln -s /usr/lib/rabbitmq//bin/* /usr/bin/
rabbitmq-plugins enable rabbitmq_management //开启管理功能
systemctl start rabbitmq-server.service //开启服务
rabbitmqctl cluster_status //检查集群状态
Cluster status of node rabbit@mq03 ...br/>[{nodes,[{disc,[rabbit@mq03]}]},
{running_nodes,[rabbit@mq03]},br/>{cluster_name,<<"rabbit@mq03">>},
{partitions,[]}]
...done.
修改cookie
复制mq01的cookie序列号
vim /var/lib/rabbitmq/.erlang.cookie
AUKBYMMUHDEXPODERJIX
将其粘贴到另外两台服务器的cookie文件中
重启mq02,mq03的rabbitmq服务
systemctl stop rabbitmq-server.service
systemctl start rabbitmq-server.service
在02和03上操作内存节点
rabbitmqctl stop_app
rabbitmqctl join_cluster --ram rabbit@mq01
rabbitmqctl start_app
rabbitmqctl cluster_status
[{nodes,[{disc,[rabbit@mq01]},{ram,[rabbit@mq03,rabbit@mq02]}]},br/>{running_nodes,[rabbit@mq02,rabbit@mq01,rabbit@mq03]},
{cluster_name,<<"rabbit@mq01">>},
{partitions,[]}]
...done.
至此rabbitmq部署完成打开浏览器http://192.168.252.130:15672
显示该网页表示搭建成功
标签:取出 消息 群集 需要 src clu sys run 方便
原文地址:http://blog.51cto.com/13842738/2301202