采用镜像队列的方案进行配置
1、 网络拓扑
node1:10.10.11.1
node2:10.10.11.2
2、 配置hosts
node1+node2:
vim /etc/hosts
>10.10.11.1 rab1
>10.10.11.2 rab2
3、 安装epel
node1+node2:
Centos 5.x
wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -Uvh epel-release-5*.rpm
Centos 6.x
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6*.rpm
4、 安装erlang
node1+node2:
yum install erlang
5、 下载rabbitMQ并安装
node1+node2:
yum install rabbitmq-server
【下载地址: http://www.rabbitmq.com/install-rpm.html
rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
yum install rabbitmq-server-3.3.5-1.noarch.rpm】
6、 运行rabbitMQ
node1+node2:
chkconfig rabbitmq-server on
service rabbitmq-server start
7、 确保节点使用相同的Erlang cookie文件
先停止两个节点的rabbitMQ
node1:
scp /var/lib/rabbitmq/.erlang.cookie \
root@rab2:/var/lib/rabbitmq/.erlang.cookie
8、 关闭防火墙
node1+node2:
service iptables stop
9、 配置rabbitMQ集群
node2:
rabbitmqctl stop_app
rabbitmqctl join_cluster rabbit@rab1
rabbitmqctl start_app
9、检测集群配置
rabbitmqctl cluster_status
10、配置镜像队列
rabbitmqctl set_policy HA '^(?!amq\.).*' '{"ha-mode": "all"}'
11、配置服务使用镜像队列
RabbitMQ HA cluster host:port pairs:
rabbit_hosts=rabbit1:5672,rabbit2:5672
How frequently to retry connecting with RabbitMQ:
rabbit_retry_interval=1
How long to back-off for between retries when connecting to RabbitMQ:
rabbit_retry_backoff=2
Maximum retries with trying to connect to RabbitMQ (infinite by default):
rabbit_max_retries=0
Use durable queues in RabbitMQ:
rabbit_durable_queues=false
Use HA queues in RabbitMQ (x-ha-policy: all):
rabbit_ha_queues=true
If you change the configuration from an old setup which did not use HA queues, you should interrupt the service:
# rabbitmqctl stop_app
# rabbitmqctl reset
# rabbitmqctl start_app
Services currently working with HA queues: OpenStack Compute, OpenStack Block Storage, OpenStack Networking, Telemetry.