LinuxServicesIaaSOpenStack-Pike(3.搭建高可用消息队列)
Posted 炼狱腾蛇
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LinuxServicesIaaSOpenStack-Pike(3.搭建高可用消息队列)相关的知识,希望对你有一定的参考价值。
1. 简介
1.1. 官方网站: https://www.rabbitmq.com/
1.2. 配置文档:https://docs.openstack.org/ha-guide/shared-messaging.html#rabbitmq-configure
2. 安装与配置:
功能与组件 | 机器名 | 服务IP | 管理IP | Processor Cores | RAM | Storage | 备注 |
Mongo/Redis/RabbitMQ/Memorycached | HCTJOSCACHE01 | 10.30.2.45 | 172.16.0.45 | ||||
Mongo/Redis/RabbitMQ/Memorycached | HCTJOSCACHE02 | 10.30.2.46 | 172.16.0.46 | ||||
Mongo/Redis/RabbitMQ/Memorycached | HCTJOSCACHE03 | 10.30.2.47 | 172.16.0.47 |
2.1. 安装:在每个节点上都做
直接使用yum安装,openstack的yum源中会提供安装包
yum install rabbitmq-server
启动服务(确认cookie文件已经生成)
~]# systemctl start rabbitmq-server ~]# ll /var/lib/rabbitmq/.erlang.cookie -r-------- 1 rabbitmq rabbitmq 20 Dec 6 00:00 /var/lib/rabbitmq/.erlang.cookie
创建用户
#前面的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@hctjoscache02:/var/lib/rabbitmq/.erlang.cookie scp /var/lib/rabbitmq/.erlang.cookie root@hctjoscache03:/var/lib/rabbitmq/.erlang.cookie
在节点02/03上分别修改权限
# chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie # chmod 400 /var/lib/rabbitmq/.erlang.cookie
在节点01上启动服务并查看集群状态
[root@hctjoscache01 yum.repos.d]# systemctl start rabbitmq-server.service [root@hctjoscache01 yum.repos.d]# rabbitmqctl cluster_status Cluster status of node rabbit@hctjoscache01 ... [{nodes,[{disc,[rabbit@hctjoscache01]}]}, {running_nodes,[rabbit@hctjoscache01]}, {cluster_name,<<"rabbit@hctjoscache01.hccos.cn">>}, {partitions,[]}, {alarms,[{rabbit@hctjoscache01,[]}]}]
在节点02和03上启动服务,停止本机服务,加入01的集群(成功加入以后,再启动服务就不用执行stop_app了)
[root@hctjoscache02 ~]# systemctl start rabbitmq-server [root@hctjoscache02 ~]# rabbitmqctl stop_app Stopping node rabbit@hctjoscache02 ... [root@hctjoscache02 ~]# rabbitmqctl join_cluster --ram rabbit@hctjoscache01 Clustering node rabbit@hctjoscache02 with rabbit@hctjoscache01 ...
[root@hctjoscache03 ~]# systemctl start rabbitmq-server [root@hctjoscache03 ~]# rabbitmqctl stop_app Stopping node rabbit@hctjoscache03 ... [root@hctjoscache03 ~]# rabbitmqctl join_cluster --ram rabbit@hctjoscache01 Clustering node rabbit@hctjoscache03 with rabbit@hctjoscache01 ...
在01节点上查看状态
[root@hctjoscache01 yum.repos.d]# rabbitmqctl cluster_status Cluster status of node rabbit@hctjoscache01 ... [{nodes,[{disc,[rabbit@hctjoscache01]}, {ram,[rabbit@hctjoscache03,rabbit@hctjoscache02]}]}, {running_nodes,[rabbit@hctjoscache01]}, {cluster_name,<<"rabbit@hctjoscache01.hccos.cn">>}, {partitions,[]}, {alarms,[{rabbit@hctjoscache01,[]}]}]
配置一下ha的模式,我没太明白官方文档中的意思,不过看起来是说这样配置的话可以实现HA模式,消息可以镜像到其他的节点
rabbitmqctl set_policy ha-all \'^(?!amq\\.).*\' \'{"ha-mode": "all"}\'
以上是关于LinuxServicesIaaSOpenStack-Pike(3.搭建高可用消息队列)的主要内容,如果未能解决你的问题,请参考以下文章