Docker 安装部署RabbitMQ
这里注意获取镜像的时候要获取management版本的,不要获取last版本的,management版本的才带有管理界面。
获查询镜像
docker search rabbitmq:management
可以看到如下结果:
$ sudo docker search rabbitmq:management
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
macintoshplus/rabbitmq-management Based on rabbitmq:management whit python and… 4 [OK]
transmitsms/rabbitmq-sharded Fork of rabbitmq:management with sharded_exc… 0
xiaochunping/rabbitmq xiaochunping/rabbitmq:management 2018-06-30 0
获取镜像
docker pull rabbitmq:management
可以看到如下结果
management: Pulling from library/rabbitmq
6abc03819f3e: Pull complete
05731e63f211: Pull complete
0bd67c50d6be: Pull complete
78d7bb64d81b: Pull complete
fa37476193df: Pull complete
5293f1f07690: Pull complete
5f4305b1c03c: Pull complete
d4b9a7eb3d27: Pull complete
53924b30a970: Pull complete
aae6654997e3: Pull complete
7b042b8ea02a: Pull complete
Digest: sha256:f042507e7af2d12f2fca98036d4605569169b8cd4e40026c08c1a6b3ad6adc0c
Status: Downloaded newer image for rabbitmq:management
运行镜像
docker run -d -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:management
看到如下结果,变成功了:
$ sudo docker run -d -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:management
c7ea3ce6bfbed06e9ad22608b70eda0e06c9205953115d828dda3119119fb721
指定用户及名称启动rabbitmq
$ sudo docker run -d --restart=always --name ppshuai-rabbitmq -e RABBITMQ_DEFAULT_USER=ppshuai -e RABBITMQ_DEFAULT_PASS=ppshuai@2019 -p 15672:15672 -p 4369:4369 -p 5671-5672:5671-5672 -p 15671:15671 -p 25672:25672 rabbitmq:management
e168fcb813bbc521ace2d5e66aca6c5df0829e1bae197e88bc45039d4e7d1b91
查看启动状态信息:
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e168fcb813bb rabbitmq:management "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:4369->4369/tcp, 0.0.0.0:5671-5672->5671-5672/tcp, 0.0.0.0:15671-15672->15671-15672/tcp, 0.0.0.0:25672->25672/tcp ppshuai-rabbitmq
端口说明:
4369 (epmd), 25672 (Erlang distribution)
5672, 5671 (AMQP 0-9-1 without and with TLS)应用访问端口号
15672 (if management plugin is enabled)控制台端口号
61613, 61614 (if STOMP is enabled)
1883, 8883 (if MQTT is enabled)
若要关闭服务:
sudo docker stop e168fcb813bb(CONTAINER ID容器标识)
sudo docker rm e168fcb813bb(CONTAINER ID容器标识)
或
sudo docker stop ppshuai-rabbitmq(CONTAINER NAME容器名称)
sudo docker rm ppshuai-rabbitmq(CONTAINER NAME容器名称)
访问管理界面
访问管理界面的地址就是 http://[宿主机IP]:15672,可以使用默认的账户登录,用户名和密码都guest(若指定则用指定的用户名和密码登陆),如:
A、新增用户:
(1)Admin菜单:
(2)新增用户:(用户名)ppshuai2019/ (密码)ppshuai2019
(3)给用户设置:set permission
B、新增队列:
(1)Queues菜单:
(2)新增队列:Add a new queue
(3)队列名称:tests_queue
使用方式:
amqp://ppshuai2019:ppshuai2019@*.*.*.*:5672
queue:tests_queue