🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
:-: ![](https://img.kancloud.cn/ed/a9/eda9d3c507ea15d5061cc8d39bbd0875_1321x417.jpg) RabbitMQ集群架构 <br/> 步骤如下: **1. 准备三台安装好RabbitMQ的机器** ![](https://img.kancloud.cn/2d/c4/2dc4dc7e7fc63f6a4ccc87c2800e91ae_1548x260.jpg) **2. 修改三台机器的主机名,分别命名为`node1`、`node2`、`node3`** ```shell # vim /etc/hostname ``` **3. 在三台机器上都做如下主机映射** ```shell # vim /etc/hosts 192.168.0.109 node1 192.168.0.112 node2 192.168.0.113 node3 ``` **4. 重启三台机器** ```shell # reboot ``` **5. 让三台机器的cookie保证一致** ```shell -- 在node1节点执行下面的命令 # scp /var/lib/rabbitmq/.erlang.cookie root@node2:/var/lib/rabbitmq/.erlang.cookie # scp /var/lib/rabbitmq/.erlang.cookie root@node3:/var/lib/rabbitmq/.erlang.cookie ``` **6. 分别启动三台机器的RabbitMQ服务和Erlang虚拟机** ```shell # rabbitmq-server -detached ``` **7. 在node2节点执行下面的命令** ```shell # rabbitmqctl stop_app # rabbitmqctl reset # rabbitmqctl join_cluster rabbit@node1 # rabbitmqctl start_app ``` **8. 在node3节点执行下面的命令** ```shell # rabbitmqctl stop_app # rabbitmqctl reset # rabbitmqctl join_cluster rabbit@node2 # rabbitmqctl start_app ``` **9. 在任意一台机器上执行`rabbitmqctl cluster_status`可以查看集群状态** ```shell # rabbitmqctl cluster_status Cluster status of node rabbit@node1 ... Basics Cluster name: rabbit@node1 Disk Nodes rabbit@node1 rabbit@node2 rabbit@node3 Running Nodes rabbit@node1 rabbit@node2 rabbit@node3 Versions rabbit@node1: RabbitMQ 3.8.8 on Erlang 21.3 rabbit@node2: RabbitMQ 3.8.8 on Erlang 21.3 rabbit@node3: RabbitMQ 3.8.8 on Erlang 21.3 Maintenance status Node: rabbit@node1, status: not under maintenance Node: rabbit@node2, status: not under maintenance Node: rabbit@node3, status: not under maintenance ... ``` **10. 在任意一台机器上创建用户** ```shell # rabbitmqctl add_user admin admin # rabbitmqctl set_user_tags admin administrator # rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*" ``` **11. 登录WEB界面** 使用任意节点的 ip 登录,比如这里用node1的 ip:http://192.168.0.109:15672 登录,用户名一律为`admin`,密码一律为`admin`。 ![](https://img.kancloud.cn/bd/66/bd66ad75e4cde50bd924ca4fd3d1e10d_1909x1020.png)