Win系统下使用Docker安装RabbitMQ及延迟插件
- docker 安装 rabbitmq
docker pull rabbitmq:3.12.0-management
- 运行
docker run -d --name=rabbitmq --restart=always -p 5672:5672 -p 15672:15672 rabbitmq:3.12.0-management
- 访问
访问 http://localhost:15672/,默认账号密码为:guest / guest
登录后出现如下界面表示运行成功
- 下载延迟队列插件
访问:https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases,找到与之对应的版本,点击下载
- 安装插件
首先docker ps -a 显示正在运行的容器,记录下对应的rabbitmq的CONTAINER ID
然后拷贝插件到容器中
cp e:\plugs\rabbitmq_delayed_message_exchange-3.12.0.ez c809062d2ee1:/plugins
接着进入到容器内部
docker exec -it rabbitmq /bin/bash
cd到 plugins 目录下
cd plugins
执行 ls -l|grep delay 命令查看插件是否copy成功
ls -l|grep delay
在 plugins 目录下执行命令启动插件
rabbitmq-plugins enable rabbitmq_delayed_message_exchange
最后退出容器
exit
然后重启这个容器
docker restart c809
查看插件是否安装成功
发现有 x-delayed-message 选型说明延迟队列插件安装成功
下面是我完整的操作步骤
C:\Users\25019>docker cp e:\plugs\rabbitmq_delayed_message_exchange-3.12.0.ez c809062d2ee1:/plugins
Successfully copied 50.2kB to c809062d2ee1:\opt\rabbitmq\pluginsC:\Users\25019>docker exec -it rabbitmq /bin/bashroot@c809062d2ee1:/# cd pluginsroot@c809062d2ee1:/plugins# ls -l|grep delay
-rwxr-xr-x 1 root root 48214 Aug 11 02:53 rabbitmq_delayed_message_exchange-3.12.0.ezroot@c809062d2ee1:/plugins# rabbitmq-plugins enable rabbitmq_delayed_message_exchange
Enabling plugins on node rabbit@c809062d2ee1:
rabbitmq_delayed_message_exchange
The following plugins have been configured:rabbitmq_delayed_message_exchangerabbitmq_managementrabbitmq_management_agentrabbitmq_prometheusrabbitmq_web_dispatch
Applying plugin configuration to rabbit@c809062d2ee1...
The following plugins have been enabled:rabbitmq_delayed_message_exchangestarted 1 plugins.root@c809062d2ee1:/plugins# exit
exitC:\Users\25019>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c809062d2ee1 rabbitmq:3.12.0-management "docker-entrypoint.s…" 23 minutes ago Up 23 minutes 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp rabbitmqC:\Users\25019>docker restart c809
c809C:\Users\25019>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c809062d2ee1 rabbitmq:3.12.0-management "docker-entrypoint.s…" 23 minutes ago Up 4 seconds 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp rabbitmqC:\Users\25019>