当前位置:   article > 正文

Docker部署RabbitMQ及各种插件_docker rabbitmq插件

docker rabbitmq插件

一、获取查询镜像

这里注意获取镜像的时候要获取management版本的,不要获取last版本的,management版本的才带有管理界面。

 docker search rabbitmq:management
  • 1

可以看到如下结果:

[root@localhost ~]# docker search rabbitmq:management
INDEX       NAME                                          DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/macintoshplus/rabbitmq-management   Based on rabbitmq:management whit python a...   1                    [OK]
docker.io   docker.io/transmitsms/rabbitmq-sharded        Fork of rabbitmq:management with sharded_e...   0
[root@localhost ~]#
  • 1
  • 2
  • 3
  • 4
  • 5

获取镜像

docker pull rabbitmq:management
  • 1

可以看到如下结果

[root@localhost ~]# docker pull rabbitmq:management
Trying to pull repository docker.io/library/rabbitmq ...
management: Pulling from docker.io/library/rabbitmq
e7bb522d92ff: Pull complete
ad90649c4d84: Pull complete
5a318b914d6c: Pull complete
cedd60f70052: Pull complete
f4ec28761801: Pull complete
b8fa44aa9074: Pull complete
e8002a209c24: Pull complete
cd1206edcd43: Pull complete
769be0727074: Pull complete
7308b93d35af: Pull complete
c4102ef22c29: Pull complete
fefc8e1aa4b5: Pull complete
a271d400045b: Pull complete
b0d4c40c62de: Pull complete
Digest: sha256:8761de2c22badfc86dfe89791dc9dbf122f67ff0f8981966573d267af421b97f
[root@localhost ~]#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

二、运行镜像

运行

docker run -d -p 5672:5672 -p 15672:15672 -p 15675:15675 -p 1883:1883 --name rabbitmq rabbitmq:management
  • 1

看到如下结果,变成功了:

[root@localhost ~]# docker run -d -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:management
e194a2dbeb52f2296dfb6d1c527cf052d82be5ed9a4c974d70dcd6af3da3eb7e
[root@localhost ~]#
  • 1
  • 2
  • 3

拷贝plugins,为了方便后前面扩展

docker cp rabbitmq:/opt/rabbitmq/plugins /usr/local/rabbitmq/
  • 1

再次运行

# 设置默认用户
docker run \
-e RABBITMQ_DEFAULT_USER=demo \
-e RABBITMQ_DEFAULT_PASS=123 \
-v /usr/local/rabbitmq/plugins:/plugins \
-d -p 5672:5672 -p 15672:15672 -p 15675:15675 -p 1883:1883 --name rabbitmq rabbitmq:management
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

指定自网络运行

指定子网络运行

docker run -d -p 5672:5672 -p 15672:15672 --network elk-net --name rabbitmq rabbitmq:management
# 也可以后面指定
docker network connect --alias rabbitmq mynet rabbitmq
  • 1
  • 2
  • 3

三、访问管理界面

访问管理界面的地址就是 http://[宿主机IP]:15672,可以使用默认的账户登录,用户名和密码都guest,如:http://192.168.0.44:15672
在这里插入图片描述

创建用户

在这里插入图片描述

配置权限

NameTagsCan access virtual hostsHas password
adminadministrator,management,policymaker/
guestadministrator/, /heima
hikinneradministrator,management/

修改用户名密码

# 查看用户
rabbitmqctl list_users
# 修改用户名对应密码
rabbitmqctl change_password Username 'Newpassword'

  • 1
  • 2
  • 3
  • 4
  • 5

四、安装mqtt插件1883

进入命令

docker exec -it rabbitmq /bin/bash
  • 1

执行安装

rabbitmq-plugins enable rabbitmq_mqtt
  • 1

提示如下安装成功

Enabling plugins on node rabbit@54978086cc2f:
rabbitmq_mqtt
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_mqtt
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@54978086cc2f...
The following plugins have been enabled:
  rabbitmq_mqtt

started 1 plugins.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

五、安装web-mqtt插件15675

进入命令

docker exec -it rabbitmq /bin/bash
  • 1

执行安装

rabbitmq-plugins enable rabbitmq_web_mqtt
  • 1

提示如下安装成功

Enabling plugins on node rabbit@401063285a70:
rabbitmq_web_mqtt
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_mqtt
  rabbitmq_prometheus
  rabbitmq_web_dispatch
  rabbitmq_web_mqtt
Applying plugin configuration to rabbit@401063285a70...
The following plugins have been enabled:
  rabbitmq_web_mqtt

started 1 plugins.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

六、安装DelayExchange延迟队列插件

插件地址:https://www.rabbitmq.com/community-plugins.html
github:https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases/tag/3.9.0
下载:rabbitmq_delayed_message_exchange-3.9.0.ez
由于我的rabbitmq版本是RabbitMQ 3.9.13,所以我们安装3.9.0的插件

拷贝插件文件到宿主机的映射目录下

mv rabbitmq_delayed_message_exchange-3.9.0.ez /usr/local/rabbitmq/plugins/
  • 1

启用插件

# 进入容器
docker exec -it rabbitmq /bin/bash
# 启用插件
rabbitmq-plugins enable rabbitmq_delayed_message_exchange
  • 1
  • 2
  • 3
  • 4

提示如下说明安装成功:

oot@01e900b94fb4:/# rabbitmq-plugins enable rabbitmq_delayed_message_exchange
Enabling plugins on node rabbit@01e900b94fb4:
rabbitmq_delayed_message_exchange
The following plugins have been configured:
  rabbitmq_delayed_message_exchange
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_mqtt
  rabbitmq_prometheus
  rabbitmq_web_dispatch
  rabbitmq_web_mqtt
Applying plugin configuration to rabbit@01e900b94fb4...
The following plugins have been enabled:
  rabbitmq_delayed_message_exchange

started 1 plugins.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

七、虚拟主机

虚拟主机概念是RabbitMQ的核心,在用户未自定义虚拟机前已经内置有虚拟机,在使用RabbitMQ中,可以进行自定义配置虚拟机.一个虚拟机中可以含有多个队列信息
虚拟机最大的好处在于可以根据不同的用户分配不同的操作空间
可以理解是多租户的概念,每个用虚拟主机的交换机,队列等隔离
在这里插入图片描述
可以参考https://blog.csdn.net/qq_42549122/article/details/90642239

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/401115?site
推荐阅读
相关标签
  

闽ICP备14008679号