Docker安装RabbitMQ

简介

RabbitMQ是由erlang语言开发,基于AMQP(Advanced Message Queue 高级消息队列协议)协议实现的消息队列,它是一种应用程序之间的通信方法,消息队列在分布式系统开发中应用非常广泛。RabbitMQ官方地址:http://www.rabbitmq.com

准备工作

一般情况,需要先安装部署Erlang环境再安装RabbitMQ环境。不过docker中,Erlang环境已经被docker自动安装,我们只需要简单几步操作即可完成RabbitMQ环境地安装+Web页面管理。

1、端口开放

如果在云服务上部署需在安全组开通一下端口:15672、5672、25672、61613、1883。

15672(UI页面通信口)、5672(client端通信口)、25672(server间内部通信口)、61613(stomp 消息传输)、1883(MQTT消息队列遥测传输)。

image.png

2、查询镜像

docker search rabbitmq

[root@iZwz9a7e3zeceih72sq5fcZ ~]# docker search rabbitmq
NAME                                      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
rabbitmq                                  RabbitMQ is an open source multi-protocol me…   4769      [OK]       
bitnami/rabbitmq                          Bitnami Docker Image for RabbitMQ               97                   [OK]
bitnami/rabbitmq-exporter                                                                 2                    
circleci/rabbitmq                         This image is for internal use                  0                    
circleci/rabbitmq-delayed                 https://github.com/circleci/rabbitmq-delayed…   1                    
bitnami/rabbitmq-cluster-operator                                                         0                    
rapidfort/rabbitmq                        RapidFort optimized, hardened image for Rabb…   9                    
bitnamicharts/rabbitmq                                                                    0                    
bitnamicharts/rabbitmq-cluster-operator                                                   0                    
itisfoundation/rabbitmq                                                                   0                    
masstransit/rabbitmq                                                                      11                   
nasqueron/rabbitmqadmin                   RabbitMQ management plugin CLI tool Lightwei…   1                    [OK]
clearlinux/rabbitmq                       RabbitMQ multi-protocol messaging broker wit…   0                    
corpusops/rabbitmq                        https://github.com/corpusops/docker-images/     0                    
brightercommand/rabbitmq                  RabbitMQ management with delay plugin enabled   0                    
drud/rabbitmq                             rabbitmq                                        0                    [OK]
nasqueron/rabbitmq                        RabbitMQ wth management, MQTT and STOMP plug…   0                    [OK]
exozet/rabbitmq-delay-management          deprecated                                      1                    
uselagoon/rabbitmq                                                                        0                    
betterweb/rabbitmq                                                                        0                    
uselagoon/rabbitmq-cluster                                                                0                    
newrelic/k8s-nri-rabbitmq                 New Relic Infrastructure RabbitMQ Integratio…   0                    
betterweb/rabbitmq-swarm-cluster          https://gitlab.com/BetterCorp/public/rabbitm…   0                    
faucet/event-adapter-rabbitmq              Faucet rabbitmq event adaptor docker image …   0                    
cloudio/cloudio-rabbitmq                  Docker image of RabbitMQ for cloud.iO           0                    
[root@iZwz9a7e3zeceih72sq5fcZ ~]#

3、安装镜像

docker pull rabbitmq

[root@iZwz9a7e3zeceih72sq5fcZ mydata]# docker pull rabbitmq
Using default tag: latest
latest: Pulling from library/rabbitmq
7b1a6ab2e44d: Pull complete 
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
[root@iZwz9a7e3zeceih72sq5fcZ mydata]# 

4、查询镜像

docker images

[root@iZwz9a7e3zeceih72sq5fcZ mydata]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
luo-blog     1.0       245f0c303c08   11 days ago     794MB
luo-admin    1.0       953beb66aaa2   11 days ago     798MB
nginx        latest    605c77e624dd   16 months ago   141MB
redis        latest    7614ae9453d1   17 months ago   113MB
rabbitmq     latest    d445c0adc9a5   17 months ago   220MB
nginx        1.18.0    c2c45d506085   2 years ago     133MB
redis        6.0.8     16ecd2772934   2 years ago     104MB
mysql        8.0.19    0c27e8e5fcfa   3 years ago     546MB
java         8         d23bdf5b1b1b   6 years ago     643MB
[root@iZwz9a7e3zeceih72sq5fcZ mydata]# 

5、启动MQ安装management

docker run -d --name rabbit -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin -p 15672:15672 -p 5672:5672 -p 25672:25672 -p 61613:61613 -p 1883:1883 rabbitmq:management

docker run -d --name rabbit -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin -p 15672:15672 -p 5672:5672 -p 25672:25672 -p 61613:61613 -p 1883:1883 rabbitmq:management

参数解释:本条命令包括安装Web页面管理的 rabbitmq:management组件,账号和密码都为 admin ;-p 后面参数表示公网IP地址的端口号对应容器内部的端口号

[root@iZwz9a7e3zeceih72sq5fcZ mydata]# docker run -d --name rabbit -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin -p 15672:15672 -p 5672:5672 -p 25672:25672 -p 61613:61613 -p 1883:1883 rabbitmq:management
Unable to find image 'rabbitmq:management' locally
management: Pulling from library/rabbitmq
7b1a6ab2e44d: Already exists 
37f453d83d8f: Already exists 
e64e769bc4fd: Already exists 
c288a913222f: Already exists 
12addf9c8bf9: Already exists 
eaeb088e057d: Already exists 
b63d48599313: Already exists 
05c99d3d2a57: Already exists 
43665bfbc3f9: Already exists 
f14c7d7911b1: Pull complete 
Digest: sha256:4c4b66ad5ec40b2c27943b9804d307bf31c17c8537cd0cd107236200a9cd2814
Status: Downloaded newer image for rabbitmq:management
5466ca599f2001e7db46df705a94ab1c3d9779d364b60cbfe10ffe21dad9f178
[root@iZwz9a7e3zeceih72sq5fcZ mydata]# 

6、使用admin访问RabbitMQ的Web页面

image.png

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