EMQ X 集群部署

news2024/11/18 11:23:39

EMQ X 消息服务器集群基于 Erlang/OTP 分布式设计,集群原理可简述为下述两条规则:

MQTT 客户端订阅主题时,所在节点订阅成功后广播通知其他节点:某个主题(Topic)被本节点订阅。

MQTT 客户端发布消息时,所在节点会根据消息主题(Topic),检索订阅并路由消息到相关节点。

1. 集群架构 #

EMQ X 消息服务器同一集群的所有节点,都会复制一份主题(Topic) -> 节点(Node)映射的路由表,例如:

topic1 -> node-01, node-02
topic2 -> node-03
topic3 -> node-02, node-04

复制成功!

2. 集群部署规划 #

item node 1 node 2 node 3
node.name node-01@127.0.0.1 node-02@127.0.0.1 node-03@127.0.0.1
mqtt:tcp:external 3000 3100 3200
mqtt:ssl:external 3010 3110 3210
mqtt:ws:external 3020 3120 3220
mqtt:wss:external 3030 3130 3230
http:management 3040 3140 3240
http:dashboard 3050 3150 3250
mqtt:tcp:internal 13000 13100 13200

3. 安装文件 #

下载文件

请下载 ubuntu zip 版本

  • 以 4.3.10 版本为例:https://www.emqx.com/zh/downloads/broker/4.3.10/emqx-ubuntu20.04-4.3.10-amd64.zip

  • 其他版本下载:https://www.emqx.com/zh/try?product=broker

解压文件

unzip emqx-ubuntu20.04-4.3.10-amd64.zip

复制成功!

4. 集群部署 #

4.1 创建文件目录 #

分别创建三个节点(node)目录,多个以此类推 node-N

cd /data

mkdir -p emqx/dc3/node-01 emqx/dc3/node-02 emqx/dc3/node-03

复制成功!

将解压的 emqx 文件放入到每个节点中,其他节点操作一致

cp -r emqx* emqx/dc3/node-01/

# pwd
# /data/emqx/dc3/node-01

# ls
# bin data dynlibs erts-11.1.8 etc lib log releases

复制成功!

4.2 配置文件 #

在每个节点的 etc 下配置文件 emqx.confplugins/emqx_dashboard.confplugins/emqx_management.conf

4.2.1 emqx.conf #
## EMQ X Configuration 4.3

## NOTE: Do not change format of CONFIG_SECTION_{BGN,END} comments!

## CONFIG_SECTION_BGN=cluster ==================================================

## Cluster name.
##
## Value: String
cluster.name = dc3-emqx-cluster

## Specify the erlang distributed protocol.
##
## Value: Enum
##  - inet_tcp: the default; handles TCP streams with IPv4 addressing.
##  - inet6_tcp: handles TCP with IPv6 addressing.
##  - inet_tls: using TLS for Erlang Distribution.
##
## vm.args: -proto_dist inet_tcp
cluster.proto_dist = inet_tcp

## Cluster auto-discovery strategy.
##
## Value: Enum
## - manual: Manual join command
## - static: Static node list
## - mcast:  IP Multicast
## - dns:    DNS A Record
## - etcd:   etcd
## - k8s:    Kubernetes
##
## Default: manual
cluster.discovery = manual

## Enable cluster autoheal from network partition.
##
## Value: on | off
##
## Default: on
cluster.autoheal = on

## Autoclean down node. A down node will be removed from the cluster
## if this value > 0.
##
## Value: Duration
## -h: hour, e.g. '2h' for 2 hours
## -m: minute, e.g. '5m' for 5 minutes
## -s: second, e.g. '30s' for 30 seconds
##
## Default: 5m
cluster.autoclean = 5m

##--------------------------------------------------------------------
## Cluster using static node list

## Node list of the cluster.
##
## Value: String
## cluster.static.seeds = emqx1@127.0.0.1,emqx2@127.0.0.1

