码迷,mamicode.com
首页 > 系统相关 > 详细

【Linux】【Services】【IaaS】OpenStack-Pike(3.搭建高可用消息队列)

时间:2018-02-12 20:06:02      阅读:273      评论:0      收藏:0      [点我收藏+]

标签:ror   des   https   mode   iaas   too   密码   gpo   赋权   

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】【IaaS】OpenStack-Pike(3.搭建高可用消息队列)

标签:ror   des   https   mode   iaas   too   密码   gpo   赋权   

原文地址:https://www.cnblogs.com/demonzk/p/8445208.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!