安装rabbitmq
1 yum install -y erlang
备注:
2 wget
http://www.rabbitmq.com/releases/rabbitmq-server/v3.4.2/rabbitmq-server-3.4.2-1.noarch.rpm
yum install -y rabbitmq-server-3.4.2-1.noarch.rpm
3 chkconfig rabbitmq-server on
4 service rabbitmq-server restart
5 rabbitmq-plugins enable rabbitmq_management
(如发现RabbitMQ启动成功,但是Web不能访问到RabbitMQ控制台。则在dos窗口执行命令:rabbitmq-plugins.bat enable rabbitmq_management,然后再重启RabbitMQ即可通过Web访问到RabbitMQ控制台。)
6 rabbitmqctl change_password guest 123456
- 添加外部访问
/etc/rabbitmq/rabbitmq.config
[{rabbit, [{loopback_users, []}]}]. |
然后
remoteIP:15672
- 配置集群
web1机器:
chmod 777 /var/lib/rabbitmq/.erlang.cookie
scp root@web2:/var/lib/rabbitmq/.erlang.cookie .
chmod 400 /var/lib/rabbitmq/.erlang.cookie
分别重启web1,web2 rabbitmq
停止rabbitmq,每个机器分别执行
rabbitmq-server -detached
查看状态,应该都是自己
rabbitmqctl cluster_status
web1执行
rabbitmqctl stop_app
rabbitmqctl join_cluster --ram rabbit@web2
rabbitmqctl start_app
查看状态
rabbitmqctl cluster_status
Rabbit - Error: mnesia_unexpectedly_running解决
rabbitmqctl stop_app
rabbitmqctl reset
配置haproxy
yum install -y haproxy
vi /etc/haproxy/haproxy.cfg
listen rabbitmq_cluster 0.0.0.0:5672
mode tcp
balance roundrobin
server web1 10.144.169.225:5672 check inter 2000 rise 2 fall 3
server web2 10.161.47.79:5672 check inter 2000 rise 2 fall 3
cat /dev/null >
1.停止RabbitMQ应用,关闭节点
# rabbitmqctl stop
2.停止RabbitMQ应用
# rabbitmqctl stop_app
3.启动RabbitMQ应用
# rabbitmqctl start_app
4.显示RabbitMQ中间件各种信息
# rabbitmqctl status
5.重置RabbitMQ节点
# rabbitmqctl reset
# rabbitmqctl force_reset