In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
I. brief introduction
MQ (Message Queue, message queue) is a message middleware, which is generally deployed in a cluster, which mainly provides message receiving and sending, and realizes message asynchronism among microservices.
1. Cluster principle
Rabbitmq is implemented according to the distributed characteristics of erlang (the underlying RabbitMQ is implemented through the Erlang architecture, so rabbitmqctl will start the Erlang node and use the Erlang system to connect the RabbitMQ node based on the Erlang node. The correct Erlang Cookie and node name are needed in the connection process, and the Erlang node exchanges Erlang Cookie to obtain authentication). Therefore, when deploying a rabbitmq distributed cluster, install erlang first and copy the cookie of one of the services to another node.
In the rabbitmq cluster, each rabbitmq is a peer node, that is, each node provides a client connection to receive and send messages. Nodes are divided into memory nodes and disk nodes, generally, they should be established as disk nodes, in order to prevent messages from disappearing after machine restart.
RabbitMQ's Cluster cluster mode is generally divided into two modes, normal mode and mirror mode. Message queuing replicates message queuing entities through rabbitmq HA mirror queues.
In normal mode, take two nodes (rabbit01, rabbit02) as examples to illustrate. For Queue, the message entity exists only on one of the nodes, rabbit01 (or rabbit02), and rabbit01 and rabbit02 have only the same metadata, that is, the structure of the queue. When the message enters the Queue of the rabbit01 node and the consumer is consumed from the rabbit02 node, RabbitMQ temporarily transmits the message between rabbit01 and rabbit02, takes out the message entity in An and sends it to consumer through B. So consumer should try to connect to each node and get messages from it. That is, for the same logical queue, a physical Queue is established on multiple nodes. Otherwise, no matter whether consumer is connected with rabbit01 or rabbit02, the export is always in rabbit01, which will create a bottleneck.
In mirror mode, the queues that need to be consumed are changed into mirror queues, which exist in multiple nodes, so that the HA high availability of RabbitMQ can be achieved. The effect is that message entities actively synchronize between mirrored nodes, rather than temporarily reading data when consumer consumes data, as in normal mode. The disadvantage is that the synchronous communication within the cluster will take up a lot of network bandwidth.
2. System architecture
Concept note:
Broker: it provides a transport service whose role is to maintain a route from producer to consumer, ensuring that data can be transmitted in a specified way.
Exchange: message switch, which specifies the rules by which messages are routed to which queue
Queue: the carrier of messages, where each message is thrown to one or more queues
Binding: binding, which binds exchange and queue according to routing rules
Routing Key: routing keyword according to which exchange delivers messages
Vhost: virtual host. There can be multiple vhost in a broker, which can be used to separate permissions for different users.
Producer: message producer, that is, the program that delivers messages
Consumer: the message consumer is the program that accepts the message.
Channel: message channel, in which multiple channel can be established in each connection of the client
II. Environmental preparation
1. System environment
Hostnam
System
IP
Use
Master
CentOS7.4
192.168.56.129
Disk node
Slave1
CentOS7.4
192.168.56.130
Memory node
Slave2
CentOS7.4
192.168.56.131
Memory node
2. Temporarily turn off the firewall and selinux
3. Set the hostname hosts of the three nodes
[root@master ~] # cat / etc/hosts
192.168.56.129 master
192.168.56.130 slave1
192.168.56.131 slave2
Third, build services
1. Install the latest repo source
[root@master ~] # yum-y install epel-release
2. Install the rabbitmq-server package with three nodes
[root@master ~] # yum-y install rabbitmq-server
3. View installed plug-ins
[root@master ~] # rabbitmq-plugins list
4. Start the management service (three nodes)
[root@master ~] # rabbitmq-plugins enable rabbitmq_management
5. Start the rabbitmq service (three nodes) respectively
[root@master ~] # systemctl start rabbitmq-server.service
Rabbitmq cluster deployment
1. Shut down the service (three nodes)
[root@master ~] # systemctl stop rabbitmq-server.service
2. Enter the cookie file directory and configure (each node needs to have the same sequence number value)
[root@master ~] # cd / var/lib/rabbitmq/
[root@master rabbitmq] # vim .erlang.cookie
3. Start the rabbitmq service again
[root@master rabbitmq] # systemctl start rabbitmq-server.service
4. Close the rabbitmq application (only close slave1 and slave2)
[root@master rabbitmq] # rabbitmqctl stop_app
5. Add slave1 and slave2 to master to make them a cluster. Start the application again
[root@slave1] # rabbitmqctl join_cluster-- ram rabbit@master
[root@slave1 ~] # rabbitmqctl start_app
6. Check the status of the rabbitmq server separately
[root@master ~] # rabbitmqctl cluster_status
7. Access RabbitMQ through the client browser (user name: guest password: guest)
Http://192.168.56.129:15672
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.