1883,888 3 (if MQTT is enabled)Enable Firewall settings for corresponding ports
Add an EPEL Source
[Root @ node139 ~] # Rpm-Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Warning:/var/tmp/rpm-tmp.2hDPSr: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing... ################################### [100%]
Updating/installing...
1: epel-release-7-8 ################################# [100%]
Add an Erlang Source
[Root @ node139 ~] # Rpm-Uvh http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
Retrieving http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
Preparing... ################################### [100%]
Updating/installing...
1: erlang-solutions-1.0-1 ################################# [100%]
-- 06:34:38 -- http://packages.erlang-solutions.com/rpm/centos/erlang_solutions.repo
Resolving packages.erlang-solutions.com (packages.erlang-solutions.com)... 31.172.186.53
Connecting to packages.erlang-solutions.com (packages.erlang-solutions.com) | 31.172.186.53 |: 80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 245
Saving to: 'erlang _ solutions. repo'
100% [============================================== =========================================>] 245 --. -K/s in 0 s
06:34:39 (27.5 MB/s)-'erlang _ solutions. repo' saved [245/245]
Install RabbitMQ
Software Version: http://www.rabbitmq.com/releases/rabbitmq-server
[Root @ node139 ~] # Wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el7.noarch.rpm
[Root @ node139 ~] # Rpm -- import https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
[Root @ node139 ~] # Yum install rabbitmq-server-3.6.6-1.el7.noarch.rpm
Start the service
[Root @ node139 ~] # Systemctl enable rabbitmq-server.service
[Root @ node139 ~] # Systemctl start rabbitmq-server.service
Enable the RabbitMQ monitoring plug-in
[Root @ node139 ~] # Rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
Mochiweb
Webmachine
Rabbitmq_web_dispatch
Amqp_client
Rabbitmq_management_agent
Rabbitmq_management
Applying plugin configuration to rabbit @ node139... started 6 plugins.
[Root @ node139 ~] # Netstat-apn | grep 15672
Tcp 0 0 0.0.0.0: 15672 0.0.0.0: * LISTEN 4119/beam. smp
RabbitMQ user management
Add User (username root, password admin)
[Root @ node139 ~] # Rabbitmqctl add_user admin
Set User Role (set admin user as Administrator)
[Root @ node139 ~] # Rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator]...
Set User Permissions (set admin user configuration, write, and read permissions)
[Root @ node139 ~] # Rabbitmqctl set_permissions-p/admin ".*"".*"".*"
Setting permissions for user "admin" in vhost "/"...
Delete a user (delete a guest user)
[Root @ node139 ~] # Rabbitmqctl delete_user guest
RabbitMQ cluster configuration
The cluster is configured on the basis of the single-host configuration.
The following uses node140 as an example. node132 must perform the same operation.
Add:
192.168.190.132 node132
192.168.190.139 node139
192.168.190.140 node140
Rabbitmq clusters rely on erlang clusters. Therefore, you must first build an erlang cluster environment. Each node in the Erlang cluster is implemented through a magic cookie. This cookie is stored in/var/lib/rabbitmq/. erlang. cookie, and the file has 400 permissions. Therefore, ensure that the cookies of each node are consistent; otherwise, the communication between nodes fails.
[Root @ node140/] # echo-n "AZVOCZYZZBVFLBPTBXU">/var/lib/rabbitmq/. erlang. cookie
[Root @ node140 ~] # Chown rabbitmq: root/var/lib/rabbitmq/. erlang. cookie
[Root @ node140/] # chmod 600/var/lib/rabbitmq/. erlang. cookie
[Root @ node140/] # cat/var/lib/rabbitmq/. erlang. cookie
AZVOCZYZZBVFLBPTBXU
Start the service
[Root @ node140 ~] # Systemctl start rabbitmq-server.service
[Root @ node140 ~] # Rabbitmq-server-detached
Enable Firewall
[Root @ node140 ~] # Firewall-cmd -- permanent -- add-port = {4369/tcp, 25672/tcp}
Success
[Root @ node140 ~] # Firewall-cmd -- reload
Success
Set image policies[Root @ node140 ~] # Rabbitmqctl set_policy ha-all "^" '{"ha-mode": "all", "ha-sync-mode": "automatic "}'
Setting policy "ha-all" for pattern "^" to "{\" ha-mode \ ": \" all \ ", \" ha-sync-mode \": \ "automatic \"} "with priority" 0 "...
Enable the RabbitMQ monitoring plug-in
After the cluster is set up, if the "Node statistics not available" information is displayed in the Nodes section of the Overview of rabbitmq_management in the web management tool, the web management plug-in is not enabled on the Node.
[Root @ node140 ~] # Rabbitmq-plugins enable rabbitmq_management
After the cluster is configured, you can run the following command on any node of RabbitMQ to check whether the cluster configuration is successful.
[Root @ node140 ~] # Rabbitmqctl cluster_status
Other nodes must perform the same operation.
Log on to the website http: // 192.168.190.139: 15672/
Reference URL:Http://www.rabbitmq.com/clustering.html
Problems encountered during installation:
In this/var/lib/rabbitmq/. erlang. cookie file, you must modify the permission of the file owner and file to rw. Otherwise, the rabbitmq service cannot be started;