RabbitMQ集群安装 RabbitMQ
程序员文章站
2022-07-13 14:57:49
...
首先参考上一篇文章【CentsOS原生RabbitMQ安装过程】在两到三台机器上先安装单独的RabbitMQ节点
修改一下hostname
1 2 3 4 |
[root@rnode1 ~]# vim /etc/hosts 172.16.20.110 rnode1 172.16.20.111 rnode2 172.16.20.112 rnode3 |
erlang节点之间通信需要相同的cookie文件,将其中一个机器上的cookie文件copy到另外两个机器
1 2 |
scp /var/lib/rabbitmq/.erlang.cookie rnode2:/var/lib/rabbitmq scp /var/lib/rabbitmq/.erlang.cookie rnode3:/var/lib/rabbitmq |
首先在rnode1上观察一下节点状态如下
1 2 3 4 5 6 7 |
[root@rnode1 ~]# rabbitmqctl cluster_status Cluster status of node rabbit@rnode1 [{nodes,[{disc,[rabbit@rnode1]}]}, {running_nodes,[rabbit@rnode1]}, {cluster_name,<<"rabbit@rnode1" }, {partitions,[]}, {alarms,[{rabbit@rnode1,[]}]}] |
分别在rnode2、rnode3上执行以下命令使其与rnode1组成集群
1 2 3 4 5 6 |
[root@rnode2 ~]# rabbitmqctl stop_app Stopping rabbit application on node rabbit@rnode2 [root@rnode2 ~]# rabbitmqctl join_cluster --ram rabbit@rnode1 Clustering node rabbit@rnode2 with rabbit@rnode1 [root@rnode2 ~]# rabbitmqctl start_app Starting node rabbit@rnode2 |
随便选择一台集群观察节点状态发现集群已经搭建完毕
1 2 3 4 5 6 7 |
[root@rnode3 ~]# rabbitmqctl cluster_status Cluster status of node rabbit@rnode3 [{nodes,[{disc,[rabbit@rnode1]},{ram,[rabbit@rnode3,rabbit@rnode2]}]}, {running_nodes,[rabbit@rnode2,rabbit@rnode1,rabbit@rnode3]}, {cluster_name,<<"rabbit@rnode1" }, {partitions,[]}, {alarms,[{rabbit@rnode2,[]},{rabbit@rnode1,[]},{rabbit@rnode3,[]}]}] |
安装过程中可能会出现如下问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@rnode1 ~]# rabbitmqctl status Status of node rabbit@rnode1 Error: unable to connect to node rabbit@rnode1: nodedown DIAGNOSTICS =========== attempted to contact: [rabbit@rnode1] rabbit@rnode1: * connected to epmd (port 4369) on rnode1 * epmd reports: node 'rabbit' not running at all no other nodes on rnode1 * suggestion: start the node current node details: - node name: 'rabbitmq-cli-01@rnode1' - home dir: /var/lib/rabbitmq - cookie hash: DGMyi0De4NLhiCnlJmHsTg== |
此问题停止RabbitMQ的服务再重新启动即可解决
1 2 |
rabbitmq-server stop rabbitmq-server -detached |
推荐阅读
- SpringCloud学习系列汇总
- 为什么一线大厂面试必问redis,有啥好问的?
- 多线程面试必备基础知识汇总
- Java集合源码分析汇总-JDK1.8
- Linux常用命令速查-汇总篇
- JVM系列文章汇总
- MySQL系列文章汇总
博客所有文章首发于公众号《Java学习录》转载请保留
扫码关注公众号即可领取2000GJava学习资源
上一篇: tomcat查看并修改jvm大小
下一篇: RabbitMQ高级面试题