This article will introduce four machines to build RABBITMQ clusters:
Rabbitmq
IP and hostname (per machine installed RABBITMQ 3.5.6, Erlang 18.1)
192.168.87.73 localhost73
192.168.87.74 localhost74
192.168.87.75 localhost75
192.168.87.76 localhost76
Add the above IP and host names to the Hosts file (vim/etc/hosts)
RABBITMQ clusters are dependent on Erlang's clusters to work, so you must first build a clustered environment of Erlang. The nodes in Erlang's cluster are implemented by a magic cookie, which is stored in/var/lib/rabbitmq/.erlang.cookie and the file is 400 privileged. Therefore, it is necessary to ensure that each node cookie is consistent, otherwise the nodes cannot communicate.
Set Cookie:vi/var/lib/rabbitmq/.erlang.cookie
In this example, assuming that the first node cookie is: ZTNMCISEYCEMUZMMHFAHABC, execute the following command at each node:
# chmod 700/var/lib/rabbitmq/.erlang.cookie
# echo-n "ZTNMCISEYCEMUZMMHFAHABC" >/var/lib/rabbitmq/.erlang.cookie
# chmod 400/var/lib/rabbitmq/.erlang.cookie
Open the cluster communication port on the firewall
Start firewall: Systemctl start Firewalld.service
# Firewall-cmd--permanent--add-port={4369/tcp,25672/tcp,5672/tcp}
# Firewall-cmd--reload
Component clusters
We use localhost73 as the primary node and execute the following command on localhost74:
localhost74 # Rabbitmqctl Stop_app
localhost74 # rabbitmqctl Join_cluster [email protected]
localhost74 # Rabbitmqctl Start_app
Then, the localhost75 and localhost76 are executed sequentially.
Change node Properties
#rabbitmqctl stop_app– Stop RABBITMQ Service
#rabbitmqctl Change_cluster_node_type disc– Change node to disk node
Rabbitmqctl Change_cluster_node_type ram– change node to memory node
#rabbitmqctl start_app– Open RABBITMQ Service
In this example we will change the main node localhost73 to a disk node, so that we have completed the cluster, such as:
View cluster status
RABBITMQ Web Management plug-in starts
Rabbitmq-plugins Enable rabbitmq_management start
Rabbitmq-plugins Disable rabbitmq_management off
After opening we can access RABBITMQ Web management, Access address: http://192.168.87.73:15672, user name password: guest,guest
If you do not have a native access then you need to add a new user, because the guest this user can only be in the local access, so we want to add a user and give permission.
Add Web Admin user
Add User: Rabbitmqctl add_user admin 123456
Add Permissions: Rabbitmqctl set_permissions-p "/" admin ". *" ". *" ". *"
Modify User Role Rabbitmqctl set_user_tags admin Administrator
After adding the user login by address http://192.168.87.73:15672 and the username and password you just created, you can view the cluster we configured:
Web management view Clusters
Turn from
http://www.toutiao.com/i6461441222467650061/
Introduction to RABBITMQ Cluster construction method (test machine Linux CentOS) "Turn"