RabbitMQ Introduction:
- 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 requiring a dedicated connection to link them. 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. Some of the more mature MQ products are IBM WEBSPHERE MQ and so on.
MQ Features
- MQ is a typical representative of the consumer-producer model, where one end writes messages to the message queue, while the other end reads or subscribes to messages in the queue. MQ is similar to JMS, but the difference is that JMS is a standard and API definition for the Sun Java Messaging Middleware Service, and MQ follows the specific implementations and products of the AMQP protocol.
RabbitMQ structure diagram:
- Exchange: A message switch that specifies what rules a message is routed to that queue.
- Queue: A Message Queuing vector in which each message is put into one or more queues.
- Routing key: The routing keyword, Exchange messages are delivered based on this keyword.
Use procedure for Message Queuing:
- 1. The client connects to the Message Queuing server and opens a channel (Message channel).
- 2. The client declares an Exchange and sets the related properties.
- 3. The client declares a Queue and sets the related properties.
- 4. The client uses Routing Key to establish a good binding relationship between Exchange and queue.
- 5. Clients post messages to Exchange.
The circumstances of the case:
Host name |
system |
IP Address |
Firewalls and SELinux |
Use |
Mq01 |
CentOS 7.3 |
192.168.217.137 |
Shut down |
Disk node |
Mq02 |
CentOS 7.3 |
192.168.217.138 |
Shut down |
Memory nodes |
Mq03 |
CentOS 7.3 |
192.168.217.139 |
Shut down |
Memory nodes |
RabbitMQ Cluster Deployment: 1. Modify all host names (restart effective):
systemctl stop firewalld.servicesetenforce 0vim /etc/hostname #其他两台相同mq01.localdomainvim /etc/hosts #添加192.168.217.137 mq01192.168.217.138 mq02192.168.217.139 mq03
2. Install the RABBITMQ service:
yum install -y epel-release #安装epel源yum install -y rabbitmq-server #安装rabbitmq服务
[[email protected] ~]# /usr/lib/rabbitmq/bin/rabbitmq-plugins list #查看插件安装信息[ ] amqp_client 3.3.5[ ] cowboy 0.5.0-rmq3.3.5-git4b93c2d[ ] eldap 3.3.5-gite309de4[ ] mochiweb 2.7.0-rmq3.3.5-git680dba8......
/usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management #启动群集管理服务
3. Configure the cluster features:
vim /var/lib/rabbitmq/.erlang.cookie#把mq01.erlang.cookie内容复制到mq02、mq03 systemctl restart rabbitmq-server.service #重启服务
4. Operate on mq02, mq03, and join the MQ01 cluster:
rabbitmqctl stop_app #关闭节点rabbitmqctl join_cluster --ram [email protected] #加入到磁盘节点rabbitmqctl start_app #开启节点
5. Verify the cluster Status:
[[email protected] ~]# rabbitmqctl cluster_status #查看状态Cluster status of node [email protected] ...[{nodes,[{disc,[[email protected]]},{ram,[[email protected],[email protected]]}]}, {running_nodes,[[email protected],[email protected],[email protected]]}, {cluster_name,<<"[email protected]">>}, {partitions,[]}]#磁盘节点为mq01,内存节点为mq02、mq03.
6.web Management:
Browser Access http://192.168.217.137:15672/#默认用户名: Guest Password: Guest
Tens of thousands of PV website RabbitMQ message Queue