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

Implementation method of deploying rabbitmq Cluster in docker

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

Share

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

Pull rabbitmq management image

Docker pull rabbitmq:3.7-rc-management

If you do not use the management feature of Rabbitmq, you can pull the image: rabbitmq:3.7-rc

Reference: https://hub.docker.com/_/rabbitmq/

Create a network

Create a rabbitmq VPC

# docker network create rabbitmqnet# docker network lsNETWORK ID NAME DRIVER SCOPE65b44ea8847c rabbitmqnet bridge local...

Create a nod

Create three Rabbitmq nodes through the docker command

Note that the same RABBITMQ_ERLANG_COOKIE value is used here

# docker run-d\-- name=rabbitmq1\-p 5672 RABBITMQ_ERLANG_COOKIE='YZSDHWMFSMKEMBDHSGGZ' 15672\-e RABBITMQ_NODENAME=rabbitmq1\-e RABBITMQ_ERLANG_COOKIE='YZSDHWMFSMKEMBDHSGGZ'\-h rabbitmq1\-net=rabbitmqnet\ rabbitmq:3.7-rc-management# docker run-d\-name=rabbitmq2\-p 56735672 rabbitmq2\-e RABBITMQ_NODENAME=rabbitmq2\-e RABBITMQ_ERLANG_COOKIE='YZSDHWMFSMKEMBDHSGGZ'\-h rabbitmq2\-- net=rabbitmqnet\ rabbitmq:3.7-rc-management# docker run-d\ -- name=rabbitmq3\-p 5674 RABBITMQ_ERLANG_COOKIE='YZSDHWMFSMKEMBDHSGGZ' 5672\-p 15674 RABBITMQ_ERLANG_COOKIE='YZSDHWMFSMKEMBDHSGGZ' 15672\-e RABBITMQ_ERLANG_COOKIE='YZSDHWMFSMKEMBDHSGGZ'\-h rabbitmq3\-- net=rabbitmqnet\ rabbitmq:3.7-rc-management

Set up rabbitmq cluster

Log in to the last two nodes of Rabbitmq and execute the command to join the first Rabbitmq node cluster

# Disk Node# docker exec rabbitmq2 bash-c\ "rabbitmqctl stop_app & &\ rabbitmqctl reset & &\ rabbitmqctl join_cluster rabbitmq1@rabbitmq1 &\ rabbitmqctl start_app" # Ram Node# docker exec rabbitmq3 bash-c\ "rabbitmqctl stop_app & &\ rabbitmqctl reset & &\ rabbitmqctl join_cluster-- ram rabbitmq1@rabbitmq1 &\ rabbitmqctl start_app"

Exit the cluster

# docker exec rabbitmq3 bash-c\ "rabbitmqctl stop_app & &\ rabbitmqctl reset & &\ rabbitmqctl start_app"

Pull haproxy image

Pull haproxy image

# docker pull haproxy

Start haproxy

# cat haproxymurcreate.shroud! / bin/bashdocker run-d\-- name rabbitmq-haproxy\-p 1080 name rabbitmq-haproxy 80-p 5677 name rabbitmq-haproxy 5677-p 8001 name rabbitmq-haproxy 8001\-- net=rabbitmqnet\-v / root/rabbitmq/haproxy-etc:/usr/local/etc/haproxy:ro\ haproxy:latest

The configuration file for haproxy is as follows:

Root@node0:~/rabbitmq# cat haproxy-etc/haproxy.cfg# Simple configuration for an HTTP proxy listening on port 80 on all# interfaces and forwarding requests to a single backend "servers" with a # single server "server1" listening on 127.0.0.1:8000global daemon maxconn 256defaults mode http timeout connect 5000ms timeout client 5000ms timeout server 5000mslisten rabbitmq_cluster bind 0.0.0.015 5677 option tcplog mode tcp balance leastconn server rabbit1 rabbitmq1:5672 check inter 2s rise 2 fall 3 server rabbit2 rabbitmq2:5672 check inter 2s rise 2 fall 3 server rabbit3 rabbitmq3 : 5672 check inter 2s rise 2 fall 3listen http_front bind 0.0.0.0:80 stats uri / haproxy?statslisten rabbitmq_admin bind 0.0.0.0:8001 server rabbit1 rabbitmq1:15672 server rabbit2 rabbitmq2:15672 server rabbit3 rabbitmq3:15672

After starting haproxy, you can access the rabbitmq cluster through haproxy: http://external-ip:8001

Get the status of haproxy: http://external-ip:1080/haproxy?stats

Rabbitmq exporter deployment

To collect the metrics of rabbitmq for prometheus use, you can use the open source rabbitmq-exporter

References are as follows:

Https://github.com/kbudde/rabbitmq_exporter

Https://hub.docker.com/r/kbudde/rabbitmq-exporter/

Pull the image

# docker pull kbudde/rabbitmq-exporter

Start the rabbitmq instance

The copy code is as follows: # docker run-d-name=rabbitmq1-p 5672 RABBITMQ_ERLANG_COOKIE='YZSDHWMFSMKEMBDHSGGZ' 5672-p 15672 RABBITMQ_ERLANG_COOKIE='YZSDHWMFSMKEMBDHSGGZ' 15672-e RABBITMQ_NODENAME=rabbitmq1-e RABBITMQ_ERLANG_COOKIE='YZSDHWMFSMKEMBDHSGGZ'-h rabbitmq1-- net=rabbitmqnet-p 9090 RABBITMQ_ERLANG_COOKIE='YZSDHWMFSMKEMBDHSGGZ' 9090 rabbitmq:3.7-rc-management

Open port 9090, which is the default PUBLISH_PORT for rabbitmq exporter

Start the rabbitmq exporter instance

# docker run-d-net=container:rabbitmq1 kbudde/rabbitmq-exporter

Get the metrics of rabbitmq

# wget http://localhost:9090/metrics

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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