RabbitMQ 3.8.11 Creating VMS in a cluster is tedious. You can docker-like it.

1. Create docker-comemess. yml file

version: '3'
services:
  rabbitmq1:
    image: The rabbitmq: 3.8.11 - management
    container_name: rabbitmq1
    restart: always
    hostname: rabbitmq1
    ports:
      - 15683: 15672
      - 5683: 5672
    volumes:
      - ./data1:/var/lib/rabbitmq
      - ./rabbitmq.sh:/home/rabbitmq.sh
      - ./etc/hosts:/etc/hosts
      - ./etc/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins
    environment:
      - RABBITMQ_DEFAULT_USER=root
      - RABBITMQ_DEFAULT_PASS=root
      - STOMP_DEFAULT_USER=root
      - STOMP_DEFAULT_PASS=root
      - RABBITMQ_ERLANG_COOKIE=CURIOAPPLICATION
    networks:
      rabbit:
        ipv4_address: 192.1681.127.

  rabbitmq2:
    image: The rabbitmq: 3.8.11 - management
    container_name: rabbitmq2
    restart: always
    hostname: rabbitmq2
    ports:
      - 15684: 15672
      - 5684: 5672
    volumes:
      - ./data2:/var/lib/rabbitmq
      - ./rabbitmq.sh:/home/rabbitmq.sh
      - ./etc/hosts:/etc/hosts
      - ./etc/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins
    environment:
      - RABBITMQ_DEFAULT_USER=root
      - RABBITMQ_DEFAULT_PASS=root
      - STOMP_DEFAULT_USER=root
      - STOMP_DEFAULT_PASS=root
      - RABBITMQ_ERLANG_COOKIE=CURIOAPPLICATION
    networks:
      rabbit:
        ipv4_address: 192.1681.128.

  rabbitmq3:
    image: The rabbitmq: 3.8.11 - management
    container_name: rabbitmq3
    restart: always
    hostname: rabbitmq3
    ports:
      - 15692: 15672
      - 5692: 5672
    volumes:
      - ./data3:/var/lib/rabbitmq
      - ./rabbitmq.sh:/home/rabbitmq.sh
      - ./etc/hosts:/etc/hosts
      - ./etc/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins
    environment:
      - RABBITMQ_DEFAULT_USER=root
      - RABBITMQ_DEFAULT_PASS=root
      - STOMP_DEFAULT_USER=root
      - STOMP_DEFAULT_PASS=root
      - RABBITMQ_ERLANG_COOKIE=CURIOAPPLICATION
    networks:
      rabbit:
        ipv4_address: 192.1681.129.

networks:
  rabbit:
    external:
      name: rabbitmqnet

Copy the code

2. Start using the plugin (rabbitmq_stomp)

./etc/rabbitmq/enabled_plugins

[rabbitmq_management,rabbitmq_prometheus,rabbitmq_stomp].
Copy the code

3. Create the rabbitmq. Sh

rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster rabbitmq@rabbitmq1
rabbitmqctl start_app
Copy the code

4. Create a host list

./etc/hosts

192.168.1.127 rabbitmq1
192.168.1.128 rabbitmq2
192.168.1.129 rabbitmq3
Copy the code

5. Create a dependent network

# docker network create --subnet 192.168.1.1/24 rabbitmqnet
Copy the code

6. Start the rabbitMQ cluster

# docker-compose up -d
Copy the code

7. Open the monitoring platform