A brief introduction of RABBITMQ PV website architecture
What is RABBITMQ?
MQ is all called the message queue, and Message Queuing (MQ) is an application-to-application communication method. Applications communicate by reading and writing messages to and from the queue (data for the application) without having to connect them with private links. Message passing refers to the process of communicating between programs by sending data in a message, rather than by directly invoking each other, and directly invoking techniques such as remote procedure calls. Queuing refers to an application communicating through a queue. The use of queues removes the requirement that both the receiving and sending applications execute concurrently.
RABBITMQ a description of several key concepts:
Broker: The Message Queuing server entity is simply the case.
Exchange: A message switch that specifies what rules the message is routed to and to which queue.
Queue: A message queue carrier in which each message is put into one or more queues.
Binding: Bind, which is the role of binding exchange and queue according to routing rules.
Routing key: The routing keyword, exchange messages are delivered based on this keyword.
Vhost: Virtual host, a broker can open multiple vhost, as a separate user permissions.
Producer: The message producer is the program that delivers the message.
Consumer: The message consumer is the program that receives the message.
Channel: The message channels, in each connection of the client, multiple channels can be established, each channel represents a session task.
Use of Message Queuing process:
(1), the client connects to the Message Queuing server and opens a channel (Message channel).
(2), the client declares an Exchange (message switch), and sets the related properties.
(3), the client declares a queue (Message queue carrier), and sets the related properties.
(4), the client uses a routing key (the routing keyword) to establish a binding relationship between Exchange and queue.
(5), client post message to Exchange.
When Exchange receives a message, it routes messages to one or more queues based on the key of the message and the binding that has been set.
RABBITMQ Usage Scenarios
RABBITMQ supports the persistence of messages, which means that the data is written on disk.
The persistence of Message Queuing consists of 3 parts:
1. Exchange persistence, specify durable=>1 when declaring.
2. Queue persistence, specify durable=>1 when declaring.
3. Message persistence, specify DELIVERY_MODE=>2 (1 non-persistent) on delivery.
Practical Application of RABBITMQ
The RABBITMQ model is roughly divided into the following three types:
1, single mode.
2, Normal mode (the default cluster mode).
3, mirroring mode (to make the required queue into a mirror queue, exist in multiple nodes, belongs to the HA scheme of RABBITMQ, in the case of high business reliability requirements are more practical).
Experimental deployment
Host name |
IP Address |
system Use |
Centos7-1 (MQ01) |
172.16.10.138 |
Disk node |
Centos7-2 (MQ02) |
172.16.10.147 |
Memory nodes |
Centos7-5 (MQ03) |
172.16.10.146 |
Memory nodes |
- Set the hosts resolution file for each server to add the following content
Vim/etc/hosts
172.16.10.138 RabbitMQ01172.16.10.147 RabbitMQ02172.16.10.146 RabbitMQ03
- Set the hostname for each server
Mq01.localdomain #依次为mq02 mq03
- Configure installation of Epel source with RABBITMQ
Yum-y Install Epel-release
- Installing RABBITMQ software using the Yum repository
Yum Install-y rabbitmq-server
- Related configuration and opening service
/usr/lib/rabbitmq/bin/rabbitmq-plugins list #查看插件安装情况/usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management #启用rabbitmq_management服务systemctl start rabbitmq-server #开启服务rabbitmqctl cluster_status #检查三台的集群状态,目前相互独立,没有形成集群。Cluster status of node [email protected] ...[{nodes,[{disc,[[email protected]]}]}, {running_nodes,[[email protected]]}, #可以看到此时,是并没有集群的 {cluster_name,<<"[email protected]">>}, {partitions,[]}]...done
- Cluster deployment (configured on two memory nodes)
rabbitmqctl stop_apprabbitmqctl join_cluster --ram [email protected] #加入到磁盘节点rabbitmqctl start_app rabbitmqctl cluster_status #验证集群状态
- Webpage login RABBITMQ Web Management Page view
RABBITMQ of PV website architecture