RabbitMQ is a complete, edible enterprise messaging system based on the AMQP protocol standard. It follows the Mozilla Public License and is an industrial-grade message queue (MQ) server implemented by Erlang. Rabbit MQ is built on the Erlang OTP platform.
1. Install Erlang
Erlang will need to be installed before rabbitMQ can be installed.
Small series use OTP_win64_18.1, need other versions or 32-bit system, can go to the official website to download.
All you have to do is click “Next.”
Some choose other installation methods, may need to add the system environment variables (normal installation should also check) :
If you have it, add it manually.
2. Install the RabbitMQ
To run Rabbitmq-server-3.6.5, you can download rabbitmq-server-3.6.5 from rabbitmq-server.
You can still install without changing the default.
Note: The default listening port for RabbitMQ is 5672
Configuration of 3.
Enable RabbitMQ’s Management Plugin
The RabbitMQ management plug-in provides a better visual view of the state of the RabbitMQ server instance.
Open a command window:
Enter the command:
"C: \ Program Files \ the RabbitMQ Server \ rabbitmq_server - 3.6.5 \ sbin \ the RabbitMQ - plugins. Bat." " enable rabbitmq_management
Copy the code
Now that the plug-in is installed, is it ready to use? Don’t worry, you need to restart the service. Use the following command:
net stop RabbitMQ && net start RabbitMQ
Copy the code
At this point, the result may be:
“Error occurred: System error 5 occurred. Access is denied.”
What the hell is this? Check, it turns out that 5 stands for: not system administrator rights.
Solution: Use the administrator to open CMD and run this command:
Is that the end of it? Of course not.
Use the rabbitmqctl console command (located at C:\Program Files\RabbitMQ Server\rabbitmq_server-3.6.5\sbin>) to create users, passwords, bind permissions, etc.
Note: The installation path is different please see carefully ah.
User management for RabbitMQ includes adding users, deleting users, viewing user lists, and changing user passwords.
View existing users and their roles:
rabbitmqctl.bat list_users
Copy the code
Add a user:
rabbitmqctl.bat add_user username password
Copy the code
Now take a look at our current user ha:
Eric does not have “[administrator]” after it
What does the administrator do? This brings us to user roles:
As I understand it, rabbitMQ user roles fall into five categories: super administrator, monitor, policy maker, general manager and others.
(1) Super administrator
You can log in to the management console (with the Management Plugin enabled), view all information, and operate on users and policies.
(2) Monitoring
Log on to the management console (with the Management Plugin enabled) and view rabbitMQ node information (number of processes, memory usage, disk usage, etc.)
(3) Policymaker
You can log into the administrative console (with the Management Plugin enabled) and manage policies.
(4) General management
You can only log into the administrative console (with the Management Plugin enabled), and you cannot see node information or manage policies.
(5) other
Unable to log on to the administrative console, it is usually the ordinary producer and consumer.
Ok, let’s give Eric the role of “super administrator” as well:
rabbitmqctl.bat set_user_tags username administrator
Copy the code
Take a look at the results:
Of course, in addition to administrator, there are monitoring, Policymaker, Management, and custom names that correspond to the different roles described above.
Just like us, our roles are not only employees of the company, but also children of parents and parents of children. Users can also have multiple roles at the same time. Setting methods:
rabbitmqctl.bat set_user_tags username tag1 tag2 ...
Copy the code
Guest is an insecure password (its default password is guest). If you want to change the password, it is easy to do:
rabbitmqctl change_password userName newPassword
Copy the code
Guest: I’m not happy with the guest. I added a user administrator to the guest account.
rabbitmqctl.bat delete_user username
Copy the code
At this point, someone may ask: command box is only one user, how do you operate? How to check the execution of ah /
Of course there is a way:
Use a browser to go to http://localhost:15672 and log in to the RabbitMq management console using the account you have just created:
permissions
The user has the role, that also needs to set the permission ah, don’t worry, take your time:
According to the official document, user rights refer to user operation rights on Exchange and Queue, including configuration rights and read and write rights.
Configuring permissions affects the declaration and deletion of exchanges and queues.
Read and write permissions affect fetching messages from queues, sending messages to Exchanges, and binding operations between queues and Exchanges.
For example, to bind a queue to an exchange, you must have the write permission of the queue and the read permission of the Exchange. You must have exchange writable permission to send messages to Exchange. Fetching data from a queue requires the read permission of the queue
Permission related commands are as follows:
(1) Set user permissions
rabbitmqctl set_permissions -p VHostPath User ConfP WriteP ReadP
(2) View the permission information of all users (specified hostPath)
rabbitmqctl list_permissions [-p VHostPath]
(3) View the permission information of the specified user
rabbitmqctl list_user_permissions User
(4) Clear user permission information
rabbitmqctl clear_permissions [-p VHostPath] User
Now the environment is set up, users, roles and permissions are all set, and code is started (principle sorting, and coding to be continued).
Note: There is no hard work in the adult world