Rabbitmq入门与应用(一)-rabbitmq安装(docker版)

@Rabbitmq入门与应用-rabbitmq安装(docker版)

RabbitMQ简介

什么是RabbitMQ?

Rabbitmq入门与应用(一)-rabbitmq安装(docker版)_第1张图片

RabbitMQ is a message broker: it accepts and forwards messages. You can think about it as a post office: when you put the mail that you want posting in a post box, you can be sure that the letter carrier will eventually deliver the mail to your recipient. In this analogy, RabbitMQ is a post box, a post office, and a letter carrier.

RabbitMQ是非常热门的一款消息中间件。如英文中解释道: RabbitMQ是一个信息协调者,类似于我们的邮局。

RabbitMQ安装(docker)

查询RabbitMQ镜像

docker search rabbitmq

[root@localhost ~]# docker search rabbitmq
NAME                                      DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
rabbitmq                                  RabbitMQ is an open source multi-protocol me…   4798      [OK]       
bitnami/rabbitmq                          Bitnami Docker Image for RabbitMQ                100                  [OK]
bitnami/rabbitmq-exporter                                                                  2                    
circleci/rabbitmq                         This image is for internal use                   0                    
circleci/rabbitmq-delayed                 https://github.com/circleci/rabbitmq-delayed…   1                    

Rabbitmq入门与应用(一)-rabbitmq安装(docker版)_第2张图片

拉取镜像

docker pull rabbitmq

[root@localhost ~]# 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

创建运行rabbitmq容器

docker run -it --name=rabbitmq -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=123 -p 15672:15672 -p 5672:5672 rabbitmq

docker run -it \
--name rabbitmq \
-v /etc/localtime:/etc/localtime
-v /usr/local/software/rabbitmq/data:/var/lib/rabbitmq \
-e RABBITMQ_DEFAULT_USER=admin \
-e RABBITMQ_DEFAULT_PASS=123 \
--network wn_docker_net \
--ip 172.18.12.30 \
-p 15672:15672 \
-p 5672:5672 \
-d rabbitmq

Rabbitmq入门与应用(一)-rabbitmq安装(docker版)_第3张图片

查看运行日志

[root@localhost ~]# docker logs rabbitmq
2023-06-17 02:35:10.091757+00:00 [info] <0.222.0> Feature flags: list of feature flags found:
2023-06-17 02:35:10.107600+00:00 [info] <0.222.0> Feature flags:   [ ] implicit_default_bindings
2023-06-17 02:35:10.107642+00:00 [info] <0.222.0> Feature flags:   [ ] maintenance_mode_status
2023-06-17 02:35:10.107661+00:00 [info] <0.222.0> Feature flags:   [ ] quorum_queue
2023-06-17 02:35:10.107675+00:00 [info] <0.222.0> Feature flags:   [ ] stream_queue
2023-06-17 02:35:10.107749+00:00 [info] <0.222.0> Feature flags:   [ ] user_limits
2023-06-17 02:35:10.107764+00:00 [info] <0.222.0> Feature flags:   [ ] virtual_host_metadata
2023-06-17 02:35:10.107778+00:00 [info] <0.222.0> Feature flags: feature flag states written to disk: yes
:
:
  ##  ##      RabbitMQ 3.9.11
  ##  ##
  ##########  Copyright (c) 2007-2021 VMware, Inc. or its affiliates.
  ######  ##
  ##########  Licensed under the MPL 2.0. Website: https://rabbitmq.com

  Erlang:      24.2 [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

启动管理插件

进入rabbitmq容器

[root@localhost ~]# docker exec -it rabbitmq bash

启动插件

root@6d2342d51b11:/# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@6d2342d51b11:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_prometheus
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@6d2342d51b11...
The following plugins have been enabled:
  rabbitmq_management

started 1 plugins.

浏览器测试

在浏览器中输入 linux的ip地址:15672

Rabbitmq入门与应用(一)-rabbitmq安装(docker版)_第4张图片

管理页面配置

使用默认用户名密码登录

默认用户名、密码是在启动容器时创建的:

-e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=123

Rabbitmq入门与应用(一)-rabbitmq安装(docker版)_第5张图片

Rabbitmq入门与应用(一)-rabbitmq安装(docker版)_第6张图片

点击Chanels问题

问题描述

management UI被禁止了。

Rabbitmq入门与应用(一)-rabbitmq安装(docker版)_第7张图片

解决方案
进入rabbitmq容器

进入到容器内的/etc/rabbitmq/conf.d文件夹

root@92d011f48e0a:/# cd /etc/rabbitmq/conf.d
root@92d011f48e0a:/etc/rabbitmq/conf.d# ls
10-default-guest-user.conf  management_agent.disable_metrics_collector.conf
修改management_agent.disable_metrics_collector

修改management_agent.disable_metrics_collector.conf文件中的management_agent.disable_metrics_collector值为false。

echo management_agent.disable_metrics_collector=false > management_agent.disable_metrics_collector.conf 

image-20230617105650544

退出并重启容器
root@6d2342d51b11:/etc/rabbitmq/conf.d# exit
exit
[root@localhost ~]# docker restart rabbitmq 
rabbitmq
刷新浏览器测试

Rabbitmq入门与应用(一)-rabbitmq安装(docker版)_第8张图片

Rabbitmq入门与应用(一)-rabbitmq安装(docker版)_第9张图片

你可能感兴趣的:(rabbitmq,rabbitmq,docker,ruby,java)