##--------------------------------------------------------------------
## Cluster using IP Multicast.

## IP Multicast Address.
##
## Value: IP Address
## cluster.mcast.addr = 239.192.0.1

## Multicast Ports.
##
## Value: Port List
## cluster.mcast.ports = 4369,4370

## Multicast Iface.
##
## Value: Iface Address
##
## Default: 0.0.0.0
## cluster.mcast.iface = 0.0.0.0

## Multicast Ttl.
##
## Value: 0-255
## cluster.mcast.ttl = 255

## Multicast loop.
##
## Value: on | off
## cluster.mcast.loop = on

##--------------------------------------------------------------------
## Cluster using DNS A records.

## DNS name.
##
## Value: String
## cluster.dns.name = localhost

## The App name is used to build 'node.name' with IP address.
##
## Value: String
## cluster.dns.app = emqx

##--------------------------------------------------------------------
## Cluster using etcd

## Etcd server list, seperated by ','.
##
## Value: String
## cluster.etcd.server = http://127.0.0.1:2379

## The prefix helps build nodes path in etcd. Each node in the cluster
## will create a path in etcd: v2/keys/<prefix>/<cluster.name>/<node.name>
##
## Value: String
## cluster.etcd.prefix = dc3-emqx-cluster

## The TTL for node's path in etcd.
##
## Value: Duration
##
## Default: 1m, 1 minute
## cluster.etcd.node_ttl = 1m

## Path to a file containing the client's private PEM-encoded key.
##
## Value: File
## cluster.etcd.ssl.keyfile = etc/certs/client-key.pem

## The path to a file containing the client's certificate.
##
## Value: File
## cluster.etcd.ssl.certfile = etc/certs/client.pem

## Path to the file containing PEM-encoded CA certificates. The CA certificates
## are used during server authentication and when building the client certificate chain.
##
## Value: File
## cluster.etcd.ssl.cacertfile = etc/certs/ca.pem

##--------------------------------------------------------------------
## Cluster using Kubernetes

## Kubernetes API server list, seperated by ','.
##
## Value: String
## cluster.k8s.apiserver = http://10.110.111.204:8080

## The service name helps lookup EMQ nodes in the cluster.
##
## Value: String
## cluster.k8s.service_name = emqx

## The address type is used to extract host from k8s service.
##
## Value: ip | dns | hostname
## cluster.k8s.address_type = ip

## The app name helps build 'node.name'.
##
## Value: String
## cluster.k8s.app_name = emqx

## The suffix added to dns and hostname get from k8s service
##
## Value: String
## cluster.k8s.suffix = pod.cluster.local

## Kubernetes Namespace
##
## Value: String
## cluster.k8s.namespace = default

## CONFIG_SECTION_END=cluster ==================================================

##--------------------------------------------------------------------
## Node
##--------------------------------------------------------------------

## Node name.
##
## See: http://erlang.org/doc/reference_manual/distributed.html
##
## Value: <name>@<host>
##
## Default: node-01@127.0.0.1
node.name = node-01@127.0.0.1

## Cookie for distributed node communication.
##
## Value: String
node.cookie = emqxsecretcookie

## Data dir for the node
##
## Value: Folder
node.data_dir = data

## Heartbeat monitoring of an Erlang runtime system. Comment the line to disable
## heartbeat, or set the value as 'on'
##
## Turning this on may cause the node to restart if it becomes unresponsive to
## the heartbeat pings.
##
## NOTE: When managed by systemd (or other supervision tools like systemd),
##       heart will probably only cause EMQ X to stop, but restart or not will
##       depend on systemd's restart strategy.
## NOTE: When running in docker, the container will die as soon as the the
##       heart process kills EMQ X, but restart or not will depend on container
##       supervision strategy, such as k8s restartPolicy.
##
## Value: on
##
## vm.args: -heart
## node.heartbeat = on

