前言: RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件) 环境准备 系统:centos8 [root@localhost ~]# uname -aLinux localhost.localdomain 4.18.0-348.2.1.el8_5.x86_6
前言:
RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件)
环境准备
系统:centos8
[root@localhost ~]# uname -a
Linux localhost.localdomain 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Tue Nov 16 14:42:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
yum配置
(1)yum 包更新到最新
> yum update
(2)安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的
> yum install -y yum-utils device-mapper-persistent-data lvm2
(3)设置yum源为阿里云
> yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
环境软件安装
安装docker
(1)安装docker
> yum install docker-ce -y
(2)安装后查看docker版本
> docker -v
(3) 安装加速镜像
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://0wrdwnn6.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
rabbitMQ安装
获取镜像
docker pull rabbitmq:management
创建容器并且启动
参数解释
—hostname:指定容器主机名称
—name:指定容器名称
-p:将mq端口号映射到本地
或者运行时设置用户和密码
docker run -di --name myrabbit -e RABBITMQ_DEFAULT_USER=admin -e
RABBITMQ_DEFAULT_PASS=admin -p 15672:15672 -p 5672:5672
-p 25672:25672 -p 61613:61613 -p1883:1883 rabbitmq:management
基础命令
运行已经关闭的容器
[root@localhost ~]# docker start 126a86537bb8
126a86537bb8
查看日志
**查看所有**
[root@localhost ~]# docker logs -ft 72b19a0066cf
2021-11-28T12:38:39.555502228Z [root@72b19a0066cf /]# ls
2021-11-28T12:38:39.557263423Z bin etc lib lost+found mnt proc run srv tmp var
2021-11-28T12:38:39.557294151Z dev home lib64 media opt root sbin sys usr
2021-11-28T12:38:44.029516834Z [root@72b19a0066cf /]# pwd
2021-11-28T12:38:44.029579060Z /
2021-11-28T12:38:46.551094266Z [root@72b19a0066cf /]# cd
2021-11-28T12:38:47.291735224Z [root@72b19a0066cf ~]# ls
2021-11-28T12:38:47.293627194Z anaconda-ks.cfg anaconda-post.log original-ks.cfg
2021-11-28T12:38:49.739058562Z [root@72b19a0066cf ~]# pwd
2021-11-28T12:38:49.739098127Z /root
2021-11-28T12:39:27.711038133Z [root@72b19a0066cf ~]# exit
2021-11-28T12:39:27.711062810Z exit
查看前10行
[root@localhost ~]# docker logs -ft --tail 10 72b19a0066cf
2021-11-28T12:38:39.557294151Z dev home lib64 media opt root sbin sys usr
2021-11-28T12:38:44.029516834Z [root@72b19a0066cf /]# pwd
2021-11-28T12:38:44.029579060Z /
2021-11-28T12:38:46.551094266Z [root@72b19a0066cf /]# cd
2021-11-28T12:38:47.291735224Z [root@72b19a0066cf ~]# ls
2021-11-28T12:38:47.293627194Z anaconda-ks.cfg anaconda-post.log original-ks.cfg
2021-11-28T12:38:49.739058562Z [root@72b19a0066cf ~]# pwd
2021-11-28T12:38:49.739098127Z /root
2021-11-28T12:39:27.711038133Z [root@72b19a0066cf ~]# exit
2021-11-28T12:39:27.711062810Z exit
查看正在运行容器
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
41ddc6d666f1 rabbitmq:management "docker-entrypoint.s…" 7 days ago Up 24 minutes 4369/tcp, 0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 15671/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp, 0.0.0.0:25672->25672/tcp, :::25672->25672/tcp, 0.0.0.0:61613->61613/tcp, :::61613->61613/tcp, 15691-15692/tcp myrabbit
查看所有容器-包含容器运行历史记录
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
126a86537bb8 nginx "/docker-entrypoint.…" 2 days ago Created nginx01
d84bde692ede nginx "/docker-entrypoint.…" 2 days ago Exited (0) 28 minutes ago nginx-docker
d19328c57186 centos "/bin/bash" 2 days ago Exited (0) 28 minutes ago centos-1
ccfb98634296 centos "/bin/bash" 2 days ago Exited (0) 2 days ago cranky_proskuriakova
4e883d4a8a32 mysql:5.7 "docker-entrypoint.s…" 2 days ago Exited (1) 2 days ago sleepy_chandrasekhar
28461d65d619 centos "/bin/bash" 2 days ago Exited (0) 2 days ago suspicious_mclaren
72b19a0066cf centos "/bin/bash" 3 days ago Exited (0) 3 days ago hopeful_hertz
41ddc6d666f1 rabbitmq:management "docker-entrypoint.s…" 7 days ago Up 25 minutes 4369/tcp, 0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 15671/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp, 0.0.0.0:25672->25672/tcp, :::25672->25672/tcp, 0.0.0.0:61613->61613/tcp, :::61613->61613/tcp, 15691-15692/tcp myrabbit
界面运行结果:
登录
主页面