docker 安装 rabbitmq3.8 集群-3 台
1.规划:
192.168.171.128 rabbitmq1
192.168.171.129 rabbitmq2
192.168.171.130 rabbitmq3
2.docker 安装 rabbitmq3.8 集群
参考链接:https://blog.csdn.net/belonghuang157405/article/details/83540148
1)先在 3 台机器上各自安装 rabbitmq
192.168.171.128 机器:
基本服务器配置,配置主机名和 hostst 解析:
[root@localhost ~]# hostnamectl set-hostname rabbitmq1
[root@rabbitmq1 ~]# cat /etc/hosts
192.168.171.128 rabbitmq1
192.168.171.129 rabbitmq2
192.168.171.130 rabbitmq3
上传并导入 rabbitmq 镜像:
[root@rabbitmq1 ~]# ls rabbitmq-management.tar
rabbitmq-management.tar
[root@rabbitmq1 ~]# docker load -i rabbitmq-management.tar
[root@rabbitmq1 ~]# docker images |grep rabbitmq
rabbitmq management 36ed80b6a1b1 3 months ago 180MB
3 台主机分别创建持久化目录和自定义配置文件:
[root@rabbitmq1 ~]# mkdir -p /data/rabbitmq/data
[root@rabbitmq1 ~]# mkdir -p /data/rabbitmq/conf
[root@rabbitmq1 ~]# vim /data/rabbitmq/conf/rabbitmq.conf #配置文件都一样,服务先单独安装,最后统一创建集群
loopback_users.guest = false
listeners.tcp.default = 5672
management.tcp.port = 15672
[root@rabbitmq1 ~]# docker run -d --net=host --restart=always --hostname rabbitmq1 --name rabbitmqCluster1 -v /data/rabbitmq/data:/var/lib/rabbitmq -v
/etc/hosts:/etc/hosts -v /data/rabbitmq/conf/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf rabbitmq:management
[root@rabbitmq1 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5c2195ad027f rabbitmq:management "docker-entrypoint.s…" 50 seconds ago Up 49 seconds rabbitmqCluster1
[root@rabbitmq1 ~]# netstat -anput |grep 5672
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 19169/beam.smp
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 19169/beam.smp
tcp6 0 0 :::5672 :::* LISTEN 19169/beam.smp
通过浏览器访问 rabbitmq1: http://192.168.171.128:15672
默认用户名和密码:guest/guest