## Sets the number of threads in async thread pool. Valid range is 0-1024.
##
## See: http://erlang.org/doc/man/erl.html
##
## Value: 0-1024
##
## vm.args: +A Number
## node.async_threads = 4

## Sets the maximum number of simultaneously existing processes for this
## system if a Number is passed as value.
##
## See: http://erlang.org/doc/man/erl.html
##
## Value: Number [1024-134217727]
##
## vm.args: +P Number
## node.process_limit = 2097152

## Sets the maximum number of simultaneously existing ports for this system.
##
## See: http://erlang.org/doc/man/erl.html
##
## Value: Number [1024-134217727]
##
## vm.args: +Q Number
## node.max_ports = 1048576

## Sets the distribution buffer busy limit (dist_buf_busy_limit).
##
## See: http://erlang.org/doc/man/erl.html
##
## Value: Number [1KB-2GB]
##
## vm.args: +zdbbl size
## node.dist_buffer_size = 8MB

## Sets the maximum number of ETS tables. Note that mnesia and SSL will
## create temporary ETS tables.
##
## Value: Number
##
## vm.args: +e Number
## node.max_ets_tables = 262144

## Global GC Interval.
##
## Value: Duration
##
## Examples:
##  - 2h:  2 hours
##  - 30m: 30 minutes
##  - 20s: 20 seconds
##
## Defaut: 15 minutes
node.global_gc_interval = 15m

## Tweak GC to run more often.
##
## Value: Number [0-65535]
##
## vm.args: -env ERL_FULLSWEEP_AFTER Number
## node.fullsweep_after = 1000

## Crash dump log file.
##
## Value: Log file
node.crash_dump = log/crash.dump

## Specify SSL Options in the file if using SSL for Erlang Distribution.
##
## Value: File
##
## vm.args: -ssl_dist_optfile <File>
## node.ssl_dist_optfile = etc/ssl_dist.conf

## Sets the net_kernel tick time. TickTime is specified in seconds.
## Notice that all communicating nodes are to have the same TickTime
## value specified.
##
## See: http://www.erlang.org/doc/man/kernel_app.html#net_ticktime
##
## Value: Number
##
## vm.args: -kernel net_ticktime Number
## node.dist_net_ticktime = 120

## Sets the port range for the listener socket of a distributed Erlang node.
## Note that if there are firewalls between clustered nodes, this port segment
## for nodes’ communication should be allowed.
##
## See: http://www.erlang.org/doc/man/kernel_app.html
##
## Value: Port [1024-65535]
node.dist_listen_min = 6369
node.dist_listen_max = 6369

node.backtrace_depth = 16

## CONFIG_SECTION_BGN=rpc ======================================================

## RPC Mode.
##
## Value: sync | async
rpc.mode = async

## Max batch size of async RPC requests.
##
## Value: Integer
## Zero or negative value disables rpc batching.
##
## NOTE: RPC batch won't work when rpc.mode = sync
rpc.async_batch_size = 256

## RPC port discovery
##
## The strategy for discovering the RPC listening port of other nodes.
##
## Value: Enum
## - manual: discover ports by `tcp_server_port` and `tcp_client_port`.
## - stateless: discover ports in a stateless manner.
##   If node name is `emqx<N>@127.0.0.1`, where the `<N>` is an integer,
##   then the listening port will be `5370 + <N>`
##
## Defaults to `stateless`.
rpc.port_discovery = stateless

## TCP port number for RPC server to listen on.
##
## Only takes effect when `rpc.port_discovery` = `manual`.
##
## NOTE: All nodes in the cluster should agree to this same config.
##
## Value: Port [1024-65535]
#rpc.tcp_server_port = 5369

## Number of outgoing RPC connections.
##
## Value: Interger [0-256]
## Default = 1
#rpc.tcp_client_num = 1

## RCP Client connect timeout.
##
## Value: Seconds
rpc.connect_timeout = 5s

