标签:var yum源 user 分享 src ati aging 图片 多重
1. 简介
1.1. 官方网站: https://www.rabbitmq.com/
2. 安装与配置:
详见:https://docs.openstack.org/ha-guide/shared-messaging.html#rabbitmq-configure
2.1. 安装:在每个节点上都做
直接使用yum安装,openstack的yum源中会提供安装包
yum install rabbitmq-server
启动服务(确认cookie文件已经生成)
[root@hctjoscontroller01 ~]# systemctl start rabbitmq-server [root@hctjoscontroller01 ~]# ll /var/lib/rabbitmq/.erlang.cookie -r-------- 1 rabbitmq rabbitmq 20 Dec 6 00:00 /var/lib/rabbitmq/.erlang.cookie [root@hctjoscontroller01 ~]#
创建用户
#前面的openstack是用户名,后面的openstack是密码
rabbitmqctl add_user openstack openstack
Creating user "openstack" ...
赋权限
rabbitmqctl set_permissions openstack ".*" ".*" ".*" Setting permissions for user "openstack" in vhost "/" ...
停止rabbitMQ
systemctl stop rabbitmq-server
2.2. 配置
在节点01上,把cookie文件scp到另外两个节点上
scp /var/lib/rabbitmq/.erlang.cookie root@hctjoscontroller02:/var/lib/rabbitmq/.erlang.cookie scp /var/lib/rabbitmq/.erlang.cookie root@hctjoscontroller03:/var/lib/rabbitmq/.erlang.cookie
在节点02/03上分别修改权限
# chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie # chmod 400 /var/lib/rabbitmq/.erlang.cookie
在节点01上启动服务并查看集群状态
[root@hctjoscontroller01 ~]# systemctl start rabbitmq-server.service [root@hctjoscontroller01 ~]# rabbitmqctl cluster_status Cluster status of node rabbit@hctjoscontroller01 ... [{nodes,[{disc,[rabbit@hctjoscontroller01]}]}, {running_nodes,[rabbit@hctjoscontroller01]}, {cluster_name,<<"rabbit@hctjoscontroller01.homecredit.cn">>}, {partitions,[]}, {alarms,[{rabbit@hctjoscontroller01,[]}]}]
在节点02和03上启动服务,停止本机服务,加入01的集群(成功加入以后,再启动服务就不用执行stop_app了)
[root@hctjoscontroller02 ~]# systemctl start rabbitmq-server [root@hctjoscontroller02 ~]# rabbitmqctl stop_app Stopping node rabbit@hctjoscontroller02 ... [root@hctjoscontroller02 ~]# rabbitmqctl join_cluster --ram rabbit@hctjoscontroller01 Clustering node rabbit@hctjoscontroller02 with rabbit@hctjoscontroller01 ...
[root@hctjoscontroller03 ~]# systemctl stop rabbitmq-server [root@hctjoscontroller03 ~]# chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie [root@hctjoscontroller03 ~]# chmod 400 /var/lib/rabbitmq/.erlang.cookie [root@hctjoscontroller03 ~]# systemctl start rabbitmq-server [root@hctjoscontroller03 ~]# rabbitmqctl stop_app Stopping node rabbit@hctjoscontroller03 ... [root@hctjoscontroller03 ~]# rabbitmqctl join_cluster --ram rabbit@hctjoscontroller01 Clustering node rabbit@hctjoscontroller03 with rabbit@hctjoscontroller01 ...
在01节点上查看状态
[root@hctjoscontroller01 ~]# rabbitmqctl cluster_status Cluster status of node rabbit@hctjoscontroller01 ... [{nodes,[{disc,[rabbit@hctjoscontroller01]}, {ram,[rabbit@hctjoscontroller03,rabbit@hctjoscontroller02]}]}, {running_nodes,[rabbit@hctjoscontroller02,rabbit@hctjoscontroller03, rabbit@hctjoscontroller01]}, {cluster_name,<<"rabbit@hctjoscontroller01.homecredit.cn">>}, {partitions,[]}, {alarms,[{rabbit@hctjoscontroller02,[]}, {rabbit@hctjoscontroller03,[]}, {rabbit@hctjoscontroller01,[]}]}]
一定要保证能看见三个节点,我在配置过程中出现了下面的错误,多重启几遍就好了,以后再碰到再研究吧
[root@hctjoscontroller02 ~]# rabbitmqctl join_cluster --ram rabbit@hctjoscontroller01 Clustering node rabbit@hctjoscontroller02 with rabbit@hctjoscontroller01 ... Error: {inconsistent_cluster,"Node rabbit@hctjoscontroller01 thinks it‘s clustered with node rabbit@hctjoscontroller02, but rabbit@hctjoscontroller02 disagrees"}
配置一下ha的模式,我没太明白官方文档中的意思,不过看起来是说这样配置的话可以实现HA模式,消息可以镜像到其他的节点
rabbitmqctl set_policy ha-all ‘^(?!amq\.).*‘ ‘{"ha-mode": "all"}‘
【Linux】【Services】【Openstack】安装与部署(2. 消息队列)
标签:var yum源 user 分享 src ati aging 图片 多重
原文地址:http://www.cnblogs.com/demonzk/p/7994052.html