首页 > 其他分享 >kubernetes rabbimq3.11.11集群之mqtt插件

kubernetes rabbimq3.11.11集群之mqtt插件

时间:2023-04-03 15:37:19浏览次数:59  
标签:11 default 插件 rabbimq3.11 ## rabbitmq cluster mqtt user

1. 概述

  本文是总结给予k8s的rabbitmq3.11.11集群的mqtt搭建

  rabbitmq集群搭建详见前一篇文章:kubernetes 集群部署rabbimq3.11.11

2. 自动创建mqtt账号密码

wrapper-entrypoint.sh
#!/usr/bin/env bash
(sleep 20; \
admin_user=bbbbbb;\
admin_passwd=111111;\
rabbitmqctl add_user $admin_user $admin_passwd; \
rabbitmqctl set_user_tags mqtt_admin administrator; \
rabbitmqctl set_permissions -p / mqtt_admin ".*" ".*" ".*"; \
rabbitmqadmin -u $admin_user -p $admin_passwd declare exchange --vhost='/' name=exchange_mqtt_topic type=topic auto_delete=false durable=true;\
) &

# Call original entrypoint
exec docker-entrypoint.sh rabbitmq-server $@

这个脚本是准备在服务器起来以后的处理流程:

先等待20s

设置管理员bbbbbb的密码为111111,

创建exchange:exchange_mqtt_topic

Dockerfile
 FROM rabbitmq:3.11.11-management-alpine


COPY wrapper-entrypoint.sh /

# 开启插件 + 设置mqtt登录用户和权限
RUN chmod a+x /wrapper-entrypoint.sh

EXPOSE 1883 8883 15675

ENTRYPOINT ["/wrapper-entrypoint.sh"]

重新基于wrapper-entrypoint.sh编译一个镜像,这样每个容器在起来20s以后就可以创建bbbbbb的账号了

3. ConfigMap配置文件修改

apiVersion: v1
kind: ConfigMap
metadata:
  name: rabbitmq-config
  namespace: rabbitmq
data:
  enabled_plugins: |
      [rabbitmq_management,rabbitmq_mqtt,rabbitmq_web_mqtt,rabbitmq_peer_discovery_k8s].
  rabbitmq.conf: |
      ## Cluster formation. See https://www.rabbitmq.com/cluster-formation.html to learn more.
      cluster_formation.peer_discovery_backend  = k8s
      cluster_formation.k8s.host = kubernetes.default.svc.cluster.local
      ## Service name is rabbitmq by default but can be overridden using the cluster_formation.k8s.service_name key if needed
      cluster_formation.k8s.service_name = rabbitmq-internal
      ## It is possible to append a suffix to peer hostnames returned by Kubernetes using cluster_formation.k8s.hostname_suffix
      cluster_formation.k8s.hostname_suffix = .rabbitmq-internal.rabbitmq.svc.cluster.local
      ## Should RabbitMQ node name be computed from the pod's hostname or IP address?
      ## IP addresses are not stable, so using [stable] hostnames is recommended when possible.
      ## Set to "hostname" to use pod hostnames.
      ## When this value is changed, so should the variable used to set the RABBITMQ_NODENAME
      ## environment variable.
      cluster_formation.k8s.address_type = hostname
      ## How often should node cleanup checks run?
      cluster_formation.node_cleanup.interval = 30
      ## Set to false if automatic removal of unknown/absent nodes
      ## is desired. This can be dangerous, see
      ##  * https://www.rabbitmq.com/cluster-formation.html#node-health-checks-and-cleanup
      ##  * https://groups.google.com/forum/#!msg/rabbitmq-users/wuOfzEywHXo/k8z_HWIkBgAJ
      cluster_formation.node_cleanup.only_log_warning = true
      cluster_partition_handling = autoheal
      ## See https://www.rabbitmq.com/ha.html#master-migration-data-locality
      queue_master_locator=min-masters
      ## This is just an example.
      ## This enables remote access for the default user with well known credentials.
      ## Consider deleting the default user and creating a separate user with a set of generated
      ## credentials instead.
      ## Learn more at https://www.rabbitmq.com/access-control.html#loopback-users
      loopback_users.guest = false
      ## https://www.rabbitmq.com/memory.html#configuring-threshold
      vm_memory_high_watermark.relative = 0.6


      ## On first start RabbitMQ will create a vhost and a user. These
      ## config items control what gets created.
      ## Relevant doc guide: https://rabbitmq.com/access-control.html
      ##
      default_vhost = /
      default_user = aaaaa
      default_pass = 11111



      # =======================================
      # MQTT section
      # =======================================

      ## TCP listener settings.
      ##
      # mqtt.listeners.tcp.1 = 127.0.0.1:61613
      # mqtt.listeners.tcp.2 = ::1:61613
      mqtt.listeners.tcp.default = 1883

      ## Set the default user name and password used for anonymous connections (when client
      ## provides no credentials). Anonymous connections are highly discouraged!
      ##
      mqtt.default_user = bbbbbb
      mqtt.default_pass = 111111

      ## Enable anonymous connections. If this is set to false, clients MUST provide
      ## credentials in order to connect. See also the mqtt.default_user/mqtt.default_pass
      ## keys. Anonymous connections are highly discouraged!
      ##
      mqtt.allow_anonymous = false

      ## If you have multiple vhosts, specify the one to which the
      ## adapter connects.
      ##
      mqtt.vhost = /

      ## Specify the exchange to which messages from MQTT clients are published.
      ##
      mqtt.exchange = exchange_mqtt_topic

      ## Specify TTL (time to live) to control the lifetime of non-clean sessions.
      ##
      mqtt.subscription_ttl = 1800000

      ## Set the prefetch count (governing the maximum number of unacknowledged
      ## messages that will be delivered).
      ##
      mqtt.prefetch = 10

以上设置了:

  1. enabled_plugins添加rabbitmq_mqtt,rabbitmq_web_mqtt插件

  2. mqtt端口设置为1883
  3. mqtt的默认用户为bbbbbb,密码为111111,这里是使用用户
  4. mqtt不允许匿名登陆,allow_anonymous=false
  5. mqtt消息转成amqp的exchange:exchange_mqtt_topic

 

这样起来以后就支持mqtt了。

标签:11,default,插件,rabbimq3.11,##,rabbitmq,cluster,mqtt,user
From: https://www.cnblogs.com/zhanchenjin/p/17283099.html

相关文章

  • js 头像上传(图片截取) 插件 全屏高清版 源码
    先上图片 index.html<!DOCTYPEhtml><html><head><metaname="viewport"content="width=device-width"/><title>ccp</title><linkhref="Content/ccp.css"rel="stylesheet"......
  • Spark视频王家林第119课: Spark Streaming性能优化:如何在生产环境下应对流数据峰值巨变
    Spark视频王家林第119课:SparkStreaming性能优化:如何在生产环境下应对流数据峰值巨变?本节讲解SparkStreaming性能优化:如何在生产环境下应对流数据峰值巨变?数据峰值及流量变化的不稳定有2个层面:1)第一个层面就是数据确实不稳定,例如晚上11点的时候访问流量特别高,相对其他时间而言表......
  • jQuery图片放大镜插件jqzoom
    <html><head><title>JQzoomDemo</title><scriptsrc="../js/jquery-1.3.2.min.js"type="text/javascript"></script><scriptsrc="../js/jqzoom.pack.1.0.1.js"type="text/javascript"......
  • Eclipse中安装Velocity插件
    工具特性:   1)用户自定义模版   2)根据velocity的vtl和html的标签进行自动缩进   3)语法高亮显示   4)html标签和velocity语句的自动完成提示和内容帮助,   5)html预览   6)使用ctrl+alt+鼠标点击html的结束标签(如)或velocity......
  • 联芸mas0902固态使用量产工具的开卡方法,mas0902/mas1102开卡软件教程
    MAS0902是一款固态存储器芯片,一般固态硬盘损坏的情况下才需要量产,在量产过程中,需要从量产部落网下载对应主控型号和闪存颗粒类型的量产工具后,使用量产工具来对芯片进行初始化和测试。以下是MAS0902固态使用量产工具的开卡方法:1.首先,将采用MAS0902芯片的固态硬盘短接ROM孔后,连......
  • Maven 指定仓库和插件地址
    <repositories><repository><id>public</id><name>aliyunnexus</name><url>https://maven.aliyun.com/repository/public/</url><releases>......
  • 114.二叉树展开为链表 Java
    114.二叉树展开为链表给你二叉树的根结点root,请你将它展开为一个单链表:展开后的单链表应该同样使用TreeNode,其中right子指针指向链表中下一个结点,而左子指针始终为null。展开后的单链表应该与二叉树先序遍历顺序相同。示例1:输入:root=[1,2,5,3,4,null,6]输出......
  • Windows 11 如何安装 WSL2
    安装WSL2需要满足以下要求:64位版本的Windows10,包括:家庭版、专业版、企业版或教育版,版本号1903或更高版本,或者WindowsServer2019或更高版本。启用了WSL的选项。至少4GB的RAM在Windows11上安装WSL2的步骤如下:打开WindowsPowerShell作为管理员......
  • 221114-华中科技大学学位论文利用Pandoc实现LaTex转Word
    LaTex快乐地编辑排版好论文,然后学校系统提交还是要Word文档TT利用Pandoc将.tex直接转换成.docxpandochust_main.tex-ohust_main.docx-wdocx\--reference-dochust_temp.docx\--filterpandoc-crossref\--bibliography=main_ref.bib\--ci......
  • 221115-Word插入公式+自动编号+索引公式的最便捷方式(可能没有之一)
    结合参考文献中的两种方法,最终效果见视频:Word中插入公式及引用的最快捷的方式[可能没有之一]Step1:通过插入题注定制公式编号Step2:通过插入表格定制公式样式Step3:通过自动纠正定制快捷方法(⚠️:选中之前设置好的公式样式即可)参考文献:https://www.youtube.com/watch?v=4ocHER25os......