OpenStack使用消息队列来协调服务之间的操作和状态信息。消息队列服务通常在控制器节点上运行。OpenStack支持多种消息队列服务,包括RabbitMQ、Qpid和ZeroMQ。但是,大多数打包OpenStack的发行版都支持特定的消息队列服务
单机部署
1、安装与配置rabbitMQ,在控制节点(controller)执行以下操作
# yum -y install rabbitmq-server
2、设置开机自启动
# systemctl enable rabbitmq-server.service
# systemctl start rabbitmq-server.service
3、在rabbitMQ中添加用于openstack 的用户并授予管理员权限
添加用户
# rabbitmqctl add_user openstack openstack
设置openstack用户为管理员
# rabbitmqctl set_user_tags openstack administrator
允许openstack用户进行配置、写入和读取访问
# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
4、启用rabbitmq-manager 插件,开启Web控制台
# rabbitmq-plugins enable rabbitmq_management
# ss -tunlp |grep 5672
tcp LISTEN 0 128 *:25672 *:* users:(("beam.smp",pid=80178,fd=46))
tcp LISTEN 0 128 *:15672 *:* users:(("beam.smp",pid=80178,fd=57))
tcp LISTEN 0 128 [::]:5672 [::]:* users:(("beam.smp",pid=80178,fd=55))
5672 rabbitmq-server
15672 rabbitmq-ui
25672 集群
5、登录验证
http://192.168.58.100:15672
guest/guest (缺省账户)
openstack/openstack
集群部署
1、安装与配置rabbitMQ,在controller、compute01、compute02执行以下操作
# yum install rabbitmq-server -y
2、设置开机自启动
# systemctl enable rabbitmq-server.service
# systemctl start rabbitmq-server.service
查看监听端口:
netstat -lantp | grep 5672
3、在rabbitMQ中添加用于openstack 的用户并授予管理员权限
添加用户
# rabbitmqctl add_user openstack openstack
设置openstack用户为管理员
# rabbitmqctl set_user_tags openstack administrator
允许openstack用户进行配置、写入和读取访问
# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
4、编辑rabbittmq变量文件(所有主机)
# vim /etc/rabbitmq/rabbitmq-env.conf
RABBITMQ_NODE_PORT=5672
ulimit -S -n 4096
RABBITMQ_SERVER_ERL_ARGS="+K true +A30 +P 1048576 -kernel inet_default_connect_options [{nodelay,true},{raw,6,18,<<5000:64/native>>}] -kernel inet_default_listen_options [{raw,6,18,<<5000:64/native>>}]"
RABBITMQ_NODE_IP_ADDRESS=192.168.58.100
# 192.168.58.101
# 192.168.58.102
5、将rabbittmq变量文件拷贝到其他两节点,之后并修改相应节点的ip
# scp /etc/rabbitmq/rabbitmq-env.conf compute01:/etc/rabbitmq/
# scp /etc/rabbitmq/rabbitmq-env.conf compute02:/etc/rabbitmq/
查看rabbitmq插件
# /usr/lib/rabbitmq/bin/rabbitmq-plugins list
6、所有节点都开启rabbitmq的web管理页面
# rabbitmq-plugins enable rabbitmq_management
7、controller发送erlang.cookie到其他节点配置集群
# scp /var/lib/rabbitmq/.erlang.cookie compute01:/var/lib/rabbitmq/.erlang.cookie
# scp /var/lib/rabbitmq/.erlang.cookie compute02:/var/lib/rabbitmq/.erlang.cookie
8、compute01compute02停止应用,并以ram的方式加入controller节点,之后重启应用
# systemctl restart rabbitmq-server.service
# rabbitmqctl stop_app
# rabbitmqctl join_cluster --ram rabbit@controller
# rabbitmqctl start_app
9、检查集群状态
[root@controller ~]# rabbitmqctl cluster_status
Cluster status of node rabbit@controller
[{nodes,[{disc,[rabbit@controller]},
{ram,[rabbit@compute02,rabbit@compute01]}]},
{running_nodes,[rabbit@compute02,rabbit@compute01,rabbit@controller]},
{cluster_name,<<"rabbit@controller">>},
{partitions,[]},
{alarms,[{rabbit@compute02,[]},
{rabbit@compute01,[]},
{rabbit@controller,[]}]}]
登录验证:
http://192.168.58.100:15672
guest/guest (缺省账户)
openstack/openstack
其他命令:
(1)添加管理员:
rabbitmqctl add_user zhangsan zhangsan
rabbitmqctl set_user_tags zhangsan administrator
rabbitmqctl set_permissions -p / zhangsan ".*" ".*" ".*"
(2)更改节点类型(内存型或磁盘型)
rabbitmqctl stop_app
rabbitmqctl change_cluster_node_type disc 或 rabbitmqctl change_cluster_node_type ram
rabbitmqctl start_app
(3)从集群移除节点(或者重置节点)
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app
rabbitmqctl cluster_status
(4)从某个节点移除集群中其他节点
rabbitmqctl forget_cluster_node rabbit@node3
rabbitmqctl reset
rabbitmqctl start_app
rabbitmqctl cluster_status
1. 保证集群中至少有一个磁盘类型的节点以防数据丢失,在更改节点类型时尤其要注意。
2. 若整个集群被停掉了,应保证最后一个 down 掉的节点被最先启动,若不能则要使用 forget_cluster_node 命令将其移出集群
3. 若集群中节点几乎同时以不可控的方式 down 了此时在其中一个节点使用 force_boot 命令重启节点