Centos7.3 Example of RabbitMQ distributed cluster setup
- 2020-09-16 07:54:58
- OfStack
This paper introduces the example of Centos7.3 RabbitMQ distributed cluster setup, which is Shared as follows:
Matters needing attention
centos 7.x closes firewall
3 machines:
172.17.250.97 rabbiMQ01
172.17.250.98 rabbiMQ03
172.17.250.99 rabbiMQ02
Configuration hosts
172.17.250.97 fz-rabbitMQ01
172.17.250.99 fz-rabbitMQ02
172.17.250.98 fz-rabbitMQ03
$ systemctl stop firewalld.service # stop firewall
Do not want to close the firewall, just open port 15672, after setting up can manage MQ via web
Install and install the iptables firewall
yum install iptables-services
Add the configuration
iptables -I INPUT -p tcp --dport 5672 -j ACCEPT
iptables -I INPUT -p tcp --dport 15672 -j ACCEPT
Save the configuration
service iptables save
restart
systemctl restart iptables.service
Set the boot to boot
systemctl enable iptables.service
The installation
Install Erlang
The RabbitMQ installation depends on the Erlang environment
$ cd /usr/local/src
$ wget http://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el7.centos.x86_64.rpm
$ yum install erlang-19.0.4-1.el7.centos.x86_64.rpm -y
Install RabbitMQ
$ cd /usr/local/src
$ wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el7.noarch.rpm
$ yum install rabbitmq-server-3.6.10-1.el7.noarch.rpm -y
Only rabbitMQ01 runs:
172.17.250.97 fz-rabbitMQ01
172.17.250.99 fz-rabbitMQ02
172.17.250.98 fz-rabbitMQ03
0
Run after
172.17.250.97 fz-rabbitMQ01
172.17.250.99 fz-rabbitMQ02
172.17.250.98 fz-rabbitMQ03
1
Check to see if rabbitmq starts properly.
Create clusters:
First, get a key authentication:
172.17.250.97 fz-rabbitMQ01
172.17.250.99 fz-rabbitMQ02
172.17.250.98 fz-rabbitMQ03
2
Read cookie for rabbitMQ01 node and copy to other nodes (nodes determine whether they can communicate with each other via cookie). cookie stored in/var/lib/rabbitmq /. erlang. cookie or $HOME /. erlang. cookie.
[root@fz-rabbitMQ01 src]# scp -PXXXXX /var/lib/rabbitmq/.erlang.cookie 172.17.250.99:/var/lib/rabbitmq
/etc/bashrc: line 94: soruce: No command found
.erlang.cookie 100% 20 0.0KB/s 00:00
[root@fz-rabbitMQ01 src]# scp -PXXXXX /var/lib/rabbitmq/.erlang.cookie 172.17.250.98:/var/lib/rabbitmq
/etc/bashrc: line 94: soruce: No command found
.erlang.cookie
Start node by node
172.17.250.97 fz-rabbitMQ01
172.17.250.99 fz-rabbitMQ02
172.17.250.98 fz-rabbitMQ03
4
Set up the cluster
Execute on rabbitMQ02 and rabbitMQ03, respectively
172.17.250.97 fz-rabbitMQ01
172.17.250.99 fz-rabbitMQ02
172.17.250.98 fz-rabbitMQ03
5
Finally, check the status information of the cluster through rabbitmqctl cluster_status:
172.17.250.97 fz-rabbitMQ01
172.17.250.99 fz-rabbitMQ02
172.17.250.98 fz-rabbitMQ03
6
During a visit to web (http: / / xxx. xxx. xxx. xxx: 15672), if the Nodes portion of the Overview see "Node statistics not available" information, instructions on the node web management plug-in is not enabled.
All three nodes need to be run:
172.17.250.97 fz-rabbitMQ01
172.17.250.99 fz-rabbitMQ02
172.17.250.98 fz-rabbitMQ03
7
Problems encountered
[
Error: unable to connect to node '[email protected]': nodedown
Solution: Execute the following two commands:
# /sbin/service rabbitmq-server stop
# /sbin/service rabbitmq-server start
Then execute it again: Ok
172.17.250.97 fz-rabbitMQ01
172.17.250.99 fz-rabbitMQ02
172.17.250.98 fz-rabbitMQ03
9