基于 Docker 安装 RabbitMQ
查找RabbitMQ镜像
- 命令:
docker search rabbitmq
- 示例:
MBP:~ shanglishuai$ docker search rabbitmq
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
rabbitmq RabbitMQ is an open source multi-protocol me… 2768 [OK]
bitnami/rabbitmq Bitnami Docker Image for RabbitMQ 31 [OK]
tutum/rabbitmq Base docker image to run a RabbitMQ server 20
frodenas/rabbitmq A Docker Image for RabbitMQ 12 [OK]
kbudde/rabbitmq-exporter rabbitmq_exporter for prometheus 11
:~ shanglishuai$
拉取RabbitMQ镜像
命令:
docker pull rabbitmq (镜像未配有控制台)
docker pull rabbitmq:management (镜像配有控制台)
注意:rabbitmq是官方镜像,该镜像不带控制台。如果要安装带控制台的镜像,需要在拉取镜像时附带tag标签,例如:management。tag标签可以通过https://hub.docker.com/_/rabbitmq?tab=tags来查询。
- 示例:
>docker pull rabbitmq:management
management: Pulling from library/rabbitmq
35c102085707: Pull complete
251f5509d51d: Pull complete
8e829fe70a46: Pull complete
6001e1789921: Pull complete
79bdb7145cce: Pull complete
a53ba598956f: Pull complete
78be6aa88825: Pull complete
78743b5c9607: Pull complete
af023e02a847: Pull complete
2259c0afa940: Pull complete
347b67546dd0: Pull complete
a139db4173f7: Pull complete
Digest: sha256:654b5c6a3a4d3ca1affd4ca7d24f841a8c87e31f02734b957a58b4ba42eee42e
Status: Downloaded newer image for rabbitmq:latest
docker.io/library/rabbitmq:latest
安装 RabbitMQ
- 命令:docker run --name rabbitmq -d -p 15672:15672 -p 5672:5672 rabbitmq:management
- 示例:
>docker run --name rabbitmq -d -p 15672:15672 -p 5672:5672 rabbitmq:management
9e88cc029a42566ce17eb9030796e88e43cf1c4289b3cdc48946126aec47c07d
停止 RabbitMQ 容器
- 命令:docker stop rabbitmq
- 示例:
>docker stop rabbitmq
rabbitmq
启动 RabbitMQ 容器
- 命令:docker start rabbitmq
- 示例:
>docker start rabbitmq
rabbitmq
重启 RabbitMQ 容器
- 命令:docker restart rabbitmq
- 示例:
>docker restart rabbitmq
rabbitmq
查看 RabbitMQ 容器进程信息
- 命令:docker top rabbitmq
- 示例:
>docker top rabbitmq
PID USER TIME COMMAND
4911 999 0:00 {rabbitmq-server} /bin/sh /opt/rabbitmq/sbin/rabbitmq-server
5069 999 0:00 /usr/local/lib/erlang/erts-10.4.4/bin/epmd -daemon
5120 999 0:08 /usr/local/lib/erlang/erts-10.4.4/bin/beam.smp -W w -A 64 -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -K true -B i -- -root /usr/local/lib/erlang -progname erl -- -home /var/lib/rabbitmq -- -pa /opt/rabbitmq/ebin -noshell -noinput -s rabbit boot -sname rabbit@9e88cc029a42 -boot start_sasl -conf /etc/rabbitmq/rabbitmq.conf -conf_dir /var/lib/rabbitmq/config -conf_script_dir /opt/rabbitmq/sbin -conf_schema_dir /var/lib/rabbitmq/schema -conf_advanced /etc/rabbitmq/advanced.config -kernel inet_default_connect_options [{nodelay,true}] -sasl errlog_type error -sasl sasl_error_logger tty -rabbit lager_log_root "/var/log/rabbitmq" -rabbit lager_default_file tty -rabbit lager_upgrade_file tty -rabbit feature_flags_file "/var/lib/rabbitmq/mnesia/rabbit@9e88cc029a42-feature_flags" -rabbit enabled_plugins_file "/etc/rabbitmq/enabled_plugins" -rabbit plugins_dir "/opt/rabbitmq/plugins" -rabbit plugins_expand_dir "/var/lib/rabbitmq/mnesia/rabbit@9e88cc029a42-plugins-expand" -os_mon start_cpu_sup false -os_mon start_disksup false -os_mon start_memsup false -mnesia dir "/var/lib/rabbitmq/mnesia/rabbit@9e88cc029a42" -kernel inet_dist_listen_min 25672 -kernel inet_dist_listen_max 25672
5220 999 0:00 erl_child_setup 1048576
5269 999 0:00 inet_gethost 4
5270 999 0:00 inet_gethost 4
控制台信息
启动容器后,可以浏览器中访问http://localhost:15672来查看控制台信息。
RabbitMQ
默认的用户名:guest
,密码:guest
如下图: