RabbitMQ 高可用架构部署方案笔记

0. 部署架构简介

hostname ip role
host1 192.168.10.11 rabbitmq-master
host2 192.168.10.12 rabbitmq-slave

1. 安装软件

分别在host1host2上执行:

$ wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.0/rabbitmq-server-3.6.0-1.noarch.rpm
$ wget http://www.rabbitmq.com/releases/erlang/erlang-18.2-1.el7.centos.x86_64.rpm

$ rpm -ivh erlang-18.2-1.el7.centos.x86_64.rpm
$ rpm -ivh rabbitmq-server-3.6.0-1.noarch.rpm

2. 拷贝cookie

host1cookie复制到host2中去:

scp /var/lib/rabbitmq/.erlang.cookie host2:/var/lib/rabbitmq/.erlang.cookie

3. /etc/hosts

分别将host1host2/etc/hosts修改成下面这样:

192.168.10.11   host1
192.168.10.12   host2

4. 启动rabbitmq集群

host1上执行:

rabbitmq-server -detached

host2上执行:

rabbitmq-server -detached
rabbitmqctl stop_app
rabbitmqctl join_cluster --ram rabbit@hw13
rabbitmqctl start_app

5. 启动host1的web管理页面(可选)

$ rabbitmq-plugins enable rabbitmq_management
$ cat /etc/rabbitmq/rabbitmq.config
[{rabbit, [{loopback_users, []}]}].

6. 设置高可用策略

host1上执行(在host2上执行也行):

rabbitmqctl set_policy -p / ha-allqueue "^" '{"ha-mode":"all"}'

7. 利用keepalived或是haproxy实现rabbitmq主备的自动切换

8. ref

http://www.cnblogs.com/flat_peach/archive/2013/04/07/3004008.html

你可能感兴趣的:(高可用,rabbitmq,部署,HA)