Afen teaches you to avoid the pitfalls of installing RabbitMQ (command practice)

Afen teaches you to avoid the pitfalls of installing RabbitMQ (command practice)

This article is reprinted from the WeChat public account "Java Geek Technology", the author is Yaxue Fans. Please contact the Java Geek Technology public account for reprinting this article.

Some time ago, Afen wrote an article about how to install RabbitMQ and how to install RabbitMQ on Windows, but a fan asked, why don't you talk about installing RabbitMQ on Linux? I have failed to install it on Linux several times, and I don't know what the problem is. So Afen specially built a small cloud server, and planned to install RabbitMQ on his own cloud server and explain the installation commands to everyone in detail.

RabbitMQ Installation Preparation

If you have the conditions, you can rent a server on Alibaba Cloud and Huawei Cloud. The lowest configuration is enough for your own play. It is convenient to deploy small gadgets and the price is very cheap. Generally, it only costs 60 or 70 yuan to get it done for a year. For example, Afen spent 100 yuan to arrange a small cloud server, one from Alibaba Cloud and the other from Huawei Cloud, in order to experience the difference between them. The total cost is a little over 100 yuan. Let me show you the cloud server.

The configuration of the server is the lowest, it is an entry-level one for self-testing, you must buy it during the promotion, especially if you want to use it for fun yourself, you can pay attention to the promotion, without further ado, let's connect to our server and do it.

Remotely connect to your own cloud server

Afen uses XShell and XFtp to remotely connect to his cloud server. After the connection is completed, it looks like this.

Without further ado, let's start installing RabbitMQ. First of all, we know that RabbitMQ is developed in Erlang language, so no matter we install RabbitMQ under Windows or Linux, we need to install the Erlang language environment first, that is, install the Erlang environment.

RabbitMQ Installation

1. Upgrade all packages and also upgrade the software and system kernel

  1. yum -y update  

Here we need to upgrade all the packages, software and system kernel first. At this time, some people may ask why some teaching says to use yum -y upgrade. Afen here tells you that there is a difference between these two commands.

  • yum -y update upgrades all packages and also upgrades the software and system kernel
  • yum -y upgrade only upgrades all packages, not software and system kernel

If you execute yum -y update, then if nothing unexpected happens, the content of the update is generally more, and the second upgrade package does not upgrade the software and kernel command, so it is relatively faster to execute. However, Ah Fen uses his own cloud server, so at least the network speed must be faster than Ah Fen's local server. Upgrade!

2. Install EPEL YUM repository

  1. yum -y install epel-release

Why do we need to install this? Because when we use yum to install the software, we find that the software is not in our yum source, and then we need to wget it ourselves, then configure, make, make install

In CentOS, there is a source EPEL (Extra Packages for Enterprise) which contains many software and can meet most of our needs, so let's install it. After installation, we will upgrade it.

  1. yum -y update  

It’s the picture below.

Then we need to make up the Erlang environment

  1. yum -y install erlang socat

When Complete! appears, it means there is no problem. Since there is no problem, we should check whether the installation is successful.

  1. erl -version
  2.  
  3. Erlang/OTP 22 [erts-10.4.4] [source] [64- bit ] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]

We see that Erlang corresponds to OTP 22. At this time, we need to check the official website to see what version of RabbitMQ corresponding to Erlang needs us to download.

At this time, we have to download the corresponding version. Our Erlang environment is 22, so we have to download the corresponding version, otherwise, you cannot install RabbitMQ.

As shown below:

In other words, the versions we can choose from are only these: 3.7.27 / 3.7.26 / 3.7.25 / 3.7.24 / 3.7.23 / 3.7.22 / 3.7.21 / 3.7.20 / 3.7.19 / 3.7.18 / 3.7.17 / 3.7.16 / 3.7.15

At this time, we will arrange a wave for him and find a 3.7.26 installation package.

Before downloading, we have to see which version we want to download, because for different CentOS, you'd better download the corresponding version.

  1. cat /etc/centos-release

CentOS Linux release 8.4.2105

That is to say, what we need to download is the el8 type. Ah Fen downloaded this, rabbitmq-server-3.7.26-1.el8.noarch.rpm,

We upload to our cloud server via XFtp.

Then install it:

  1. rpm -Uvh rabbitmq-server-3.7.26-1.el8.noarch.rpm

Does this mean that we are done with the installation?

Let's start it and check the status.

  1. systemctl start rabbitmq-server

There is no problem. Let's take a look at the status.

  1. systemctl status rabbitmq-server

It seems that we have started it, so let's see if we can access it, IP:15672

We found that we couldn't access it, so we tried to turn off the firewall.

Turn off the firewall:

  1. systemctl stop firewalld.service

Disable firewall startup

  1. systemctl disable firewalld.service

View the default firewall status

  1. firewall-cmd --state  

It shows notrunning. We confirmed that it was turned off. After turning off the firewall, Ah Fan thought for a moment, maybe I didn't open the RabbitMQ web backend, so how can I access it?

  1. rabbitmq-plugins enable rabbitmq_management

At this time, I tried to access it again. It still didn't work. At this time, Ah Fen thought about it and wondered if the cloud server's security group blocked me. I had turned off all the firewalls, so why didn't it let me access the backend? So next we have to open the port in the security group.

Finally, finally, finally we see the picture we have been longing for. Do you think it ends here? No, it definitely not. We need to arrange an account and password, right? Otherwise, what’s the point if we can’t enter and see the backend.

  1. rabbitmqctl list_users
  1. Listing users ...
  2. user tags
  3. guest [administrator]

There is an administrator account, but we need to create our own account and grant it the above role.

  1. rabbitmqctl add_user xiaoyi xiaoyi
  2. rabbitmqctl set_user_tags xiaoyi administrator

This way we will have no problem logging in again.

At this point, we have finally installed RabbitMQ. Have you learned it?

<<:  What should you know about 5G technology? What will happen in the future?

>>:  KubeDL joins CNCF Sandbox to accelerate the cloud nativeization of AI industry

Recommend

5G messaging is entering a development phase

As one of the earliest attempts at 5G commercial ...

Talking about new IP technology in data centers

Ethernet technology, also known as IP technology,...

55 yuan = 199 yuan, do you understand the "routine" behind the telecom package?

Reporters found that while measures to benefit th...

What is the global development situation of IPv6?

Statistics from authoritative foreign organizatio...