cluster

cluster

cluster.name

Type Default
string emqxcl
说明

集群名称。

cluster.proto_dist

Type Optional Value Default
enum inet_tcp, inet6_tcp, inet_tls inet_tcp
说明

分布式 Erlang 集群协议类型。可选值为:

  • inet_tcp: 使用 IPv4
  • inet6_tcp 使用 IPv6
  • inet_tls: 使用 TLS,需要与 node.ssl_dist_optfile 配置一起使用。

cluster.discovery

Type Optional Value Default
enum manual, static, mcast, dns, etcd, k8s manual
说明

集群节点发现方式。可选值为:

  • manual: 手动加入集群
  • static: 配置静态节点。配置几个固定的节点,新节点通过连接固定节点中的某一个来加入集群。
  • mcast: 使用 UDP 多播的方式发现节点。
  • dns: 使用 DNS A 记录的方式发现节点。
  • etcd: 使用 etcd 发现节点。
  • k8s: 使用 Kubernetes 发现节点。

cluster.autoheal

Type Optional Value Default
enum on, off on
说明

启用或关闭集群脑裂自动恢复机制。

cluster.autoclean

Type Default
duration 5m
说明

指定多久之后从集群中删除短线节点。

cluster.static.seeds

Type Default Example
string - emqx1@192.168.0.100,emqx2@192.168.0.101
说明

当使用 static 方式集群时,指定固定的节点列表,多个节点间使用逗号 , 分隔。

cluster.mcast.addr

Type Default
ipaddr 239.192.0.1
说明

当使用 mcast 方式集群时,指定多播地址。

cluster.mcast.ports

Type Default
string 4369
说明

当使用 mcast 方式集群时,指定多播端口。如有多个端口使用逗号 , 分隔。

cluster.mcast.iface

Type Default
ipaddr 0.0.0.0
说明

当使用 mcast 方式集群时,指定节点发现服务需要绑定到本地哪个 IP 地址。

cluster.mcast.ttl

Type Default
integer 255
说明

当使用 mcast 方式集群时,指定多播的 Time-To-Live 值。

cluster.mcast.loop

Type Optional Value Default
enum on, off on
说明

当使用 mcast 方式集群时,设置多播的报文是否投递到本地回环地址。

cluster.dns.name

Type Default Example
string - mycluster.com
说明

当使用 dns 方式集群时,指定 DNS A 记录的名字。emqx 会通过访问这个 DNS A 记录来获取 IP 地址列表,然后拼接 cluster.dns.app 里指定的 APP 名得到集群中所有节点的列表。

示例

设置 cluster.dns.app = emqx,并且配置了一个 DNS: mycluster.com,其指向 3 个 IP 地址:

192.168.0.100
192.168.0.101
192.168.0.102

则得到集群节点列表如下:

emqx@192.168.0.100
emqx@192.168.0.101
emqx@192.168.0.102

cluster.dns.app

Type Default Example
string - emqx
说明

当使用 dns 方式集群时,用来与从 cluster.dns.name 获取的 IP 列表拼接得到节点名列表。

cluster.etcd.server

Type Default Example
string - <http://127.0.0.1:2379>
说明

当使用 etcd 方式集群时,指定 etcd 服务的地址。如有多个服务使用逗号 , 分隔。

cluster.etcd.prefix

Type Default Example
string - emqxcl
说明

当使用 etcd 方式集群时,指定 etcd 路径的前缀。每个节点在 etcd 中都会创建一个路径:

v2/keys/<prefix>/<cluster.name>/<node.name>

cluster.etcd.node_ttl

Type Default Example
duration - 1m
说明

当使用 etcd 方式集群时,指定 etcd 中节点路径的过期时间。

cluster.etcd.ssl.keyfile

Type Default Example
string - etc/certs/client-key.pem
说明

当使用 SSL 连接 etcd 时,指定客户端的私有 Key 文件。

cluster.etcd.ssl.certfile

Type Default Example
string - etc/certs/client.pem
说明

当使用 SSL 连接 etcd 时,指定 SSL 客户端的证书文件。

cluster.etcd.ssl.cacertfile

Type Default Example
string - etc/certs/ca.pem
说明

当使用 SSL 连接 etcd 时,指定 SSL 的 CA 证书文件。

cluster.k8s.apiserver

Type Default Example
string - <http://10.110.111.204:8080>
说明

当使用 k8s 方式集群时,指定 Kubernetes API Server。如有多个 Server 使用逗号 , 分隔。

cluster.k8s.service_name

Type Default Example
string - emqx
说明

当使用 k8s 方式集群时,指定 Kubernetes 中 EMQ X 的服务名。

cluster.k8s.address_type

Type Optional Value Default
enum ip, dns, hostname ip
说明

当使用 k8s 方式集群时,address_type 用来从 Kubernetes 接口的应答里获取什么形式的 Host 列表。

示例

指定 cluster.k8s.address_type 为 ip,则将从 Kubernetes 接口中获取 emqx 服务的 IP 地址列表:

172.16.122.31
172.16.122.32
172.16.122.33

然后与 cluster.k8s.app_name 配置指定的 app name 拼接,得到 emqx 节点列表:

emqx@172.16.122.31
emqx@172.16.122.32
emqx@172.16.122.33

cluster.k8s.app_name

Type Default Example
string - emqx
说明

当使用 k8s 方式集群时,app_name 用来跟获取的 Host 列表拼接,得到节点列表。

cluster.k8s.suffix

Type Default Example
string - pod.cluster.local
说明

当使用 k8s 方式并且 cluster.k8s.address_type 指定为 dns 类型时,可设置 emqx 节点名的后缀。与 cluster.k8s.namespace 一起使用用以拼接得到节点名列表。

cluster.k8s.namespace

Type Default Example
string - default
说明

当使用 k8s 方式并且 cluster.k8s.address_type 指定为 dns 类型时,可设置 emqx 节点名的命名空间。与 cluster.k8s.suffix 一起使用用以拼接得到节点名列表。

示例

设置 cluster.k8s.address_type 为 dns,则将从 Kubernetes 接口中获取 emqx 服务的 dns 列表:

172-16-122-31
172-16-122-32
172-16-122-33

然后拼接上 cluster.k8s.app_name = emqx,cluster.k8s.suffix = pod.cluster.local,cluster.k8s.namespace = default 得到 dns 形式的 emqx 节点名列表:

emqx@172-16-122-31.default.pod.cluster.local
emqx@172-16-122-32.default.pod.cluster.local
emqx@172-16-122-33.default.pod.cluster.local