## TCP send timeout of RPC client and server.
##
## Value: Seconds
rpc.send_timeout = 5s

## Authentication timeout
##
## Value: Seconds
rpc.authentication_timeout = 5s

## Default receive timeout for call() functions
##
## Value: Seconds
rpc.call_receive_timeout = 15s

## Socket idle keepalive.
##
## Value: Seconds
rpc.socket_keepalive_idle = 900s

## TCP Keepalive probes interval.
##
## Value: Seconds
rpc.socket_keepalive_interval = 75s

## Probes lost to close the connection
##
## Value: Integer
rpc.socket_keepalive_count = 9

## Size of TCP send buffer.
##
## Value: Bytes
rpc.socket_sndbuf = 1MB

## Size of TCP receive buffer.
##
## Value: Seconds
rpc.socket_recbuf = 1MB

## Size of user-level software socket buffer.
##
## Value: Seconds
rpc.socket_buffer = 1MB

## CONFIG_SECTION_END=rpc ======================================================

## CONFIG_SECTION_BGN=logger ===================================================

## Where to emit the logs.
## Enable the console (standard output) logs.
##
## Value: file | console | both
## - file: write logs only to file
## - console: write logs only to standard I/O
## - both: write logs both to file and standard I/O
log.to = file

## The log severity level.
##
## Value: debug | info | notice | warning | error | critical | alert | emergency
##
## Note: Only the messages with severity level higher than or equal to
##       this level will be logged.
##
## Default: warning
log.level = warning

## The dir for log files.
##
## Value: Folder
log.dir = log

## The log filename for logs of level specified in "log.level".
##
## If `log.rotation` is enabled, this is the base name of the
## files. Each file in a rotated log is named <base_name>.N, where N is an integer.
##
## Value: String
## Default: emqx.log
log.file = emqx.log

## Limits the total number of characters printed for each log event.
##
## Value: Integer
## Default: No Limit
#log.chars_limit = 8192

## Maximum depth for Erlang term log formatting
## and Erlang process message queue inspection.
##
## Value: Integer or 'unlimited' (without quotes)
## Default: 100
#log.max_depth = 100

## Log formatter
## Value: text | json
#log.formatter = text

## Log to single line
## Value: Boolean
#log.single_line = true

## Enables the log rotation.
## With this enabled, new log files will be created when the current
## log file is full, max to `log.rotation.size` files will be created.
##
## Value: on | off
## Default: on
log.rotation = on

## Maximum size of each log file.
##
## Value: Number
## Default: 10M
## Supported Unit: KB | MB | GB
log.rotation.size = 10MB

## Maximum rotation count of log files.
##
## Value: Number
## Default: 5
log.rotation.count = 5

## To create additional log files for specific log levels.
##
## Value: File Name
## Format: log.$level.file = $filename,
##         where "$level" can be one of: debug, info, notice, warning,
##                                       error, critical, alert, emergency
## Note: Log files for a specific log level will only contain all the logs
##       that higher than or equal to that level
##
#log.info.file  = info.log
#log.error.file = error.log

## The max allowed queue length before switching to sync mode.
##
## Log overload protection parameter. If the message queue grows
## larger than this value the handler switches f

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/803040.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

ICLR 2023 | 用于分布外泛化的拓扑感知鲁棒优化

论文链接&#xff1a;https://openreview.net/pdf?idylMq8MBnAp 代码链接&#xff1a;GitHub - joffery/TRO: The Pytorch implementation for "Topology-aware Robust Optimization for Out-of-Distribution Generalization" (ICLR 2023) 01. 研究背景 近年来&…

虹科分享 | 工业4.0:IO-Link wireless等先进通信技术是不可或缺的支柱

