声明:
本文用于本人技术学习和备忘。水平有限,如有错漏欢迎指正!
原创不易,如有转载请标注出处:https://blog.csdn.net/luyou0401/article/details/126601329
文章目录
06-Docker安装RabbitMQ(Mac)
DockerHub地址
https://hub.docker.com/_/rabbitmq
镜像
RabbitMQ版本号:3.9.11
拉取镜像
# 默认版本 latest
docker pull rabbitmq
# 如需指定版本,如下
docker pull rabbitmq:3.9
操作如下:
# 拉取镜像
luyou@MacBook-Pro-yaco ~ % docker pull rabbitmq
Using default tag: latest
latest: Pulling from library/rabbitmq
7b1a6ab2e44d: Already exists
37f453d83d8f: Pull complete
e64e769bc4fd: Pull complete
c288a913222f: Pull complete
12addf9c8bf9: Pull complete
eaeb088e057d: Pull complete
b63d48599313: Pull complete
05c99d3d2a57: Pull complete
43665bfbc3f9: Pull complete
Digest: sha256:884146137011519524d506a12687127f3d2c7c37c2cc11206dc72c59bedea5e2
Status: Downloaded newer image for rabbitmq:latest
docker.io/library/rabbitmq:latest
# 查询镜像
luyou@MacBook-Pro-yaco ~ % docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
rabbitmq latest d445c0adc9a5 8 months ago 220MB
结果:
容器
1、映射目录
根据需要创建本地目录
用途 | docker目录 | 本地目录 |
---|---|---|
配置文件 | /etc/rabbitmq | /Users/luyou/docker/rabbitmq/conf |
2、创建容器
docker run --name rabbitmq \
--hostname local \
-e RABBITMQ_DEFAULT_USER=admin \
-e RABBITMQ_DEFAULT_PASS=admin \
-p 15672:15672 \
-p 5672:5672 \
-v /Users/luyou/docker/rabbitmq/conf:/etc/rabbitmq \
-d rabbitmq:latest
操作如下:
luyou@MacBook-Pro-yaco ~ % docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
14876467845c rabbitmq:latest "docker-entrypoint.s…" 4 seconds ago Up 4 seconds 4369/tcp, 0.0.0.0:5672->5672/tcp, 5671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp rabbitmq
结果:
3、配置插件
控制台
# 进入容器
docker exec -it rabbitmq /bin/bash
# 开启控制台插件
root@local:/# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@local:
rabbitmq_management
The following plugins have been configured:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@local...
The following plugins have been enabled:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
started 3 plugins.
延迟队列插件
(1)下载插件
下载地址:https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases
(2)上传插件包
# 进入安装包所在目录
cd /Users/luyou/docker/rabbitmq/plugins;
# 拷贝至容器目录
docker cp ./rabbitmq_delayed_message_exchange-3.9.0.ez rabbitmq:/plugins
(3)安装插件
# 启用延迟队列插件
root@local:/plugins# rabbitmq-plugins enable rabbitmq_delayed_message_exchange
Enabling plugins on node rabbit@local:
rabbitmq_delayed_message_exchange
The following plugins have been configured:
rabbitmq_delayed_message_exchange
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@local...
The following plugins have been enabled:
rabbitmq_delayed_message_exchange
started 1 plugins.
(4)查询已安装插件
root@local:/plugins# rabbitmq-plugins list
Listing plugins with pattern ".*" ...
Configured: E = explicitly enabled; e = implicitly enabled
| Status: * = running on rabbit@local
|/
[ ] rabbitmq_amqp1_0 3.9.11
[ ] rabbitmq_auth_backend_cache 3.9.11
[ ] rabbitmq_auth_backend_http 3.9.11
[ ] rabbitmq_auth_backend_ldap 3.9.11
[ ] rabbitmq_auth_backend_oauth2 3.9.11
[ ] rabbitmq_auth_mechanism_ssl 3.9.11
[ ] rabbitmq_consistent_hash_exchange 3.9.11
[E*] rabbitmq_delayed_message_exchange 3.9.0
[ ] rabbitmq_event_exchange 3.9.11
访问控制台
- 地址:http://localhost:15672/#/
- 账号:admin
- 密码:admin
延迟队列插件:
常用操作
启动
命令行:
docker start rabbitmq
图形界面:
停止
命令行:
docker stop rabbitmq
图形界面:
删除
命令行:
docker rm rabbitmq
图形界面:
查询日志
命令行:
docker logs -f rabbitmq
图形界面:
图形日志:
进入容器
# 进入容器
docker exec -it rabbitmq bash
# 退出容器
exit
声明:
本文用于本人技术学习和备忘。水平有限,如有错漏欢迎指正!
原创不易,如有转载请标注出处:https://blog.csdn.net/luyou0401/article/details/126601329