Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of RabbitMQ deployment and principle in tens of millions of PV

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

RabbitMQ Introduction

MQ stands for Message Queue, which is an application-to-application communication method. Applications communicate by reading and writing messages (application-specific data) in and out of queues, without the need for dedicated connections to link them. Messaging refers to programs communicating with each other by sending data in messages, rather than by calling each other directly, which is often the technique used for things like remote procedure calls. Queue refers to applications communicating through queues. The use of queues eliminates the requirement that receiving and sending applications execute simultaneously.

RabbitMQ is a popular open source message queuing system developed in the erlang language. RabbitMQ is a standard implementation of AMQP (Advanced Message Queue Protocol).

RabbitMQ Principle Diagram

Exchange four matching patterns

fanout: Push the information sent by the producer to all queues bound to him;

direct: exact match, when routing key=binding key, send the information to the corresponding Queue;

topic: fuzzy matching, when some rules are satisfied, the information is sent to the corresponding Queue;

headers: does not depend on routing key, binding key matching rules, according to the message content headers attribute matching.

Introduction to key concepts

Broker: Simply put, a message queuing server entity.

Exchange: Message switch that specifies what rules messages are routed to and to which queue.

Queue: Message queue carrier, each message is put into one or more queues.

Binding: binding, its role is to bind exchange and queue according to routing rules.

Routing Key: The routing keyword, according to which exchange delivers messages.

vhost: Virtual host, multiple vhosts can be set up in a broker, which is used for the permission separation of different users.

producer: The program that delivers the message.

Consumer: A message consumer is a program that receives messages.

channel: Message channel, multiple channels can be established in each connection of the client, each channel represents a session task.

Message queues are used roughly as follows:

(1) The client connects to the message queue server and opens a channel.

(2) The client declares an exchange and sets related properties.

(3) The client declares a queue and sets related attributes.

(4) The client uses the routing key to establish a binding relationship between exchange and queue.

(5) The client sends messages to the exchange.

RabbitMQ experimental setup

Configuration information:

配置步骤:

一、更改主机名(防止启动服务时出现故障):

mq01/mq02/mq03:

vim /etc/hostname

mq01.localdomain

vim /etc/hosts

192.168.218.156 mq01

192.168.218.145 mq02

192.168.218.139 mq03

二、构建独立的服务器

mq01/mq02/mq03:

systemctl stop firewalld.service

setenforce 0

yum install epel-release -y

yum install rabbitmq-server -y

ln -s /usr/lib/rabbitmq/bin/* /usr/bin/

rabbitmq-plugins list //查看插件安装情况

rabbitmq-plugins enable rabbitmq_management //启用rabbitmq_management管理

systemctl start rabbitmq-server.service //开启服务

rabbitmqctl cluster_status //检查集群状态(主机名未解析会报error)

Cluster status of node rabbit@mq01 ...

[{nodes,[{disc,[rabbit@mq01]}]},

{running_nodes,[rabbit@mq01]},

{cluster_name,},

{partitions,[]}]

...done.

三、构建RabbitMQ群集

mq01/mq02/mq03:

systemctl stop rabbitmq-server.service

[root@mq01 ~]# cat /var/lib/rabbitmq/.erlang.cookie

FDFUVYLHUIERZZNQUKPM //同步三台cookie相同

systemctl start rabbitmq-server.service

内存节点 mq02/03

rabbitmqctl stop_app

rabbitmqctl join_cluster --ram rabbit@mq01 //以内存节点形式存在

rabbitmqctl start_app

rabbitmqctl cluster_status //检查集群状态

Cluster status of node rabbit@mq01 ...

[{nodes,[{disc,[rabbit@mq01]},{ram,[rabbit@mq03,rabbit@mq02]}]},

{running_nodes,[rabbit@mq03,rabbit@mq02,rabbit@mq01]},

{cluster_name,},

{partitions,[]}]

...done.

http://192.168.218.156:15672/ //登录磁盘节点服务器 //默认用户名:guest 密码:guest

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report