http://www.linuxhub.cn/2018/08/12/install-rabbitmq-cluster.html
rabbitmq集群安装:
1.安装erlang环境,安装mq
2.创建erlong.cookie文件(随意内容),复制集群各个node下/var/lib/rabbitmq/
3.执行加入集群命令
下面操作在任意一节点都可以
rabbitmqctl -n rabbit@GZ-V-L-MQ-12 stop_app
rabbitmqctl -n rabbit@GZ-V-L-MQ-12 reset
rabbitmqctl -n rabbit@GZ-V-L-MQ-12 join_cluster rabbit@GZ-V-L-MQ-11
rabbitmqctl -n rabbit@GZ-V-L-MQ-12 start_app
4.springboot配置:
#RabbitMQ单机
spring:
rabbitmq:
host: localhost
port: 5672
username: your_username
password: your_password
#RabbitMQ单机,只使用addresses
spring:
rabbitmq:
addresses: ip1:port1
username: your_username
password: your_password
#RabbitMQ集群,addresses一定要逗号分隔
spring:
rabbitmq:
addresses: ip1:port1,ip2:port2,ip3:port3
username: your_username
password: your_password
补充:集群节点模式:内存模式ram和硬盘模式disc,RAM节点仅将其元数据保留在内存中,如果群集停止,该节点的所有数据将会丢失。 为了提高性能,不需要所有节点都是disc的节点,所以启动一个节点为RAM模式。
rabbitmqctl -n rabbit@GZ-V-L-MQ-12 change_cluster_node_type ram
rabbitmqctl -n rabbit@GZ-V-L-MQ-12 change_cluster_node_type disc