rabbitMQ基础 使用docker 安装rabbitMQ(一 )
【摘要】
前言: RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件)
环境准备
系统:centos8
[root@localhost ~]# uname -a
L...
前言:
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
- 1
- 2
- 3
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
- 1
- 2
- 3
- 4
- 5
- 6
- 7
环境软件安装
安装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
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
rabbitMQ安装
获取镜像
docker pull rabbitmq:management
- 1
创建容器并且启动
参数解释
—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
- 1
- 2
- 3
基础命令
运行已经关闭的容器
[root@localhost ~]# docker start 126a86537bb8
126a86537bb8
- 1
- 2
- 3
查看日志
**查看所有**
- 1
[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
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
查看前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
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
查看正在运行容器
[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
- 1
- 2
- 3
- 4
查看所有容器-包含容器运行历史记录
[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
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
界面运行结果:
登录
主页面
文章来源: kangshihang.blog.csdn.net,作者:康世行,版权归原作者所有,如需转载,请联系作者。
原文链接:kangshihang.blog.csdn.net/article/details/121663227
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)