赞
踩
环境准备有docker和docker-compose已经安装。
docker version
docker-compose version
1 创建rabbitmq_docker目录
[root@gitlab docker]# mkdir rabbitmq_docker
2 vi docker-compose.yml
version: '3.1'
services:
rabbitmq:
restart: always
image: daocloud.io/library/rabbitmq:3.8.8
volumes:
- ./data/:/var/lib/rabbitmq/
- ./log/:/var/log/rabbitmq/log/
ports:
- 15672:15672
- 5672:5672
3 运行, 不好用就多试验几次。
docker-compose up -d
出现以下问题就多试验几次
[root@gitlab rabbitmq_docker]# docker-compose up -d
[+] Running 0/1
⠿ rabbitmq Error 15.6s
Error response from daemon: Head "https://daocloud.io/v2/library/rabbitmq/manifests/3.8.8": Get "https://daohub-auth.daocloud.io/auth?scope=repository%3Alibrary%2Frabbitmq%3Apull&service=daocloud.io": net/http: request canceled (Client.Timeout exceeded while awaiting headers)
[root@gitlab rabbitmq_docker]# docker-compose up -d
[+] Running 11/11
⠿ rabbitmq Pulled
⠿ 5d9821c94847 Pull complete
⠿ a610eae58dfc Pull complete
⠿ a40e0eb9f140 Pull complete
⠿ d691f0af2920 Pull complete
⠿ 53d0225d76e3 Pull complete
⠿ 7c993fe17403 Pull complete
⠿ 0d9ec409b148 Pull complete
⠿ 59a47a965242 Pull complete
⠿ e0f8eb2a167a Pull complete
⠿ 75f84d813186 Pull complete
[+] Running 2/2
⠿ Network rabbitmq_docker_default Created
⠿ Container rabbitmq_docker-rabbitmq-1 Started
4 测试
[root@gitlab rabbitmq_docker]# curl localhost:5672
AMQP [root@gitlab rabbitmq_docker]#
5 手动开启图形化界面
查看已运行容器
[root@gitlab rabbitmq_docker]# docker ps
容器改名
[root@gitlab rabbitmq_docker]# docker rename rabbitmq_docker-rabbitmq-1 rabbitmq
进入容器
[root@gitlab rabbitmq_docker]# docker exec -it rabbitmq bash
root@ecf7688963fe:/opt# cd /opt/rabbitmq
root@ecf7688963fe:/opt/rabbitmq# cd plugin
找到rabbitmq_management-3.8.8.ez 复制下名字 rabbitmq_management
然后回退到sbin目录下,执行命令./rabbitmq-plugins enable rabbitmq_management启动图形界面
root@ecf7688963fe:/opt/rabbitmq/plugins# cd ../sbin/
root@ecf7688963fe:/opt/rabbitmq/sbin# ./rabbitmq-plugins enable rabbitmq_management
6 访问后用默认的账号密码登录。
http://你的IP:15672/
guest
guest
7 注意:
界面如果提示:Stats in management UI are disabled on this node
docker exec -it rabbitmq bash进入容器后修改配置然后重启docker
用cat 查看 management_agent.disable_metrics_collector = true
cat /etc/rabbitmq/conf.d/management_agent.disable_metrics_collector.conf
management_agent.disable_metrics_collector = true
用echo 修改为false
echo management_agent.disable_metrics_collector = false > management_agent.disable_metrics_collector.conf
重启docker,下面的6cf824022c1a是容器ID,通过docker ps 可以查看具体的ID
[root@gitlab rabbitmq_docker]# docker restart 6cf824022c1a
8 具体实操步骤:
[root@gitlab rabbitmq_docker]# docker rename rabbitmq_docker-rabbitmq-1 rabbitmq
[root@gitlab rabbitmq_docker]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ecf7688963fe daocloud.io/library/rabbitmq:3.8.8 "docker-entrypoint.s…" 2 hours ago Up 2 hours 4369/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 5671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp rabbitmq
[root@gitlab rabbitmq_docker]# docker exec -it rabbitmq bash
root@ecf7688963fe:/# cd /opt/
root@ecf7688963fe:/opt# ls
rabbitmq
root@ecf7688963fe:/opt# cd /opt/rabbitmq
root@ecf7688963fe:/opt/rabbitmq# ls
sbin
root@ecf7688963fe:/opt/rabbitmq# cd plugins
root@ecf7688963fe:/opt/rabbitmq/plugins# ls
rabbitmq_management-3.8.8.ez
root@ecf7688963fe:/opt/rabbitmq/plugins# cd ../sbin/
root@ecf7688963fe:/opt/rabbitmq/sbin# ./rabbitmq-plugins enable rabbitmq_management
started 1 plugins.
root@ecf7688963fe:/opt/rabbitmq/sbin#
9 其他 rabbitmq入门创建用户以及分配vhost
https://blog.csdn.net/Garnett_zk/article/details/127423084
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。