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

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

RabbitMQ简介

什么是RabbitMQ?

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

shell 复制代码
[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                    

拉取镜像

docker pull rabbitmq

shell 复制代码
[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

shell 复制代码
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

查看运行日志

shell 复制代码
[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容器

shell 复制代码
[root@localhost ~]# docker exec -it rabbitmq bash

启动插件

shell 复制代码
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

管理页面配置

使用默认用户名密码登录

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

-e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=123

点击Chanels问题

问题描述

management UI被禁止了。

解决方案
进入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。

shell 复制代码
echo management_agent.disable_metrics_collector=false > management_agent.disable_metrics_collector.conf 
退出并重启容器
shell 复制代码
root@6d2342d51b11:/etc/rabbitmq/conf.d# exit
exit
[root@localhost ~]# docker restart rabbitmq 
rabbitmq
刷新浏览器测试


相关推荐
2401_857610035 分钟前
Spring Boot框架:电商系统的技术优势
java·spring boot·后端
希忘auto21 分钟前
详解MySQL安装
java·mysql
冰淇淋烤布蕾33 分钟前
EasyExcel使用
java·开发语言·excel
拾荒的小海螺39 分钟前
JAVA:探索 EasyExcel 的技术指南
java·开发语言
sam-1231 小时前
k8s上部署redis高可用集群
redis·docker·k8s
Jakarta EE1 小时前
正确使用primefaces的process和update
java·primefaces·jakarta ee
马剑威(威哥爱编程)1 小时前
哇喔!20种单例模式的实现与变异总结
java·开发语言·单例模式
java—大象1 小时前
基于java+springboot+layui的流浪动物交流信息平台设计实现
java·开发语言·spring boot·layui·课程设计
Fanstay9852 小时前
在Linux中使用Nginx和Docker进行项目部署
linux·nginx·docker
杨哥带你写代码2 小时前
网上商城系统:Spring Boot框架的实现
java·spring boot·后端