In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Outline:
The Rabbitmq concept
II. Deployment of a single Rabbitmq
III. Deploying Rabbitmq Cluster
IV. Single node joining or exiting cluster configuration
The Rabbitmq concept
RabbitMQ is an open source AMQP protocol service, server-side written in Erlang language, supports a variety of clients, such as: Python, Ruby,. NET, Java, JMS, C, PHP, ActionScript, XMPP, STOMP, etc., supports AJAX. It is used to store and forward messages in distributed systems and performs well in terms of ease of use, scalability, high availability, etc.
AMQP (Advanced Message Queuing Protocol) is an open standard for application layer protocols designed for message-oriented middleware. Message middleware is mainly used for decoupling between components, and the sender of the message does not need to know the existence of the message consumer, and vice versa.
It enables the corresponding client to interact with the corresponding messaging broker. Message middleware publishers receive messages (applications that publish messages, also known as producers) and forward them to consumers (applications that process messages). Because AMQP is a network protocol, publishers, consumers, and messaging middleware can be deployed on different physical machines.
Rabbitmq usage scenarios
Message queues are commonly used in asynchronous processing, application decoupling, traffic clipping and message communication in practical applications.
II. Deployment of a single Rabbitmq
Note: Before starting, it is best to use the default localhosts for the host name (if not, an error will be reported when rabbitmq is started, workaround: restart the host and start rabbitmq again)
You can download the required software from the official website or download the rpm package from my network disk and upload it to the server by yourself.
The IP of the server below is 192.168.20.2.
[root@localhost src]# ls #Confirm required RPM package erlang-18.1-1.el6.x86_64.rpmrabbitmq-server-3.6.6-1.el6.noarch.rpmsocat-1.7.3.2-2.el7.x86_64.rpm[root@localhost src]# yum -y localinstall erlang-18.1-1.el6.x86_64.rpm rabbitmq-server-3.6.6-1.el6.noarch.rpm socat-1.7.x86_64.rpm#Install RPM package [root@ localhost src] localhost src]# chkconfig rabbitmq-server on #rabbitmq join boot boot [root@localhost src]# /etc/init.d/rabbitmq-server start #Start rabbitmq service
Make sure rabbitmq is running:
[root@localhost src]# ps -ef | grep rabbitmq
The above command returns the following result:
#Open rabbitmq's web administration plug-in so that it can be accessed via browser [root@localhost src]# rabbitmq-plugins enable rabbitmq_management#Create login user [root@localhost src]# rabbitmqctl add_user admin 123.com #Add admin user created to administrator group [root@localhost src]# rabbitmqctl set_user_tags admin administrator
The client accesses port 15672 of the rabbitmq server and logs in using the newly created admin user. After successful login, the following is displayed:
Successful access means that a single rabbitmq has been built.
III. Deploying Rabbitmq Cluster
Rabbitmq clustering can be divided into two ways:
1. Normal mode: default cluster mode, where the message corpse exists on only one node;
Mirror mode: Make the required queue mirror and exist in multiple nodes.
ha-mode:
all: queued to all nodes;exatly: randomly mirrored to other nodes;nodes: mirrored to specified nodes.
Cluster node mode:
1. Memory node: working on memory;
2. Disk nodes: work on disks;
Exception: Memory nodes and disk nodes co-exist, increasing access speed while increasing data persistence.
Compared with memory nodes, although they do not write to disks, they perform better than disk nodes. In a cluster, only one disk is needed to save state. If there are only memory nodes in the cluster, all state and messages will be lost once the nodes are down, and data persistence cannot be realized.
The deployment environment is as follows:
192.168.20.2 is based on the single rabbitmq above.
2. Install rabbitmq service
Do the following on nodes 192.168.20.3 and 20.4 (again after node 20.5) to deploy rabbitmq services:
#Upload required rpm package [root@localhost src]# ls erlang-18.1-1.el6.x86_64.rpmrabbitmq-server-3.6.6-1.el6.noarch.rpmsocat-1.7.3.2-2.el7.x86_64.rpm#install rabbitmq[root@localhost src]# yum -y localinstall erlang-18.1-1.el6.x86_64.rpm rabbitmq-server-3.6-1.el6.noarch.rpm socat-1.7.3.2-2.el7.x86_64.rpm #Start rabbitmq and join bootstrapping [root@localhost src]# /etc/init.d/rabbitmq-server start[root@localhost src]# chkconfig rabbitmq-server on3, configure host 192.168.20.2[root@localhost ~]# tail -4 /etc/hosts #Configure local resolution 192.168.20.2 rabbitmq01192.168.20.3 rabbitmq02192.168.20.4 rabbitmq03192.168.20.5 rabbitmq04#Copy hosts file to other nodes [root@localhost ~]# scp /etc/hosts root@192.168.20.3:/etc/[root@localhost ~]#scp/etc/hosts root@192.168.20.4:/etc/[root@localhost ~]# scp /etc/hosts root@192.168.20.5:/etc/#Copy the cookie node information of rabbitmq01 to other nodes that need to join the cluster #When deploying the cluster, the node cookie information needs to be consistent [root@ localhost ~]#scp/var/lib/rabbitmq/.erlang.cookie root@192.168.20.3:/var/lib/rabbitmq/.erlang.cookie root@192.168.20.4:/var/lib/rabbitmq/4. Restart all the node servers that want to join the cluster
Restart all servers you want to join the cluster by executing the following command (including rabbitmq01).
[root@localhost ~]# init 6 #After restart, you will find that the host name has been changed to the one defined in the hosts file
If you are stuck in an interface after restarting, you need to force a restart.
[root@rabbitmq01 ~]# ps -ef | grep rabbit #Confirm that it has started after restarting 5. Configure the cluster on rabbitmq01 [root@rabbitmq01 ~]# rabbitmqctl stop_app #Stop rabbitmq node service [root@rabbitmq01 ~]# rabbitmqctl reset #reset rabbitmq node [root@rabbitmq01 ~]# rabbitmqctl start_app #Starting rabbit node rabbit@rabbitmq01... #Copy the returned node name 6. Configure rabbitmq02, 03 to join rabbitmq01 cluster [root@rabbitmq02 ~]# rabbitmqctl stop_app #Stop node service [root@rabbitmq02 ~]# rabbitmqctl reset #reset node [root@rabbitmq02 ~]# rabbitmqctl join_cluster --ram rabbit@rabbitmq01 #Join cluster in memory, followed by node name of copied rabbitmq01 [root@rabbitmq02 ~]# rabbitmqctl start_app [root@rabbitmq02 ~]# rabbitmq-plugins enable rabbitmq_management7. Check node status on rabbitmq01 [root@rabbitmq01 ~]# rabbitmqctl cluster_status #View node status Cluster status of node rabbit@rabbitmq01... [{nodes,[{disc,[rabbit@rabbitmq01]}, {ram,[rabbit@rabbitmq03,rabbit@rabbitmq02]}]}, {running_nodes,[rabbit@rabbitmq03,rabbit@rabbitmq02,rabbit@rabbitmq01]}, {cluster_name,}, {partitions,[]}, {alarms,[{rabbit@rabbitmq03,[]}, {rabbit@rabbitmq02,[]}, {rabbit@rabbitmq01,[]}]}#rabbit01 Working mode is disk node; rabbit02 and 03 are memory node mode # running_nodes: running node # cluster_name: node name # alarms: alarm will be given when problems occur 8. Create management user in rabbitmq and join management group
Since the node is reset, the user needs to recreate it.
[root@rabbitmq01 ~]# rabbitmqctl add_user admin 123.com[root@rabbitmq01 ~]# rabbitmqctl set_user_tags admin administrator9. Log in to the web interface
Logins can be made on IP+15672 of any node in the cluster:
You can see information about cluster nodes on the following page:
10. Configure the web interface to add Vhost
Enter the virtual host created:
Then configure as follows:
Check the virtual host again after setup:
Set matching policy:
Release message:
Set the content of the published message:
Then refresh the current page to see the total number of queues in the current virtual host:
IV. Single node joining or exiting cluster configuration 1. Node joining cluster
Since the hosts file already resolves nodes within the cluster when I deployed the cluster above, parsing is omitted here
#Install rabbitmq on node 192.168.20.5 server and configure [root@localhost src]# yum -y localinstall erlang-18.1-1.el6.x86_64.rpm rabbitmq-server-3.6.6-1.el6.noarch.rpm socat-1.7.3.2-2.el7.x86_64.rpm [root @ localhost src]# chkconfig rabbitmq-server on[root@localhost src]# /etc/init.d/rabbitmq-server start#Copy cookie information from cluster to local [root@localhost src]# scp root@rabbitmq01:/var/lib/rabbitmq/.erlang.cookie /var/lib/rabbitmq/[root@localhost src]# init 6 #Restart Native #Join Cluster [root@rabbitmq04 ~]# rabbitmqctl stop_app[root@rabbitmq04 ~]# rabbitmqctl reset[root@rabbitmq04 ~]# rabbitmqctl join_cluster -ram rabbit@rabbitmq01#Join Cluster as memory run, to join as disk, Omit "--ram" option [root@rabbitmq04 ~]# rabbitmqctl start_app#Open web management page [root@rabbitmq04 ~]# rabbitmq-plugins enable rabbitmq_management
Check the web interface and confirm rabbitmq04 joins the cluster:
2. Single node exits cluster 1) Stop node [root@rabbitmq04 ~]# rabbitmqctl stop_app2) Go back to master node rabbitmq01 and delete node [root@rabbitmq04 ~]# rabbitmqctl -n rabbit@rabbitmq01 forget_cluster_node rabbit@rabbitmq04# -n: Specify node name # forget_cluster_node: followed by node name to be deleted
--------This article ends here, thanks for reading-------
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.