单机创建集群
1.停用web管理插件
./rabbitmq-plugins disable rabbitmq_management
停用节点(如果有开启)
./rabbitmqctl stop_app
2.设置环境变量(端口号,web端口号),以后台方式启动
RABBITMQ_NODE_PORT=5672 RABBITMQ_NODENAME=rabbit RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15672}]" ./rabbitmq-server -detachedRABBITMQ_NODE_PORT=5673 RABBITMQ_NODENAME=hare RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15673}]" ./rabbitmq-server -detachedRABBITMQ_NODE_PORT=5674 RABBITMQ_NODENAME=hare1 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15674}]" ./rabbitmq-server -detached
三个节点已经启动,通过./rabbitmqctl cluster_status查看并没有在一个集群里。分别停用后面两个节点,然后加入到第一个集群,再重新启动
./rabbitmqctl -n hare stop_app./rabbitmqctl -n hare join_cluster rabbit@`hostname -s`./rabbitmqctl -n hare start_app
下面该hare1了,这里设置成磁盘节点
./rabbitmqctl -n hare stop_app./rabbitmqctl -n hare join_cluster --ram rabbit@`hostname -s`./rabbitmqctl -n hare start_app
最后通过./rabbitmqctl cluster_status查看状态:
踢出集群:
./rabbitmqctl -n hare1 stop_app
./rabbitmqctl forget_cluster_node hare1
加入集群:
./rabbitmqctl -n hare1 join_cluster --ram rabbit@`hostname -s`
./rabbitmqctl -n hare1 start_app
启动web管理插件
./rabbitmq-plugins -n rabbit enable rabbitmq_management
./rabbitmq-plugins -n hare enable rabbitmq_management
./rabbitmq-plugins -n hare1 enable rabbitmq_management