yum -y install make gcc gcc-c++ m4 ncurses-devel openssl-devel unixODBC-devel
wget http://erlang.org/download/otp_src_19.3.tar.gz
tar xzf otp_src_19.3.tar.gz
mkdir /usr/local/erlang
依次执行以下命令。
cd otp_src_19.3 ./configure --prefix=/usr/local/erlang --without-javac
make && make install
vi /etc/profile
export PATH=$PATH:/usr/local/erlang/bin
- 按下Esc键,然后输入:wq并回车,保存并关闭文件。
source /etc/profile
erl -version
wget -P /root "https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.9/rabbitmq-server-3.6.9-1.el7.noarch.rpm"
sudo rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc
cd /root sudo yum install rabbitmq-server-3.6.9-1.el7.noarch.rpm
6.为保证数据安全,建议您删除默认用户。
RabbitMQ默认的账号用户名和密码都是guest。
sudo rabbitmqctl delete_user guest
7. 搭建rabbitmq集群镜像模式
7.1 搭建rabbitmq集群前提条件 删除/var/lib/rabbitmq/mnesia下所有内容 rm -rf /var/lib/rabbitmq/mnesia/*
7.2 确保rabbitmq服务关闭 rabbitmqctl stop
7.3 启动rabbitmq三个实例
RABBITMQ_NODE_PORT=5672 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15672}] " RABBITMQ_NODENAME=rabbit1 rabbitmq-server -detached
RABBITMQ_NODE_PORT=5673 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15673}] " RABBITMQ_NODENAME=rabbit2 rabbitmq-server -detached
RABBITMQ_NODE_PORT=5674 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15674}] " RABBITMQ_NODENAME=rabbit3 rabbitmq-server -detached
7.4 将rabbit2加入集群,rabbit1为主节点,rabbit2为磁盘节点
rabbitmqctl -n rabbit2 stop_app
rabbitmqctl -n rabbit2 reset
rabbitmqctl -n rabbit2 join_cluster rabbit1@localhost
rabbitmqctl -n rabbit2 start_app
7.5 将rabbit3加入集群,rabbit1为主节点,rabbit3为RAM内存节点
rabbitmqctl -n rabbit3 stop_app
rabbitmqctl -n rabbit3 reset
rabbitmqctl n rabbit3 join_cluster rabbit1@localhost --ram
rabbitmqctl -n rabbit3 start_app
8.创建管理用户:
8.1 添加用户 rabbitmqctl add_user -n 节点(rabbit1) 用户 密码
8.2 添加权限 rabbitmqctl set_permissions -p "/" 用户 ".*" ".*" ".*"
8.3 修改用户角色 rabbitmqctl set_user_tags 用户 administrator
9. 查看集群状态
rabbitmqctl -n rabbit1 cluster_status
1.0. 主节点下设置策略:
[root@localhost haproxy]# rabbitmqctl -n rabbit1 set_policy -p my-vhost ha "^" ‘{"ha-mode":"all","ha-sync-mode":"automatic"}‘
三 基于普通集群部署镜像集群.
1.部署haproxy (要开启IP转发)
[root@localhost haproxy]# yum -y install haproxy
[root@localhost haproxy]# vim /etc/haproxy/haproxy.cfg
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
defaults
mode tcp
log global
option tcplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
retries 3 ###3次连接失败就认为服务不可用,也可以通过后面设置
listen stats
bind 0.0.0.0:1080 #监听端口
mode http
option httplog
stats refresh 5s #统计页面自动刷新时间
stats uri /stats #统计页面url
stats realm Haproxy Manager #统计页面密码框上提示文本
stats auth admin:admin #统计页面用户名和密码设置
listen rabbitmq_cluster
bind 0.0.0.0:1234
mode tcp
option tcplog
balance roundrobin
server MQ1 192.168.0.137:5672 check inter 5000 rise 2 fall 3
server MQ2 192.168.0.137:5673 check inter 5000 rise 2 fall 3
server MQ3 192.168.0.137:5674 check inter 5000 rise 2 fall 3
listen rabbitmq_admin
bind 0.0.0.0:12345
server MQ1 192.168.0.137:15672
server MQ2 192.168.0.137:15673
server MQ3 192.168.0.137:15674
[root@localhost haproxy]#systemct start haproxy
2.配置镜像队列:
界面查看: