RabbitMQ:Docker Compose部署RabbitMQ
Posted ITKaven
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RabbitMQ:Docker Compose部署RabbitMQ相关的知识,希望对你有一定的参考价值。
创建目录,用于存放Docker Compose
部署RabbitMQ
的yaml
文件:
mkdir -p /root/composefile/rabbitmq
写入该yaml
文件:
vim /root/composefile/rabbitmq/rabbitmq.yaml
内容如下所示:
version: '3'
services:
rabbitmq:
image: rabbitmq:management
container_name: rabbitmq
restart: always
ports:
- 5672:5672
- 15672:15672
environment:
RABBITMQ_DEFAULT_VHOST: '/'
RABBITMQ_DEFAULT_USER: admin
RABBITMQ_DEFAULT_PASS: admin
rabbitmq:management
镜像是开启管理插件的RabbitMQ
镜像,开始部署:
docker compose -f /root/composefile/rabbitmq/rabbitmq.yaml up -d
[+] Running 11/11
⠿ rabbitmq Pulled 33.5s
⠿ 08c01a0ec47e Pull complete 17.9s
⠿ 1ceb23964d6c Pull complete 18.9s
⠿ 64631f643e2c Pull complete 23.1s
⠿ 67525726a753 Pull complete 23.4s
⠿ 4b28b554c25b Pull complete 25.0s
⠿ 3afdc08bc87a Pull complete 25.2s
⠿ 1e22dd212ab8 Pull complete 25.3s
⠿ b585ed397156 Pull complete 25.4s
⠿ 68de743a7628 Pull complete 25.4s
⠿ 68b52ebaee48 Pull complete 27.3s
[+] Running 2/2
⠿ Network rabbitmq_default Created 1.2s
⠿ Container rabbitmq Started 2.0s
查询运行的服务:
docker compose ls
RabbitMQ
服务在运行中。
NAME STATUS
kafka running(3)
rabbitmq running(1)
zookeeper running(3)
查询运行的容器:
docker ps
RabbitMQ
容器在运行中。
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c1ea80c84342 rabbitmq:management "docker-entrypoint.s…" 4 minutes ago Up 3 minutes 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 15671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp rabbitmq
78cc8ff2cdb5 wurstmeister/kafka "start-kafka.sh" 9 hours ago Up 9 hours 0.0.0.0:9092->9092/tcp, :::9092->9092/tcp kafka1
c9c058a28f85 wurstmeister/kafka "start-kafka.sh" 9 hours ago Up 9 hours 0.0.0.0:9094->9092/tcp, :::9094->9092/tcp kafka3
cabac80ad5df wurstmeister/kafka "start-kafka.sh" 9 hours ago Up 9 hours 0.0.0.0:9093->9092/tcp, :::9093->9092/tcp kafka2
0b053b25981f zookeeper "/docker-entrypoint.…" 26 hours ago Up 9 hours 2888/tcp, 3888/tcp, 8080/tcp, 0.0.0.0:9001->2181/tcp, :::9001->2181/tcp zookeeper1
394615a4fef7 zookeeper "/docker-entrypoint.…" 26 hours ago Up 9 hours 2888/tcp, 3888/tcp, 8080/tcp, 0.0.0.0:9003->2181/tcp, :::9003->2181/tcp zookeeper3
ef752b5f2a64 zookeeper "/docker-entrypoint.…" 26 hours ago Up 9 hours 2888/tcp, 3888/tcp, 8080/tcp, 0.0.0.0:9002->2181/tcp, :::9002->2181/tcp zookeeper2
访问http://192.168.1.9:15672/
,即可进入RabbitMQ
的管理界面。
使用yaml
文件中定义的账号进行登陆。
使用Docker Compose
部署RabbitMQ
很方便。如果部署出现问题,可以通过查看容器的日志来发现问题。
docker logs rabbitmq
2022-02-14 11:00:44.032131+00:00 [info] <0.228.0> Feature flags: list of feature flags found:
2022-02-14 11:00:44.044573+00:00 [info] <0.228.0> Feature flags: [ ] implicit_default_bindings
2022-02-14 11:00:44.044597+00:00 [info] <0.228.0> Feature flags: [ ] maintenance_mode_status
2022-02-14 11:00:44.044623+00:00 [info] <0.228.0> Feature flags: [ ] quorum_queue
2022-02-14 11:00:44.044650+00:00 [info] <0.228.0> Feature flags: [ ] stream_queue
2022-02-14 11:00:44.044699+00:00 [info] <0.228.0> Feature flags: [ ] user_limits
2022-02-14 11:00:44.044712+00:00 [info] <0.228.0> Feature flags: [ ] virtual_host_metadata
2022-02-14 11:00:44.044724+00:00 [info] <0.228.0> Feature flags: feature flag states written to disk: yes
2022-02-14 11:00:44.377772+00:00 [noti] <0.44.0> Application syslog exited with reason: stopped
2022-02-14 11:00:44.377823+00:00 [noti] <0.228.0> Logging: switching to configured handler(s); following messages may not be visible in this log output
2022-02-14 11:00:44.394528+00:00 [noti] <0.228.0> Logging: configured log handlers are now ACTIVE
2022-02-14 11:00:44.622850+00:00 [info] <0.228.0> ra: starting system quorum_queues
2022-02-14 11:00:44.622906+00:00 [info] <0.228.0> starting Ra system: quorum_queues in directory: /var/lib/rabbitmq/mnesia/rabbit@c1ea80c84342/quorum/rabbit@c1ea80c84342
2022-02-14 11:00:44.708687+00:00 [info] <0.265.0> ra: meta data store initialised for system quorum_queues. 0 record(s) recovered
2022-02-14 11:00:44.738407+00:00 [noti] <0.270.0> WAL: ra_log_wal init, open tbls: ra_log_open_mem_tables, closed tbls: ra_log_closed_mem_tables
2022-02-14 11:00:44.759025+00:00 [info] <0.228.0> ra: starting system coordination
2022-02-14 11:00:44.759062+00:00 [info] <0.228.0> starting Ra system: coordination in directory: /var/lib/rabbitmq/mnesia/rabbit@c1ea80c84342/coordination/rabbit@c1ea80c84342
2022-02-14 11:00:44.760480+00:00 [info] <0.278.0> ra: meta data store initialised for system coordination. 0 record(s) recovered
2022-02-14 11:00:44.760597+00:00 [noti] <0.283.0> WAL: ra_coordination_log_wal init, open tbls: ra_coordination_log_open_mem_tables, closed tbls: ra_coordination_log_closed_mem_tables
2022-02-14 11:00:44.767529+00:00 [info] <0.228.0>
2022-02-14 11:00:44.767529+00:00 [info] <0.228.0> Starting RabbitMQ 3.9.13 on Erlang 24.2.1 [jit]
2022-02-14 11:00:44.767529+00:00 [info] <0.228.0> Copyright (c) 2007-2022 VMware, Inc. or its affiliates.
2022-02-14 11:00:44.767529+00:00 [info] <0.228.0> Licensed under the MPL 2.0. Website: https://rabbitmq.com
## ## RabbitMQ 3.9.13
## ##
########## Copyright (c) 2007-2022 VMware, Inc. or its affiliates.
###### ##
########## Licensed under the MPL 2.0. Website: https://rabbitmq.com
Erlang: 24.2.1 [jit]
TLS Library: OpenSSL - OpenSSL 1.1.1m 14 Dec 2021
Doc guides: https://rabbitmq.com/documentation.html
Support: https://rabbitmq.com/contact.html
Tutorials: https://rabbitmq.com/getstarted.html
Monitoring: https://rabbitmq.com/monitoring.html
Logs: /var/log/rabbitmq/rabbit@c1ea80c84342_upgrade.log
<stdout>
Config file(s): /etc/rabbitmq/conf.d/10-default-guest-user.conf
Starting broker...2022-02-14 11:00:44.769082+00:00 [info] <0.228.0>
...
2022-02-14 11:00:48.954038+00:00 [info] <0.810.0> started TCP listener on [::]:5672
completed with 4 plugins.
2022-02-14 11:00:49.050886+00:00 [info] <0.665.0> Server startup complete; 4 plugins started.
2022-02-14 11:00:49.050886+00:00 [info] <0.665.0> * rabbitmq_prometheus
2022-02-14 11:00:49.050886+00:00 [info] <0.665.0> * rabbitmq_management
2022-02-14 11:00:49.050886+00:00 [info] <0.665.0> * rabbitmq_web_dispatch
2022-02-14 11:00:49.050886+00:00 [info] <0.665.0> * rabbitmq_management_agent
可见版本是RabbitMQ3.9.13
,Docker Compose
部署RabbitMQ
就介绍到这里,如果博主有说错的地方或者大家有不同的见解,欢迎大家评论补充。
以上是关于RabbitMQ:Docker Compose部署RabbitMQ的主要内容,如果未能解决你的问题,请参考以下文章
Docker-compose常用软件部署(mysqlredisrabbitmq)