Location>code7788 >text

RabbitMQ Common Cluster Same Host Docker Setup

Popularity:572 ℃/2024-08-13 10:02:52
  • Prepare the host file directory
    cd /usr/local/
  • Create a rabbitmq mapping directory
    mkdir rabbitmq
    cd rabbitmq
    mkdir 1
    mkdir 2
    mkdir 3
    cd 1
    mkdir lib
    mkdir log
    chmod 777 lib
    chmod 777 log
    Note: 1.2.3 node file directory consistency
    Installation commands
  • Getting a rabbitmq image
    docker pull rabbitmq:management
  • Node 1 installation command (master node, create -v mapping directory)
    docker run -d --hostname rabbitmq_host1 --name rabbitmq1 -p 15672:15672 -p 5672:5672 -e RABBITMQ_NODENAME=rabbit -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=xxx333.78 -e RABBITMQ_ERLANG_COOKIE='rabbitmq_cookie' --privileged=true -v /usr/local/rabbitmq/1/lib:/var/lib/rabbitmq -v /usr/local/rabbitmq/1/log:/var/log/rabbitmq rabbitmq:management
  • Node 2 installation command (create -v mapping directory)
    docker run -d --hostname rabbitmq_host2 --name rabbitmq2 -p 15673:15672 -p 5673:5672 --link rabbitmq1:rabbitmq_host1 -e RABBITMQ_NODENAME=rabbit -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=xxx333.78 -e RABBITMQ_ERLANG_COOKIE='rabbitmq_cookie' --privileged=true -v /usr/local/rabbitmq/2/lib:/var/lib/rabbitmq -v /usr/local/rabbitmq/2/log:/var/log/rabbitmq rabbitmq:management
  • Node 3 installation command (-v map directory)
    docker run -d --hostname rabbitmq_host3 --name rabbitmq3 -p 15674:15672 -p 5674:5672 --link rabbitmq1:rabbitmq_host1 --link rabbitmq2:rabbitmq_host2 -e RABBITMQ_NODENAME=rabbit -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=xxx333.78 -e RABBITMQ_ERLANG_COOKIE='rabbitmq_cookie' --privileged=true -v /usr/local/rabbitmq/3/lib:/var/lib/rabbitmq -v /usr/local/rabbitmq/3/log:/var/log/rabbitmq rabbitmq:management
    4. 3 nodes are up and configuring the cluster
  • Node 1 (master node configuration cluster)
    docker exec -it rabbitmq1 bash
    rabbitmqctl stop_app
    rabbitmqctl reset
    rabbitmqctl start_app
    exit
  • Node 2 joins the cluster (--ram joins as memory, defaults to disk node)
    docker exec -it rabbitmq2 bash
    rabbitmqctl stop_app
    rabbitmqctl reset
    rabbitmqctl join_cluster --ram rabbit@rabbitmq_host1
    rabbitmqctl start_app
    exit
  • Node 3 joins the cluster (--ram joins as memory, defaults to disk node)
    docker exec -it rabbitmq3 bash
    rabbitmqctl stop_app
    rabbitmqctl reset
    rabbitmqctl join_cluster --ram rabbit@rabbitmq_host1
    rabbitmqctl start_app
    exit
    5. Open the web terminal http:ip:port number/15672, the master node to create a queue for testing