Install RabbitMQ on centos

1. Download the installation package

Since RabbitMQ relies on the erlang environment, you need to install **erlang first. **

Enter the RabbitMQ official website to view the MQ version and supported erlang version information.

RabbitMQ Erlang Version Requirements — RabbitMQ
image.png
I hope to choose the latest version 3.12.12, then my corresponding erlang version should be **26.2.x **.

Download RabbitMQ installation package

https://github.com/rabbitmq/rabbitmq-server/releases
Insert image description here

Download erlang installation package

image.png
Because my Linux is version 7, here is the installation package corresponding to version el7 and version 26.2.1.
https://github.com/rabbitmq/erlang-rpm/releases
image.png

2. Installation

File Upload

Upload the files to the /usr/local/software folder.
Insert image description here

Installation files

  • Install erlang environment
rpm -ivh erlang-26.2.1-1.el7.x86_64.rpm 

-i installation command
-vh prints the installation progress, optional

  • Install dependency packages. This step is to download content from the Internet, which requires the server to be able to connect to the external network.
yum install socat -y 
  • Install RabbitMQ
rpm -ivh rabbitmq-server-3.12.12-1.suse.noarch.rpm 

3. Start/Stop

  1. Turn on auto-start
chkconfig rabbitmq-server on 
  1. Check status
/sbin/service rabbitmq-server status 
  1. Start
/sbin/service rabbitmq-server start 
  1. Stop
/sbin/service rabbitmq-server stop 
  1. Open the web management page (if it is not opened, there will be no web page)
rabbitmq-plugins enable rabbitmq_management 

At this point you can access the web page. If you cannot access this website, the firewall may not be closed.

// View firewall status
systemctl status firewalld
// Turn off firewall
sytemctl stop firewalld
// Turn off firewall permanently
systemctl disable firewalld 

Then you can access
Insert image description here
At this time, the login prompt “User can only log in via localhost” is because the guest account has not been assigned web login permissions.

4. User management

View users and roles

rabbitmqctl list_users 

Insert image description here
See that there is only one guest user by default, and the role is administrator

Create an account

Here admin is the username and 123 is the password

rabbitmqctl add_user admin 123 

Insert image description here
Displaying the contents of the red box indicates that the addition is successful. The red box reminds you not to forget to set permissions.
Use the rabbitmqctl list_users command to see the newly added admin user.

Set user role

set_user_tags is to set the user role, admin is the user name, administrstor represents the administrator role

rabbitmqctl set_user_tags admin administrator 

Set user permissions

set_permissions is to set user permissions, the “/” after -p is to specify vhostpath, **** is to specify the user,* *< conf>** is the configuration permission, **< write>** is the write permission, **< read>** is the read permission

rabbitmqctl set_permissions [-p <vhostpath>] <user> <conf> <write> <read>
// Example, This command means,Grant "/" vhost DownadminAll user configurations,Read and write permissions
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*" 

You can log in successfully
Insert image description here

Add users through graphical interface

Insert image description here