This article provides a brief note on the RabbitMq setup
The role of MQ (Message Que)
- Asynchronous: Improves service response speed.
- Decoupling: Moving logical processing to queues. When the consumption logic is modified, only the Consumer is changed, not the Producer
- Automatic compensation and retry: MQ automatically retries sending messages after a consumption failure.
- Guaranteed consumption order: The queue itself is a first-in, first-out (FIFO) feature that can consume messages based on the order in which they enter the queue
- Peak clipping: This is similar to asynchrony, except that it is designed to reduce the amount of concurrency that the consumer is experiencing at any given moment
RabbitMQ, Kafka, RocketMQ, etc.
Refer to the following article: Messaging-middleware deployment and comparison: rabbitMQ, activeMQ, zeroMQ, rocketMQ, Kafka, Redis
The main advantages of RabbitMQ:
- The erLang language naturally supports high concurrency
- MQ environment is relatively easy to set up
- There is a good message confirmation mechanism and message persistence
- Highly customizable routing policies
- Page management is convenient, high community activity
The RabbitMQ of actual combat
Install RabbitMQ in CentOS7
Official documentation for installation and use in various environments
-
Install Erlang environment wget HTTP: / / https://github.com/rabbitmq/erlang-rpm/releases/download/v22.2/erlang-22.2-1.el7.x86_64.rpm Download the latest Erlang package, the current version is 22.2, because the latest version of RabbitMQ is 3.8.1. # yum install wget yum install wget # yum install wget
-
Download the RPM package for rabbitMQ (CentOS7, if CentOS8, Change el7 in connection to EL8) wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.1/rabbitmq-server-3.8.1-1.el7.noarch.rpm
-
Install rabbitmq-server-3.8.1-1.el7.noarch. RPM yum install rabbitmq-server-3.8.1-1.el7.noarch. RPM
-
Start RabbitMQ chkconfig rabbitmq-server on /sbin/service rabbitmq-server start /sbin/service Rabbitmq-server stop /bin/systemctl start rabbitmq-server.service The rabbitmq – server. # service shut down
-
Rabbitmqctl list_users rabbitmqctl list_users rabbitmq-plugins enable rabbitmq_management rabbitmqctl list_users
[root@c5 ~]# rabbitmqctl list_users Listing users ... user tags guest [administrator] Copy the code
So we need to manually add a user, Rabbitmqctl add_user admin 123456 rabbitmqctl set_user_tags admin administrator # set permissions
Then you can log in using the admin account
P: Port number function
Conclusion:
- ErLang version problems during installation
- UI and port issues
- Login user and permission assignment problems
problems
-
The user interface (UI) has been rejected for port 15672 (default queue: port 5672, UI: port 15672). The user interface (UI) has been rejected for port 15672
Solutions:This is because the current UI plug-in has not been started, just run the following command.
Rabbitmq-plugins enable rabbitmq_management
-
The guest account has access restrictions.
Solutions:You need to manually create an account for him. Then we need to manually add a user, and set the user permissions to Administrator
Rabbitmqctl add_user admin 123456
Rabbitmqctl set_user_tags admin administrator # Set permission
Then you can log in using the admin account