近年来&#xff0c;随着工业4.0&#xff08;工业革命4.0&#xff09;的提出&#xff0c;制造业转型浪潮拉开帷幕。工业4.0是将数字技术整合到传统的制造流程中&#xff0c;从而创建智能工厂。对此类工厂的最初要求是工厂各个层面的完全连接&#xff0c;从制造车间一直到管理和云…

重大更新|Sui主网即将上线流动性质押,助力资产再流通

Sui社区一直提议官方上线流动质押功能&#xff0c;现在通过SIP过程&#xff0c;已经升级该协议以实现这一功能。 Sui使用委托权益证明机制&#xff08;DPoS&#xff09;来选择和奖励负责运营网络的验证节点。为了保障网络安全&#xff0c;验证节点通过质押SUI token获得质押奖…

win10小任务栏显示日期

win10存在一个问题, 就是任务栏为小任务栏时, 无法显示系统日期, 只能显示时间, 对这个问题有两个办法, 1, 把小任务栏改为大任务栏, 日期就能显示出来 但如果你就是想用小任务栏, 不想用大任务栏, 又想显示日期, 只靠win10内置的设置是没法实现的, 只能借助其他软件, 具体看…

HTTP协议揭秘:探寻互联网的背后密码、探秘数据传输的奥秘

HTTP&#xff08;超文本传输协议&#xff1a;Hypertext Transfer Protocol&#xff09;是一种用于在Web上传输数据的协议&#xff0c;它是互联网上最重要的应用层协议之一。从诞生至今&#xff0c;HTTP一直扮演着连接世界的通信桥梁的角色&#xff0c;在互联网的发展和普及中发…

数组练习题,数组的动态初始化

数组的遍历 定义一个数组&#xff0c;求和 int[] arr {1,2,3,4,5,6,7};int sum 0;for (int i 0; i <arr.length ; i) {sum sum arr[i];}System.out.println(sum);定义一个数组&#xff0c;统计数组里面一共有多少能够被3 整除的数字&#xff1a; int[] arr1 {4,62,8…

JavaScript快速入门:ComPDFKit PDF SDK 快速构建 Web端 PDF阅读器

JavaScript快速入门&#xff1a;ComPDFKit PDF SDK 快速构建 Web端 PDF阅读器 在当今丰富的网络环境中&#xff0c;处理 PDF 文档已成为企业和开发人员的必需品。ComPDFKit 是一款支持 Web 平台并且功能强大的 PDF SDK&#xff0c;开发人员可以利用它创建 PDF 查看器和编辑器&…

了解Unity编辑器之组件篇Playables和Rendering(十)

Playables 一、Playable Director&#xff1a;是一种用于控制和管理剧情、动画和音频的工具。它作为一个中央控制器&#xff0c;可以管理播放动画剧情、视频剧情和音频剧情&#xff0c;以及它们之间的时间、顺序和交互。 Playable Director组件具有以下作用&#xff1a; 剧情控…

数据结构初阶--栈和队列

目录 一.栈 1.栈的定义 2.顺序栈的功能实现 2.1.顺序栈的定义 2.2.顺序栈的初始化 2.3.顺序栈的判空 2.4.顺序栈的入栈 2.5.顺序栈的出栈 2.6.顺序栈的取栈顶元素 2.7.顺序栈的求栈的大小 2.8.顺序栈的销毁 2.9.完整程序 Stack.h Stack.c test.c 二.队列 1.队…

S475支持 ModbusRTU 转 MQTT协议采集网关

6路模拟量输入和2路RS485串口是一种功能强大的通信接口&#xff0c;可以接入多种设备和系统&#xff0c;支持4-20mA输出的传感器以及开关量输入输出。本文将详细介绍6路模拟量输入和2路RS485串口的应用场景和功能&#xff0c;重点介绍其在SCADA、HMI、远程数据监控以及采集控制…

机器学习——样本不均衡学习

