Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a RabbitMQ distributed cluster in Centos7.3

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about how to build a RabbitMQ distributed cluster in Centos7.3. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.

Matters needing attention

Centos 7.x shuts down firewall

Three machines:

172.17.250.97 rabbiMQ01172.17.250.98 rabbiMQ03172.17.250.99 rabbiMQ02

Configure hosts

172.17.250.97 fz-rabbitMQ01172.17.250.99 fz-rabbitMQ02172.17.250.98 fz-rabbitMQ03 $systemctl stop firewalld.service # stop firewall

If you don't want to turn off the firewall, open port 15672. After setting it, you can manage MQ through web pages.

Install iptables Firewall

Yum install iptables-services

Add configuration

Iptables-I INPUT-p tcp-- dport 5672-j ACCEPTiptables-I INPUT-p tcp-- dport 15672-j ACCEPT

Save configuration

Service iptables save

Restart

Systemctl restart iptables.service

Set Boot self-boot

Systemctl enable iptables.service

Installation

Install Erlang

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:

Rabbitmq-server-detached

Run after

Rabbitmqctl status

Check to see if rabbitmq starts properly.

Create a cluster:

First, do a key authentication:

[root@fz-rabbitMQ01 src] # ssh-keygen [root@fz-rabbitMQ01 src] # ssh-copy-id-pXXXXX-I ~ / .ssh/id_rsa.pub [email protected] [root@fz-rabbitMQ01 src] # ssh-copy-id-pXXXXX-I ~ / .ssh/id_rsa.pub [email protected]

Read the cookie of the rabbitMQ01 node and copy it to other nodes (nodes use cookie to determine whether they can communicate with each other). The cookie is 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: command .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: command .erlang.cookie not found

Start nodes one by one

Rabbitmq-server-detached

Set up a cluster

Just execute it on rabbitMQ02 and rabbitMQ03 respectively.

Rabbitmqctl stop_app rabbitmqctl reset rabbitmqctl join_cluster rabbit@fz-rabbitMQ01 rabbitmqctl start_app

Finally, check the status information of the cluster through rabbitmqctl cluster_status:

[root@fz-rabbitMQ01 src] # rabbitmqctl cluster_statusCluster status of node 'rabbit@fz-rabbitMQ01' [{nodes, [{disc, [' rabbit@fz-rabbitMQ01','rabbit@fz-rabbitMQ02', 'rabbit@fz-rabbitMQ03']}]}, {running_nodes, [' rabbit@fz-rabbitMQ03','rabbit@fz-rabbitMQ02', 'rabbit@fz-rabbitMQ01']}, {cluster_name,}, {partitions, []}, {alarms, [{' rabbit@fz-rabbitMQ03', []} {'rabbit@fz-rabbitMQ02', []}, {' rabbit@fz-rabbitMQ01', []}]

When accessing web (http://xxx.xxx.xxx.xxx:15672), if you see the message "Node statistics not available" in the Nodes section of the Overview, the web management plug-in is not enabled on that node.

All three nodes need to run:

[root@fz-rabbitMQ01 src] # rabbitmq-plugins enable rabbitmq_managementThe following plugins have been enabled: amqp_client cowlib cowboy rabbitmq_web_dispatch rabbitmq_management_agent rabbitmq_managementApplying plugin configuration to rabbit@fz-rabbitMQ01... Started 6 plugins.

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: you can

Rabbitmqctl stop_app rabbitmqctl reset rabbitmqctl join_cluster rabbit@fz-rabbitMQ01 rabbitmqctl start_app above is how to build a RabbitMQ distributed cluster in Centos7.3. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report