单机部署

1. 安装erlang

erlang1.9安装包

rpm -ivh erlang-19.3.6.1-1.el6.x86_64.rpm

2. 安装RabbitMQ

rpm -ivh rabbitmq-server-3.6.1-1.noarch.rpm

3. 设置环境变量

cd /etc/rabbitmq

vi rabbitmq-env.conf

1
2
3
MNESIA_BASE=/data/rabbitmq/mnesia
LOG_BASE=/data/log/rabbitmq
SERVER_ADDITIONAL_ERL_ARGS="+A 256"

chown rabbitmq:rabbitmq rabbitmq-env.conf

4. 创建对应的目录,并赋予权限

mkdir -p /data/rabbitmq/mnesia
mkdir -p /data/log/rabbitmq

cd /data
chown -R rabbitmq:rabbitmq rabbitmq

cd /data/log
chown -R rabbitmq:rabbitmq rabbitmq

5. 启动项目

rabbitmq-server -detached

6. 添加用户

rabbitmqctl add_user admin Pass1234

rabbitmqctl set_user_tags admin administrator

7. 启动MQ的UI管理界面

rabbitmq-plugins enable rabbitmq_management

集群部署

参考链接 RabbitMQ集群原理与部署

集群负载均衡 - haproxy部署

1. 安装HA

yum install haproxy

vi /etc/haproxy/haproxy.cfg

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#---------------------------------------------------------------------
global
maxconn 1000000
daemon
pidfile /var/run/haproxy/haproxy.pid
chroot /var/lib/haproxy
nbproc 8

defaults
mode tcp
option dontlognull
maxconn 1000000

listen rabbitcluster2
bind 0.0.0.0:5800
mode tcp
balance roundrobin
maxconn 1000000
timeout connect 5s
timeout client 8h
timeout server 8h
timeout tunnel 8h
option clitcpka
server mq-cluster1-012 xxx.xxx.0.132:5672 maxconn 1000000 check inter 5000 rise 2 fall 5
server mq-cluster1-013 xxx.xxx.0.129:5672 maxconn 1000000 check inter 5000 rise 2 fall 5
server mq-cluster1-011 xxx.xxx.0.131:5672 maxconn 1000000 check inter 5000 rise 2 fall 5
server mq-cluster1-014 xxx.xxx.0.130:5672 maxconn 1000000 check inter 5000 rise 2 fall 5
启动HaProxy

mkdir -p /var/run/haproxy/

/usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg