rabbitmq集群的高可用

版权声明:版权声明:本博客欢迎转发,但请保留原作者信息! https://blog.csdn.net/wylfengyujiancheng/article/details/67077694

作者:吴业亮
博客:http://blog.csdn.net/wylfengyujiancheng

这里写图片描述

这里写图片描述

1、配置hosts文件

# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.8.66 node1
172.16.8.65 node2

2、设置集群防火墙

# firewall-cmd --add-port={4369/tcp,25672/tcp} --permanent 
success
# firewall-cmd --reload 
success

3、各个节点安装rabbitmq-server
1)、安装epel源

# yum install epel* -y

2)、安装rabbitmq-server

# yum --enablerepo=epel -y install rabbitmq-server

3)、启动rabbitmq-server并设置开机启动

# systemctl start rabbitmq-server 
# systemctl enable rabbitmq-server

4)、设置防火墙

# firewall-cmd --add-port=5672/tcp --permanent 
success
# firewall-cmd --reload 
success

4、同步密码

# ssh node02 'cat /var/lib/rabbitmq/.erlang.cookie' > /var/lib/rabbitmq/.erlang.cookie 
# systemctl restart rabbitmq-server

5、停止和重置应用

# rabbitmqctl stop_app 
Stopping node rabbit@node01 ...
...done.
# rabbitmqctl reset 
Resetting node rabbit@node01 ...
...done.

6、加入集群,只能识别主机名

# rabbitmqctl join_cluster rabbit@dlp 
Clustering node rabbit@node01 with rabbit@dlp ...
...done.

7、启动应用

# rabbitmqctl start_app 
Starting node rabbit@node01 ...
...done.

8、查看状态

# rabbitmqctl cluster_status 
Cluster status of node rabbit@node01 ...
[{nodes,[{disc,[rabbit@dlp,rabbit@node01]}]},
 {running_nodes,[rabbit@dlp,rabbit@node01]},
 {cluster_name,<<"rabbit@node02">>},
 {partitions,[]}]
...done.
展开阅读全文

没有更多推荐了,返回首页