启动两个rabbitmq 服务
sudo RABBITMQ_NODE_PORT=5672 RABBITMQ_DIST_PORT=15672 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15672}]" RABBITMQ_NODENAME=rabbit1 rabbitmq-server -detached
sudo RABBITMQ_NODE_PORT=5673 RABBITMQ_DIST_PORT=15673 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15673}]" RABBITMQ_NODENAME=rabbit2 rabbitmq-server -detached
5.我们以rabbit为主节点,剩下两个为从节点(在从节点执行以下命令,主节点不用动,-n指定具体那个节点)
[root@localhost mnesia]# rabbitmqctl -n rabbit2 stop_app
Stopping rabbit application on node rabbit2@localhost ...
[root@localhost mnesia]# rabbitmqctl -n rabbit2 reset
Resetting node rabbit2@localhost ...
[root@localhost mnesia]# rabbitmqctl -n rabbit2 join_cluster rabbit@`hostname -s`
Clustering node rabbit2@localhost with rabbit@localhost ...
[root@localhost mnesia]# rabbitmqctl -n rabbit2 start_app
Starting node rabbit2@localhost ...