RABBITMQ Cluster Detailed

Source: Internet
Author: User
Tags node server rabbitmq

RABBITMQ Introduction 1, What is RABBITMQ?

MQ is all called MessageQueue, and Message Queuing (MQ) is an application-to-application communication method. Applications communicate by writing and retrieving data (messages) for applications that enter and leave the queue, without requiring a private connection to link them.
RabbitMQ is an open-source implementation of the AMQP (Advanced Message Queuing Protocol) developed by the Erlang language. RabbitMQ belongs to the message middleware, which is mainly used for decoupling between components, the sender of the message need not know the existence of the message consumer, and vice versa.

2. RABBITMQ Features
  • Reliability (Reliability)
    RabbitMQ uses a number of mechanisms to ensure reliability, such as persistence, transmission acknowledgement, and release acknowledgement.
  • Flexible routing (Flexible Routing)
    The message is routed through Exchange before the message enters the queue.
  • Message cluster (clustering)
    Multiple RabbitMQ servers can form a single cluster, forming a logical Broker.
  • High Availability (highly Available Queues)
    Queues can be mirrored on machines in a cluster so that queues are still available in the event of a partial node problem.
  • Multiple protocols (multi-protocol)
    RabbitMQ supports a variety of Message Queuing protocols, such as STOMP, MQTT, and so on.
  • Multi-lingual Client (many clients)
    RabbitMQ supports almost all common languages, such as Java,. NET, Ruby, and so on.
  • Management interface (Management UI)
    RabbitMQ provides an easy-to-use user interface that enables users to monitor and manage many aspects of message Broker.
  • Tracking mechanism (tracing)
    If the message is abnormal, RabbitMQ provides a message tracking mechanism that the consumer can use to find out what happened.
  • Plug-in mechanism (Plugin system)
    RabbitMQ provides a number of plugins to extend from a variety of ways, or to write your own plugins. 3, the internal structure of RABBITMQ

  • Message
    Message, the message is not named, and it consists of the message header and the message body.
  • Publisher
    The producer of the message, and also a client application that publishes messages to the exchanger.
  • Exchange
    A switch that receives messages sent by producers and routes them to queues in the server.
  • Binding
    Bindings, which are used for associations between message queues and switches.
  • Queue
    Message Queuing, which is used to hold messages until they are sent to consumers. It is the container of the message and the end of the message. One message can be put into one or more queues.
  • Connection
    A network connection, such as a TCP connection.
  • Channel
    Channel, a separate two-way data flow channel in a multiplexed connection.
  • Consumer
    The consumer of the message, which represents a client application that obtains the message from the message queue.
  • Virtual Host
    A virtual host that represents a batch of switches, message queues, and related objects. A virtual host is a stand-alone server domain that shares the same authentication and encryption environment.
  • Broker
    Represents a Message Queuing server entity. RABBITMQ Application Rabbit Application Mode

    Single mode
    Normal mode (default cluster mode)
    Mirroring mode (queue as a mirrored queue with multiple nodes present)
    RABBITMQ cluster nodes include memory nodes, disk nodes, and support message persistence, that is, data written on disk.

Rabbit Working process

(1) The client connects to the Message Queuing server and opens a 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.
(6) Exchange receives messages based on the key of the message and the binding already set, the message is routed, the message is posted to the queues, and the two applications communicate.

RABBITMQ Deployment Experiment Description:

There are three servers in one cluster, one using Disk mode and two in memory mode. The client connects two memory mode servers through the front-end reverse proxy. Note Connect the three servers to the Internet and install the packages.

Lab Environment:
Host name Operating System IP Address Use
Mq01 CentOS7 192.168.37.128 Disk node
Mq02 CentOS7 192.168.37.130 Memory nodes
Mq03 CentOS7 192.168.37.131 Memory nodes
Experimental process:

++++++ three servers the same operation ++++++
1. Turn off the firewall and security features

Systemctl Stop Firewalld.service
Setenforce 0

2, first modify the host name and hosts file of three servers

hostnamectl set-hostname mq01bashvim /etc/hosts192.168.37.128 mq01192.168.37.130 mq02192.168.37.131 mq03




3. Yum installation package

Yum install-y epel-release #epel为扩展软件包
Yum install-y rabbitmq-server #rabbitmq软件包

4. Establishing a soft connection

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

5. Check the installation of plugins

Rabbitmq-plugins List


6. Open Management Service

Rabbitmq-plugins Enable Rabbitmq_management

7. Open RABBITMQ Service

Systemctl Start Rabbitmq-server.service
Netstat-ntap |grep 5672


8. View the respective cluster status

Rabbitmqctl Cluster_status

Mq01

Mq02

Mq03

9, close the service, copy the configuration file and then open

Systemctl Stop Rabbitmq-server.service
Hidden files, like three configurations, copy the contents of the file on the disk node to the other 2
Vim/var/lib/rabbitmq/.erlang.cookie
Systemctl Start Rabbitmq-server.service


++++++ the following operations on the memory node ++++++
1. Add mq02, mq03 memory node servers to the disk nodes separately

Rabbitmqctl Stop_app
Rabbitmqctl join_cluster--ram [email protected] #加入到磁盘节点
#ram: Added as a memory node without disk
Rabbitmqctl cluster_status #验证集群状态

Mq02

Mq03

2. View the cluster status of the MQ01 disk node server

Rabbitmqctl Cluster_status


++++++rabbit Graphical Operation ++++++
1. Log on to the disk node server

http://192.168.37.128:15672/Default User: Guest Password: Guest


2. Create a policy on a disk node server

Name:my_ha
Pattern: ^a
Apply To:exchange and queues
Definition:ha-mode All


3. View policy (three server synchronization)
Mq01

Mq02

Mq03

4. Increase Message Queuing on the disk node server
Name:aa
Durabiliy:durable
Node: [Email protected]
Auto Delete:no

5. Write a message in the new queue
Mode:2-persistent
HEADERS:A = 123
Properties:id=1
payload:hello,world!

6. View Queue messages

RABBITMQ Cluster Detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.