RabbitMQ集群部署
程序员文章站
2022-07-12 12:17:46
...
机器:三台
系统:centos7
node03:172.25.91.30 node01: 172.25.91.31 node02: 172.25.91.32
#Install RabbitMQ cluster on CentOS 7
三台主机都操作如下:
修改hosts
vim /etc/hosts
172.25.91.30 rabbitmq01
172.25.91.31 rabbitmq02
172.25.91.32 rabbitmq03
yum -y install epel-release
yum -y update
wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
yum -y install erlang socat logrotate
#Install RabbitMQDownload RabbitMQ package
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.8/rabbitmq-server-3.8.8-1.el6.noarch.rpm
rpm --import https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
rpm -Uvh rabbitmq-server-3.8.8-1.el6.noarch.rpm
systemctl start rabbitmq-server
systemctl enable rabbitmq-server
ipatbles添加端口:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 4369 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 25672 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5672 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 15672 -j ACCEPT
system restart iptables
选择一台作为master
操作以下:
scp /var/lib/rabbitmq/.erlang.cookie [email protected]:/var/lib/rabbitmq/
scp /var/lib/rabbitmq/.erlang.cookie [email protected]:/var/lib/rabbitmq/
4.slave操作:
添加 主节点
kill -9 rabbitmq-server端口
systemctl start rabbitmq-server.service
rabbitmqctl stop_app
rabbitmqctl join_cluster [email protected]
rabbitmqctl start_app
rabbitmqctl cluster_status #查询集群状态
master 操作
#RabbitMQ Web Management Console Enable RabbitMQ web management console
rabbitmq-plugins enable rabbitmq_management
chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/ #Modify file permissions
rabbitmqctl add_user admin password #Create an admin user (Change password to a strong password)
rabbitmqctl set_user_tags admin administrator #Make admin user and administrator
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*" #Make admin user and administrator
#To access the RabbitMQ admin
http://Your_Server_IP:15672
#RabbitMQ Setup Queue Mirroring
rabbitmqctl set_policy ha-all ".*" '{"ha-mode":"all"}'
rabbitmqctl set_policy ha-two "^two\." '{"ha-mode":"exactly","ha-params":2,"ha-sync-mode":"automatic"}'
rabbitmqctl set_policy ha-nodes "^nodes\." '{"ha-mode":"nodes","ha-params":["[email protected]", "[email protected]"]}'
查询策略
rabbitmqctl list_policies;
删除策略
rabbitmqctl clear_policy ha-two
上一篇: RabbitMQ集群部署
下一篇: HDU 4310 Hero【贪心】