Based docker RabbitMQ cluster installation and deployment environment under CentOS7.X

In the previous article, I have introduced the use of the source code to install RabbitMQ (refer to article https://blog.51cto.com/8355320/2445237), the installation process is also more complicated today due to environmental requirements, the need to build a RabbitMQ cluster, due to the business also deployed to take docker container and, therefore, will study the use of docker RabbitMQ to deploy, this special deployment steps will be recorded:
Note: install the deployment docker, not here in adding the deployment process, refer to the article https: // blog. 51cto.com/8355320/2438741
built environment:
operating system: CentOS7.6
memory size: 8GB
hard disk: 200G
1, IP address planning
hostname IP address
RabbitMQ01 192.168.8.131
RabbitMQ02 192.168.8.132
RabbitMQ03 192.168.8.133
RabbitMQ04 192.168.8.134
2, RabbitMQ cluster installation
(1) four nodes run, download the image RabbitMQ
[RabbitMQ01 the root @ ~] # Docker pull RabbitMQ:. 3-Management
(2) four nodes are running, start the container RabbitMQ

[root@RabbitMQ01~]# docker run -d --restart=always --hostname rabbit01 --name rabbit-01 -p 25672:25672 -p 15672:15672 -p 5672:5672 -p 5671:5671 -p 4369:4369 --add-host rabbit02:192.168.8.132 --add-host rabbit03:192.168.8.133 --add-host rabbit04:192.168.8.134 -e RABBITMQ_ERLANG_COOKIE='rbmqcookie' rabbitmq:3-management
[root@RabbitMQ02~]# docker run -d --restart=always --hostname rabbit02 --name rabbit-02 -p 25672:25672 -p 15672:15672 -p 5672:5672 -p 5671:5671 -p 4369:4369 --add-host rabbit01:192.168.8.131 --add-host rabbit03:192.168.8.133 --add-host rabbit04:192.168.8.134 -e RABBITMQ_ERLANG_COOKIE='rbmqcookie' rabbitmq:3-management
[root@RabbitMQ03~]# docker run -d --restart=always --hostname rabbit03 --name rabbit-03 -p 25672:25672 -p 15672:15672 -p 5672:5672 -p 5671:5671 -p 4369:4369 --add-host rabbit01:192.168.8.131 --add-host rabbit02:192.168.8.132 --add-host rabbit04:192.168.8.134 -e RABBITMQ_ERLANG_COOKIE='rbmqcookie' rabbitmq:3-management
[root@RabbitMQ04~]#  docker run -d --restart=always --hostname rabbit04 --name rabbit-04 -p 25672:25672 -p 15672:15672 -p 5672:5672 -p 5671:5671 -p 4369:4369 --add-host rabbit01:192.168.8.131 --add-host rabbit02:192.168.8.132 --add-host rabbit03:192.168.8.133 -e RABBITMQ_ERLANG_COOKIE='rbmqcookie' rabbitmq:3-management

(3) to add nodes to the cluster service, we will be set to 03 nodes cluster master node, the other for the child nodes, the two nodes configured attention to ram node, the other two nodes for the disc, pay attention to the different command execution
01 nodes on execution:

[root@RabbitMQ01~]#  docker exec -it rabbit-01 bash
[rabbit@rabbit01]# rabbitmqctl stop_app
[rabbit@rabbit01]# rabbitmqctl reset
[rabbit@rabbit01]# rabbitmqctl join_cluster --ram rabbit@rabbit03
[rabbit@rabbit01]# rabbitmqctl start_app
[rabbit@rabbit01]# exit

02 nodes on execution:

[root@RabbitMQ02~]#  docker exec -it rabbit-02 bash
[rabbit@rabbit02]# rabbitmqctl stop_app
[rabbit@rabbit02]# rabbitmqctl reset
[rabbit@rabbit02]# rabbitmqctl join_cluster --ram rabbit@rabbit03
[rabbit@rabbit02]# rabbitmqctl start_app
[rabbit@rabbit02]# exit

Node 04 on the implementation of:

[root@RabbitMQ04~]#  docker exec -it rabbit-01 bash
[rabbit@rabbit04]# rabbitmqctl stop_app
[rabbit@rabbit04]# rabbitmqctl reset
[rabbit@rabbit04]# rabbitmqctl join_cluster rabbit@rabbit03
[rabbit@rabbit04]# rabbitmqctl start_app
[rabbit@rabbit04]# exit

03 nodes on execution:

[root@RabbitMQ03~]# docker exec -it rabbit-03 bash
[rabbit@rabbit03]# rabbitmqctl stop_app
[rabbit@rabbit03]# rabbitmqctl reset
[rabbit@rabbit03]# rabbitmqctl start_app
[rabbit@rabbit03]# exit

3, ha-mode image adding configure
the Name: the HA
the Pattern :.
Definition: ha-mode = All
Based docker RabbitMQ cluster installation and deployment environment under CentOS7.X

After starting the cluster to access the main interface:
Based docker RabbitMQ cluster installation and deployment environment under CentOS7.X

3, nginx installation configuration, to provide high availability
nginx installation, where skipped, directly into the configuration
[nginx the root @ ~] # CD / usr / local / nginx / the conf
[the root @ nginx the conf ~] # VI nginx.conf
other skip configuration

stream{
    upstream rabbitmq{
        server 192.168.8.131:5672 max_fails=2 fail_timeout=5s weight=2;
        server 192.168.8.132:5672 max_fails=2 fail_timeout=5s weight=2;
        server 192.168.8.133:5672 max_fails=2 fail_timeout=5s weight=2;
        server 192.168.8.134:5672 max_fails=2 fail_timeout=5s weight=2;
        }
    server{
        listen 5678;
        proxy_pass rabbitmq;
    }
}
[root@nginx~conf]#  vi rabbitmqstream.conf
upstream mqweb {
        ip_hash;
        server 192.168.8.131:15672;
        server 192.168.8.132:15672;
        server 192.168.8.133:15672;
        server 192.168.8.134:15672;
}
server {
listen 80;
server_name localhost;

  location / {
  proxy_pass http://rabbitmqstream/;
  proxy_redirect off;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  client_max_body_size    100m;
  client_body_buffer_size 256k;

  proxy_connect_timeout   60;
  proxy_send_timeout      60;
  proxy_read_timeout      60;

  proxy_buffer_size       256k;
  proxy_buffers           8 256k;
  proxy_busy_buffers_size 512k;
  proxy_temp_file_write_size 512k;
  }
}

 restart nginx container

[root@nginx~conf]# /usr/local/nginx/sbin/nginx -s reload
[root@nginx~conf]# /usr/local/nginx/sbin/nginx -s stop
[root@nginx~conf]# /usr/local/nginx/sbin/nginx

Guess you like

Origin blog.51cto.com/8355320/2459117