Giter Site home page Giter Site logo

pseudojo / docker-rabbitmq-consul-cluster Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pardahlman/docker-rabbitmq-cluster

0.0 0.0 0.0 38 KB

Cluster RabbitMQ with Consul, HAProxy using Peer Discovery

Shell 100.00%
consul docker docker-compose haproxy rabbitmq

docker-rabbitmq-consul-cluster's Introduction

Cluster RabbitMQ ๐Ÿฐ with Consul

There are a lots of good options if you want to run a RabbitMQ cluster in docker. Here's an solution that only rely on docker official images ๐ŸŽ‰

The main benifit with this approach is that you can use any version of RabbitMQ, which is maintaied by docker and will be up-to-date with future releases.

For information on how to achieve clustering using peer discovery, refer to the rabbitmq official website.

Changelog after forked (at 2023/04/10)

  • Apply Auto-Clustering

    • Enable clustering plug-in; rabbitmq_peer_discovery_consul
    • Apply useful setting to rabbitmq.conf, from "peer discovery with consul sample"
  • Change container image tag to specific version

    • Update image tag of RabbitMQ: 3-management to 3-management-alpine
    • Update image tag of HAProxy: 1.7 to lts-alpine
    • Add image tag of Consul: latest to 1-debian-11
  • Add some plugins for RabbitMQ

    • rabbitmq_management_agent
    • rabbitmq_peer_discovery_consul
    • rabbitmq_tracing
    • rabbitmq_web_mqtt
    • rabbitmq_web_stomp
  • Add depends_on of containers; Consul(consul) >> HAProxy(haproxy) >> RabbitMQ(rabbit)

  • Add always restart policy for all containers.

  • Add container-shared network as bridge mode: rabbitmq-network

Install

> # Clone repository
> git clone https://github.com/pseudojo/docker-rabbitmq-cluster.git
> cd docker-rabbitmq-cluster
>
> # Start development
> docker compose up
> 
> # Start long-options with daemon
> docker compose --env-file ./.env --file ./docker-compose.yml up -d
>
> # How to scale-up RabbitMQ : --scale rabbit=<NUMBER>
> docker compose up -d --scale rabbit=7
> # ... or 
> docker compose --env-file ./.env --file ./docker-compose.yml up -d --scale rabbit=7

Most things will be how you expect:

  • The default username and password are rabbitmq/changeme
  • The broker accepts connections on localhost:5672
    • AMQP : localhost:5672
    • MQTT : localhost:1883
    • STOMP : localhost:15672
  • The Management interface is found at localhost:15672

How to monitor/view for containers included RabbitMQ, HAProxy that.

> # check containers
> docker compose ps
>
> # trailing logs with latest 100 lines for all containers
> docker compose logs --tail=100 -f

Customize

The .env file contains environment variables that can be used to change the default username, password and virtual host.

HAProxy

This docker-compose.yml file comes with the latest version of HAProxy, an open source software that provides a high availability load balancer and proxy server.

It should be fairly easy to add a port mapping for the individual containers if it is desired to connect to a specific broker node.

For monitoring, Connect to HAProxy Statistics Page. URL is localhost:1936.

Uninstall

> cd docker-rabbitmq-cluster
>
> # Stop rabbitmq-cluster smoothly.
> docker compose down
>
> # Stop rabbitmq-cluster quickly. (3 seconds timeout)
> docker compose down --timeout 3 --remove-orphans
>
> # Purge all
> docker compose down --rmi all --remove-orphans --timeout 3

Read more

I wrote a blog post that explains some of the ideas behind this repo.

docker-rabbitmq-consul-cluster's People

Contributors

pardahlman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.