How to install rabbitmq in Linux?When doing a microservice project, we use message queuing, so we have an in-depth understanding of message queuing knowledge, and installed rabbitmq on Linux. If you want to know more about message queuing, please refer to this article!
1. Update basic system
Before installing any packages, it is recommended that you use the following command to update packages and repositories
yum -y update
2. Install Erlang
Since rabbitmq is based onErlang (high concurrency oriented language)Language development, so before installing rabbitmq, you need to install Erlang first. In this tutorial, we will install the latest version of Erlang into the server. Erlang is not available in the default Yum repository, so you will need to install the EPEL repository. Run the same command as the following.
yum -y install epel-release yum -y update
yum -y install erlang socat
You can now check the Erlang version using the following command.
You will get the following output:
[[email protected] ~]# erl -version Erlang (ASYNC_THREADS,HIPE) (BEAM) emulator version 5.10.4
2. Install rabbitmq
Rabbitmq provides RPM packages for precompiled and directly installed Enterprise Linux systems. The only dependency needed is to install Erlang into the system. We have installed Erlang, and we can download rabbitmq further. Download Erlang RPM package by running.
2.1 download rabbitmq
If you don’t have WGet installed, you can run Yum – y install WGet. You can always find a link to the latest version of rabbitmq download page.
2.2 installing rabbitmq
Import the GPG key by running:
rpm –import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc
Run rpm to install the RPM package:
rpm -Uvh rabbitmq-server-3.6.10-1.el7.noarch.rpm
Rabbitmq is now installed on the system.
3. Using rabbitmq
systemctl start rabbitmq-server
Start up automatically
systemctl enable rabbitmq-server
systemctl status rabbitmq-server
4. Access the web console 4.1 to start the web console
Start rabbitmq web management console by running:
rabbitmq-plugins enable rabbitmq_management
Provide ownership of the rabbitmq file to the rabbitmq user by running the following command:
chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/
4.2 creating users
Now you will need to create an administrative user for the rabbitmq web administration console. Run the same command as the following.
rabbitmqctl add_user admin StrongPassword rabbitmqctl set_user_tags admin administrator rabbitmqctl set_permissions -p / admin “.*” “.*” “.*”
Change the administrator to the preferred user name of the administrator user. Make sure to change the strongpassword to a very strong password.
To access the administration panel of rabbitmq, use your favorite web browser and open the following URL.
5. Introduction of management interface
Login is required for the first visit. The default account password is:guest/guest
5.1. Home page
Connections: both producers and consumers need to establish a connection with rabbitmq before they can complete the production and consumption of messages. Here, you can view the connection status. Channels: channels. After the connection is established, channels will be formed, and the delivery and acquisition of messages depends on channels. Exchanges: switches are used to route messages. Queues: queues, that is, message queues. Messages are stored in queues for consumption, and queues are removed after consumption.
5.2. Add users
In fact, the tags option above specifies the user’s role. The following options are available:
You can log in to the management console, view all information, and operate users and policies.
Log in to the management console and view the related information of rabbitmq node (process number, memory usage, disk usage, etc.)
You can log in to the management console and manage the policy at the same time. But you can’t view the information about the node (the part marked by the red box above).
You can only log in to the management console, you can’t see the node information, and you can’t manage the policy.
Unable to log in to the management console, usually ordinary producers and consumers.
5.3. Create virtual hosts
In order to allow users to work without interference, rabbitmq adds the concept of virtual hosts. In fact, it is an independent access path. Different users use different paths and have their own queues and switches, which will not affect each other.
After creating a virtual host, we also need to add access rights to users
Click add virtual host:
Enter the virtual host settings interface:
The above is all about how to install rabbitmq in Linux. I hope it can help you. If you have time, you can come to developeppaer website. There are many other materials on our website waiting for partners to explore!