1、样本不均衡定义 一般在分类机器学习中&#xff0c;每种类别的样本是均衡的&#xff0c;也就是不同目标值的样本总量是接近的&#xff0c;但是在很多场景下的样本没有办法做到理想情况&#xff0c;甚至部分情况本身就是不均衡情况&#xff1a; &#xff08;1&#xff09;很多…

[洛谷]P2052 [NOI2011] 道路修建(dfs)

在递归过程中也把子节点的贡献&#xff08;以及左右国家数记录下来了&#xff09;。 void dfs(int u,int fa) {d[u]1;//当前节点也算一个 for(int ih[u]; i; ine[i]) {int toe[i];//子节点if(tofa) continue;//防止重复搜索&#xff0c;即防止从下往上搜dfs(to,u);//子节点 //…

基于SSM+JSP+LayUI的宿舍管理系统

修正初始账号密码 默认账号&#xff1a;admin&#xff0c;默认密码&#xff1a;123456修复后台管理头像消失功能相对简单些&#xff0c;可能需要添加一些功能&#xff0c;需要源码免费提供需要运行服务、添加功能等联系我

springboot开放实验室管理系统【纯干货分享,免费领源码03361】

摘 要 随着社会的发展&#xff0c;社会的方方面面都在利用信息化时代的优势。互联网的优势和普及使得各种系统的开发成为必需。 本文以实际运用为开发背景&#xff0c;运用软件工程原理和开发方法&#xff0c;它主要是使用动态网页开发技术java作为系统的开发语言&#xff0c;M…

如何挑选滚珠螺杆的润滑油脂?

滚珠螺杆在日常使用中&#xff0c;出现卡顿或者噪音等问题&#xff0c;不用担心&#xff0c;不是你的滚珠螺杆出了问题&#xff0c;而是润滑系统出了问题&#xff0c;提醒你应该更换润滑油了。那么&#xff0c;我们应该怎样挑选滚珠螺杆的润滑油呢&#xff1f; 一般建议用轴承润…

hive整合es,详细过程。

参考官网 Apache Hive integration | Elasticsearch for Apache Hadoop [7.17] | Elastic 官网的介绍很简单&#xff0c;我看了很多博客&#xff0c;写的也很简单&#xff0c;但是我搞了半天才勉强成功&#xff0c;分享下&#xff0c;免得各位多走弯路。 环境准备 官网也很…

K8S暴露pod内多个端口

K8S暴露pod内多个端口 一、背景 公司统一用的某个底包跑jar服务&#xff0c;只暴露了8080端口 二、需求 由于有些服务在启动jar服务后&#xff0c;会启动多个端口&#xff0c;除了8080端口&#xff0c;还有别的端口需要暴露&#xff0c;我这里就还需要暴露9999端口。 注&a…

mysql常用时间相关函数

在我们平常开发的工作中&#xff0c;我们在数据库中经常会用到时间相关的函数&#xff0c;比如格式化当前时间&#xff0c;求当前时间或者计算某个特定间隔后的时间&#xff0c;那么我们主要会用到哪些函数呢&#xff1f; 1&#xff1a;求当前时间&#xff1a; select now();…

Gradle build 失败后提示.lock文件,解决办法

在Gradle build失败之后时&#xff0c;有时候强制关闭AndroidStudio&#xff0c;再次打开build时&#xff0c;会提示各种.lock 文件问题&#xff0c;删除了一个还有下一个&#xff0c;而且路径不一样。 一般情况下是这两个文件夹下的lockfile影响继续build %GRADLE_HOME%/ca…

YoLoV7做图像分类/目标检测过程(附代码+详细操作说明)

一、准备数据 图像在my_1imgs中&#xff0c;一个是原图jpg&#xff0c;一个是用labelimg画的标签xml文件。&#xff08;这个画的是一个矩形框&#xff09; 把自己的数据集&#xff08;原图和标签准备好后&#xff09;&#xff0c;这两个文件复制到VOCdevkit中,ImageSets为空。 …