- 参数配置列表
- 配置项
- Cluster
- cluster.name
- cluster.proto_dist
- cluster.discovery
- cluster.autoheal
- cluster.autoclean
- cluster.static.seeds
- cluster.mcast.addr
- cluster.mcast.ports
- cluster.mcast.iface
- cluster.mcast.ttl
- cluster.mcast.loop
- cluster.dns.name
- cluster.dns.app
- cluster.etcd.server
- cluster.etcd.prefix
- cluster.etcd.node_ttl
- cluster.etcd.ssl.keyfile
- cluster.etcd.ssl.certfile
- cluster.etcd.ssl.cacertfile
- cluster.k8s.apiserver
- cluster.k8s.service_name
- cluster.k8s.address_type
- cluster.k8s.app_name
- cluster.k8s.suffix
- cluster.k8s.namespace
- Node
- node.name
- node.cookie
- node.data_dir
- node.heartbeat
- node.async_threads
- node.process_limit
- node.max_ports
- node.dist_buffer_size
- node.max_ets_tables
- node.global_gc_interval
- node.fullsweep_after
- node.crash_dump
- node.ssl_dist_optfile
- node.dist_net_ticktime
- node.dist_use_interface
- node.dist_listen_min
- node.dist_listen_max
- RPC
- rpc.mode
- rpc.async_batch_size
- rpc.port_discovery
- rpc.tcp_server_ip
- rpc.tcp_server_port
- rpc.tcp_client_num
- rpc.connect_timeout
- rpc.send_timeout
- rpc.authentication_timeout
- rpc.call_receive_timeout
- rpc.socket_keepalive_idle
- rpc.socket_keepalive_interval
- rpc.socket_keepalive_count
- rpc.socket_sndbuf
- rpc.socket_recbuf
- rpc.socket_buffer
- Log
- authacl
- mqtt
- zoneexternal
- zone.external.idle_timeout
- zone.external.enable_acl
- zone.external.enable_ban
- zone.external.enable_stats
- zone.external.acl_deny_action
- zone.external.force_gc_policy
- zone.external.force_shutdown_policy
- zone.external.max_packet_size
- zone.external.max_clientid_len
- zone.external.max_topic_levels
- zone.external.max_qos_allowed
- zone.external.max_topic_alias
- zone.external.retain_available
- zone.external.wildcard_subscription
- zone.external.shared_subscription
- zone.external.server_keepalive
- zone.external.keepalive_backoff
- zone.external.max_subscriptions
- zone.external.upgrade_qos
- zone.external.max_inflight
- zone.external.retry_interval
- zone.external.max_awaiting_rel
- zone.external.await_rel_timeout
- zone.external.session_expiry_interval
- zone.external.max_mqueue_len
- zone.external.mqueue_priorities
- zone.external.mqueue_default_priority
- zone.external.mqueue_store_qos0
- zone.external.enable_flapping_detect
- zone.external.mountpoint
- zone.external.use_username_as_clientid
- zone.external.ignore_loop_deliver
- zone.external.strict_mode
- zoneinternal
- zone.internal.allow_anonymous
- zone.internal.enable_stats
- zone.internal.enable_acl
- zone.internal.acl_deny_action
- zone.internal.force_gc_policy
- zone.internal.wildcard_subscription
- zone.internal.shared_subscription
- zone.internal.max_subscriptions
- zone.internal.max_inflight
- zone.internal.max_awaiting_rel
- zone.internal.max_mqueue_len
- zone.internal.mqueue_store_qos0
- zone.internal.enable_flapping_detect
- zone.internal.force_shutdown_policy
- zone.internal.mountpoint
- zone.internal.ignore_loop_deliver
- zone.internal.strict_mode
- zone.internal.bypass_auth_plugins
- tcpexternal
- listener.tcp.external
- listener.tcp.external.acceptors
- listener.tcp.external.max_connections
- listener.tcp.external.max_conn_rate
- listener.tcp.external.active_n
- listener.tcp.external.zone
- listener.tcp.external.rate_limit
- listener.tcp.external.access.1
- listener.tcp.external.proxy_protocol
- listener.tcp.external.proxy_protocol_timeout
- listener.tcp.external.peer_cert_as_username
- listener.tcp.external.peer_cert_as_clientid
- listener.tcp.external.backlog
- listener.tcp.external.send_timeout
- listener.tcp.external.send_timeout_close
- listener.tcp.external.recbuf
- listener.tcp.external.sndbuf
- listener.tcp.external.buffer
- listener.tcp.external.tune_buffer
- listener.tcp.external.nodelay
- listener.tcp.external.reuseaddr
- tcpinternal
- listener.tcp.internal
- listener.tcp.internal.acceptors
- listener.tcp.internal.max_connections
- listener.tcp.internal.max_conn_rate
- listener.tcp.internal.active_n
- listener.tcp.internal.zone
- listener.tcp.internal.rate_limit
- listener.tcp.internal.backlog
- listener.tcp.internal.send_timeout
- listener.tcp.internal.send_timeout_close
- listener.tcp.internal.recbuf
- listener.tcp.internal.sndbuf
- listener.tcp.internal.buffer
- listener.tcp.internal.tune_buffer
- listener.tcp.internal.nodelay
- listener.tcp.internal.reuseaddr
- tlsexternal
- listener.ssl.external
- listener.ssl.external.acceptors
- listener.ssl.external.max_connections
- listener.ssl.external.max_conn_rate
- listener.ssl.external.active_n
- listener.ssl.external.zone
- listener.ssl.external.access.1
- listener.ssl.external.rate_limit
- listener.ssl.external.proxy_protocol
- listener.ssl.external.proxy_protocol_timeout
- listener.ssl.external.tls_versions
- listener.ssl.external.handshake_timeout
- listener.ssl.external.depth
- listener.ssl.external.key_password
- listener.ssl.external.keyfile
- listener.ssl.external.certfile
- listener.ssl.external.cacertfile
- listener.ssl.external.enable_ocsp_stapling
- listener.ssl.external.ocsp_responder_url
- listener.ssl.external.ocsp_issuer_pem
- listener.ssl.external.ocsp_refresh_interval
- listener.ssl.external.ocsp_refresh_http_timeout
- listener.ssl.external.enable_crl_check
- listener.ssl.external.crl_cache_urls
- crl_cache_http_timeout
- crl_cache_refresh_interval
- listener.ssl.external.dhfile
- listener.ssl.external.verify
- listener.ssl.external.fail_if_no_peer_cert
- listener.ssl.external.ciphers
- listener.ssl.external.psk_ciphers
- listener.ssl.external.secure_renegotiate
- listener.ssl.external.reuse_sessions
- listener.ssl.external.honor_cipher_order
- listener.ssl.external.peer_cert_as_username
- listener.ssl.external.peer_cert_as_clientid
- listener.ssl.external.backlog
- listener.ssl.external.send_timeout
- listener.ssl.external.send_timeout_close
- listener.ssl.external.recbuf
- listener.ssl.external.sndbuf
- listener.ssl.external.buffer
- listener.ssl.external.tune_buffer
- listener.ssl.external.nodelay
- listener.ssl.external.reuseaddr
- wsexternal
参数配置列表
配置项
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: 使用 IPv4inet6_tcp使用 IPv6inet_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 中 EMQX 的服务名。
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
Node
node.name
| Type | Default |
|---|---|
| string | emqx@127.0.0.1 |
说明
节点名。格式为 <name>@<host>。其中 <host> 可以是 IP 地址,也可以是 FQDN。详见 http://erlang.org/doc/reference_manual/distributed.html
(opens new window)。
node.cookie
| Type | Default |
|---|---|
| string | emqxsecretcookie |
说明
分布式 Erlang 集群使用的 cookie 值。
node.data_dir
| Type | Default |
|---|---|
| folder | ./data |
说明
节点的 data 目录,用于存放 Mnesia 数据文件等。
node.heartbeat
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
off |
说明
系统调优参数,此配置将覆盖 vm.args 文件里的 -heart 参数。
启用或关闭 Erlang 运行时检测机制,并在运行时终止时自动重启。需小心使用,以免手动关闭 emqx 时被监控进程重新启动。
node.async_threads
| Type | Optional Value | Default |
|---|---|---|
| integer | 0 - 1024 | 4 |
说明
系统调优参数,此配置将覆盖 vm.args 文件里的 +A 参数。
设置 Erlang 运行时异步线程池中的线程数量。详情请参见 http://erlang.org/doc/man/erl.html
(opens new window)。
node.process_limit
| Type | Optional Value | Default |
|---|---|---|
| integer | 1024 - 134217727 | 2097152 |
说明
系统调优参数,此配置将覆盖 vm.args 文件里的 +P 参数。
设置 Erlang 允许的最大进程数,这将影响 emqx 节点能处理的连接数。详情请参见 http://erlang.org/doc/man/erl.html
(opens new window)。
node.max_ports
| Type | Optional Value | Default |
|---|---|---|
| integer | 1024 - 134217727 | 1048576 |
说明
系统调优参数,此配置将覆盖 vm.args 文件里的 +Q 参数。
设置 Erlang 允许的最大 Ports 数量。详情请参见 http://erlang.org/doc/man/erl.html
(opens new window)。
node.dist_buffer_size
| Type | Optional Value | Default |
|---|---|---|
| bytesize | 1KB - 2GB | 8MB |
说明
系统调优参数,此配置将覆盖 vm.args 文件里的 +zdbbl 参数。
设置 Erlang 分布式通信使用的最大缓存大小。详情请参见 http://erlang.org/doc/man/erl.html
(opens new window)。
node.max_ets_tables
| Type | Default |
|---|---|
| integer | 262144 |
说明
系统调优参数,此配置将覆盖 vm.args 文件里的 +e 参数。
设置 Erlang 运行时允许的最大 ETS 表数量。详情请参见 http://erlang.org/doc/man/erl.html
(opens new window)。
node.global_gc_interval
| Type | Default |
|---|---|
| duration | 15m |
说明
系统调优参数,设置 Erlang 运行多久强制进行一次全局垃圾回收。
node.fullsweep_after
| Type | Optional Value | Default |
|---|---|---|
| integer | 0 - 65535 | 1000 |
说明
系统调优参数,此配置将覆盖 vm.args 文件里的 -env ERL_FULLSWEEP_AFTER 参数。
设置 Erlang 运行时多少次 generational GC 之后才进行一次 fullsweep GC。详情请参见 http://erlang.org/doc/man/erlang.html#spawn_opt-4
(opens new window)。
node.crash_dump
| Type | Default |
|---|---|
| string | log/crash.dump |
说明
设置 Erlang crash_dump 文件的存储路径和文件名。
node.ssl_dist_optfile
| Type | Default |
|---|---|
| string | etc/ssl_dist.conf |
说明
此配置将覆盖 vm.args 文件里的 -ssl_dist_optfile 参数。
如使用 SSL 方式建立 emqx 集群,需指定 SSL 分布式协议的配置文件。需要与 cluster.proto_dist = inet_tls 一起使用。
node.dist_net_ticktime
| Type | Default |
|---|---|
| integer | 120 |
说明
系统调优参数,此配置将覆盖 vm.args 文件里的 -kernel net_ticktime 参数。
当一个节点持续无响应多久之后,认为其已经宕机并断开连接。详情请参见 http://www.erlang.org/doc/man/kernel_app.html#net_ticktime
(opens new window)。
node.dist_use_interface
| Type | Default |
|---|---|
| ipaddr | 0.0.0.0 |
说明
节点间通讯网卡,默认使用 0.0.0.0 指定监听所有的网卡,或在指定需要监听网卡的 IP。
node.dist_listen_min
| Type | Optional Value | Default |
|---|---|---|
| integer | 1024 - 65535 | 6369 |
说明
与 node.dist_listen_max 一起设定一个 TCP 端口段,此端口段用于分配给分布式 Erlang,作为分布式通道的监听端口。注意如果在节点之间设置了防火墙,需要将此端口段放进防火墙的端口白名单里。
node.dist_listen_max
| Type | Optional Value | Default |
|---|---|---|
| integer | 1024 - 65535 | 6369 |
说明
与 node.dist_listen_min 一起设定一个 TCP 端口段,此端口段用于分配给分布式 Erlang,作为分布式通道的监听端口。注意如果在节点之间设置了防火墙,需要将此端口段放进防火墙的端口白名单里。
RPC
rpc.mode
| Type | Optional Value | Default |
|---|---|---|
| enum | sync, async |
async |
说明
RPC 模式。可选同步或异步模式。
rpc.async_batch_size
| Type | Default |
|---|---|
| integer | 256 |
说明
异步模式下最大的批量发送消息数。注意此配置在同步模式下不起作用。
rpc.port_discovery
| Type | Optional Value Default |
|---|---|
| enum | manual, stateless |
说明
manual: 手动指定服务器客户端的端口号 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>
Default is manual when started from docker (environment variable override from docker-entrypoint) otherwise stateless.
rpc.tcp_server_ip
| Type | Optional Value | Default |
|---|---|---|
| ipaddr | [0-255].[0-255].[0-255].[0-255] | 0.0.0.0 |
说明
设置 RPC 本地服务使用的监听网卡。默认使用 0.0.0.0 指定监听所有的网卡,或在指定需要监听网卡的 IP。
rpc.tcp_server_port
| Type | Optional Value | Default |
|---|---|---|
| integer | 1024 - 65535 | 5369 |
说明
设置 RPC 本地服务使用的监听 port。 注意,该配置仅在 rpc.port_discovery 设置成 manual 时有效
rpc.tcp_client_num
| Type | Optional Value | Default |
|---|---|---|
| integer | 1 - 256 | CPU 核心数 / 2 |
说明
设置由本节点发起,通往每个远程节点的 RPC 通信通道数量。设置为 1 可保证消息顺序。保持默认值(CPU 核心数的一半)可提高 RPC 的吞吐能力。
rpc.connect_timeout
| Type | Default |
|---|---|
| duration | 5s |
说明
建立 RPC 连接超时时间。建立连接时若远程节点无响应,多久之后放弃尝试。
rpc.send_timeout
| Type | Default |
|---|---|
| duration | 5s |
说明
发送超时时间。发送消息多久之后放弃。
rpc.authentication_timeout
| Type | Default |
|---|---|
| duration | 5s |
说明
RPC 认证超时时间。尝试认证若远程节点无响应,多久之后放弃。
rpc.call_receive_timeout
| Type | Default |
|---|---|
| duration | 15s |
说明
RPC 同步模式的超时时间。RPC 同步调用若收不到回复,用多久之后放弃。
rpc.socket_keepalive_idle
| Type | Default |
|---|---|
| duration | 900s |
说明
在最近一次数据包发送多久之后,发送 keepalive 探测报文。
rpc.socket_keepalive_interval
| Type | Default |
|---|---|
| duration | 75s |
说明
发送 keepalive 探测报文的间隔。
rpc.socket_keepalive_count
| Type | Default |
|---|---|
| integer | 9 |
说明
连续多少次 keepalive 探测报文都收不到回复的情况下,认为 RPC 连接已丢失。
rpc.socket_sndbuf
| Type | Default |
|---|---|
| bytesize | 1MB |
说明
TCP 调优参数。TCP 发送缓冲区大小。
rpc.socket_recbuf
| Type | Default |
|---|---|
| bytesize | 1MB |
说明
TCP 调优参数。TCP 接收缓冲区大小。
rpc.socket_buffer
| Type | Default |
|---|---|
| bytesize | 1MB |
说明
TCP 调优参数。用户态的 Socket 缓冲区大小。
Log
log.to
| Type | Optional Value | Default |
|---|---|---|
| enum | off, file, console, both |
file |
说明
将日志输出到什么地方。可选值为:
-
off: 完全关闭日志功能
-
file: 仅将日志输出到文件
-
console: 仅将日志输出到标准输出(emqx 控制台)
-
both: 同时将日志输出到文件和标准输出(emqx 控制台)
log.level
| Type | Optional Value | Default |
|---|---|---|
| enum | debug, info, notice, warning |
|
error, critical, alert, emergency |
warning |
说明
全局的日志级别。这包括 primary log level 以及所有的 log handlers。详情请参见 日志级别和 log handlers。
log.dir
| Type | Default |
|---|---|
| dir | ./log |
说明
日志文件目录。
log.file
| Type | Default |
|---|---|
| string | emqx.log |
说明
日志文件的前缀。例如,若使用默认值 (log.file = emqx.log),日志文件名将为 emqx.log.1,emqx.log.2,…。
log.chars_limit
| Type | Default |
|---|---|
| integer | -1 |
说明
设置单个日志消息的最大长度。如超过此长度,日志消息将被截断。-1 表示无限制。
log.max_depth
| Type | Default |
|---|---|
| union(integer, ‘unlimited’) | 20 |
Description
控制 Eralng 数据结构的打印深度,和 Erlang 进程消息队列查看的深度。 或配置成 ‘unlimited’ (不带引号) 不限深度打印。
log.rotation.size
| Type | Default |
|---|---|
| bytesize | 10MB |
说明
设置单个日志文件大小。如超过此大小,则进行日志文件滚动,创建新的日志文件。
log.rotation.count
| Type | Default |
|---|---|
| integer | 5 |
说明
设置日志文件总个数。如超过此文件个数,则下一次日志文件滚动将会覆盖第一个文件。
log.<level>.file
| Type | Default |
|---|---|
| string | - |
说明
针对某日志级别设置单独的日志文件。
示例
将 info 及 info 以上的日志单独输出到 info.log.N 文件中:
log.info.file = info.log
将 error 及 error 以上的日志单独输出到 error.log.N 文件中
log.error.file = error.log
log.max_depth
| Type | Default |
|---|---|
| integer | 20 |
说明
控制对大的数据结构打印日志时的最大深度。超过深度的部分将被 ‘…’ 代替。
log.single_line
| Type | Default |
|---|---|
| boolean | true |
说明
设置成 true 时,单行打印日志。 如果设置成 false, 如 crash 日志中的堆栈信息等将打印多行
log.formatter
| Type | Optional Value | Default |
|---|---|---|
| enum | text, json |
text |
说明
选择打印日志的格式
log.formatter.text.date.format
| Type | Optional Value | Default |
|---|---|---|
| enum | rfc3339 |
FORMAT |
注意: 这个配置在 EMQX 开源版 4.3.15, 4.4.4 和 EMQX 企业版 4.3.10, 4.4.4 及之后可以使用。
说明
指定 text logger 的时间戳格式。可以是 rfc3339 或者 FORMAT 字符串。
其中 FORMAT 里支持的控制符如下:
| 控制符 | 说明 | 格式示例 |
|---|---|---|
| %Y | 年 | 2022 |
| %m | 月 (01..12) | 11 |
| %d | 日 | 01 |
| %H | 时 (00..23) | 06 |
| %M | 分 (00..59) | 43 |
| %S | 秒 (00..60) | 31 |
| %N | 纳秒 (000000000..999999999) | 019085000 |
| %6N | 微秒 (00000..999999) | 019085 |
| %3N | 毫秒 (000..999) | 019 |
| %z | +HHMM 数字时区 | -0400 |
| %:z | +HH:MM 数字时区 | -04:00 |
| %::z | +HH:MM:SS 数字时区 | -04:00:00 |
举例:
## 2022-06-02T14:23:09.230000 +08:00
log.formatter.text.date.format = %Y-%m-%dT%H:%M:%S.%6N %:z
## 如下配置可以让时间戳跟 4.2.x 版本的一样 (2022-06-02 14:24:36.124):
log.formatter.text.date.format = %Y-%m-%d %H:%M:%S.%3N
authacl
allow_anonymous
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
true |
说明
是否允许匿名用户登录系统。
注:生产环境建议关闭此选项。
acl_nomatch
| Type | Optional Value | Default |
|---|---|---|
| enum | allow, deny |
allow |
说明
ACL 未命中时,允许或者拒绝 发布/订阅 操作。
acl_file
| Type | Default |
|---|---|
| string | etc/acl.conf |
说明
默认 ACL 文件的路径。
enable_acl_cache
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
on |
说明
是否启用 ACL 缓存。
acl_cache_max_size
| Type | Default |
|---|---|
| integer | 32 |
说明
ACL 规则最大缓存条数。
acl_cache_ttl
| Type | Default |
|---|---|
| duration | 1m |
说明
ACL 规则最大缓存时间。
acl_deny_action
| Type | Optional Value | Default |
|---|---|---|
| enum | ignore, disconnect |
ignore |
说明
ACL 检查失败后,执行的操作。
ignore:不做任何操作。disconnect:断开连接。
alias_enrichment_module
| Type | Default |
|---|---|
| string | - |
说明
Tip
这是一个非常特殊的高级选项,除非 EMQ 推荐,否则不应该使用。
在 “4.4.11 “中引入。
指定一个定义了 enrich_with_aliases/2 函数的模块。 这个函数会被用来添加客户端的 ID 和证书通用名(CN)的别名等信息。
special_auth_module
| Type | Default |
|---|---|
| string | - |
说明
Tip
这是一个特殊的高级选项,除非 EMQ 推荐,否则不应该使用。
在 “4.4.11 “中引入。
指定一个实现了 check_authn/2 函数的模块。 这个 该函数将被用于 client.authenticate 钩子,作为一种实现自定义认证逻辑的方式。
acl_order
| Type | Default |
|---|---|
| string | none |
Description
配置多个 ACL 后端时,可以使用该配置来指定检查的顺序。 默认值 none 表示未定义任何顺序。使用逗号分隔多个后端名称(或别名)。 例如 jwt,http 表示先检查 jwt,再检查 http。 支持的名称有:internal(或 file)、http、jwt、ldap、mnesia、mongo(或 mongodb)、mysql、pgsql(或 postgres)、redis。 指定顺序的后端总是排在未指定顺序的前面,例如如果使用了 mnesia,jwt 和 http,但是在配置中仅指定了 jwt,http,那么 mnesia 会排在最后。 如果使用了第三方插件,则必需使用具体的回调模块名称,例如 my_auth_plugin_module。
Tip
无法识别的名字会被忽略。
auth_order
| Type | Default |
|---|---|
| string | none |
Description
置多个认证后端时,可以使用该配置来指定检查的顺序。 默认值 none 表示未定义任何顺序。使用逗号分隔多个后端名称(或别名)。 配置使用与 acl_order 类似,只是认证没有 internal 这个后端。
Tip
无法识别的名字会被忽略。
flapping_detect_policy
| Type | Default |
|---|---|
| string | 30, 1m, 5m |
说明
指定 Flapping 检查策略。
格式:<threshold>,<duration>,<banned>。
例如,30, 1m, 5m,它表示如果客户端在 1 分钟内断开连接 30 次,那么在后续 5 分钟内禁止登录。
mqtt
mqtt.max_packet_size
| Type | Default |
|---|---|
| bytesize | 1MB |
说明
允许的 MQTT 报文最大长度。
mqtt.max_clientid_len
| Type | Default |
|---|---|
| integer | 65535 |
说明
允许的 Client ID 串的最大长度。
mqtt.max_topic_levels
| Type | Default |
|---|---|
| integer | 128 |
说明
允许客户端订阅主题的最大层级。0 表示不限制。
Warning
Topic层级过多可能导致订阅时的性能问题。
mqtt.max_qos_allowed
| Type | Optional Value | Default |
|---|---|---|
| enum | 0, 1, 2 |
2 |
说明
允许客户端发布的最大 QoS 等级。
mqtt.max_topic_alias
| Type | Default |
|---|---|
| integer | 65535 |
说明
允许最大的主题别名数。0 表示不支持主题别名。
mqtt.retain_available
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
true |
说明
是否支持 Retain 消息。
mqtt.wildcard_subscription
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
true |
说明
是否支持订阅通配主题。
mqtt.shared_subscription
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
true |
说明
是否支持共享订阅。
mqtt.ignore_loop_deliver
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
false |
说明
是否忽略自己发送的消息。如果忽略,则表明 EMQX 不会向消息的发送端投递此消息。
mqtt.strict_mode
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
false |
说明
是否开启严格检查模式。严格检查模式会更细致的检查 MQTT 报文的正确性。
zoneexternal
zone.external.idle_timeout
| Type | Default |
|---|---|
| duration | 15s |
说明
TCP 连接建立后的发呆时间,如果这段时间内未收到任何报文,则会关闭该连接。
zone.external.enable_acl
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
on |
说明
是否开启 ACL 检查。
zone.external.enable_ban
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
on |
说明
是否开启黑名单。
zone.external.enable_stats
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
on |
说明
是否开启客户端状态统计。
zone.external.acl_deny_action
| Type | Optional Value | Default |
|---|---|---|
| enum | ignore, disconnect |
ignore |
说明
ACL 检查失败后,执行的操作。
ignore:不做任何操作。disconnect:断开连接。
zone.external.force_gc_policy
| Type | Default |
|---|---|
| string | 16000|16MB |
说明
当收到一定数量的消息,或字节,就强制执行一次垃圾回收。
格式:<Number>|<Bytes>。
例如,16000|16MB 表示当收到 16000 条消息,或 16MB 的字节流入就强制执行一次垃圾回收。
zone.external.force_shutdown_policy
| Type | Default |
|---|---|
| string | - |
说明
当进程消息队列长度,或占用的内存字节到达某值,就强制关闭该进程。
这里的 消息队列 指的是 Erlang 进程的 消息邮箱,并非 QoS 1 和 QoS 2 的 mqueue。
格式:<Number>|<Bytes>。
例如,32000|32MB 表示当进程堆积了 32000 条消息,或进程占用内存达到 32MB 则关闭该进程。
zone.external.max_packet_size
| Type | Default |
|---|---|
| bytesize | - |
说明
允许的 MQTT 报文最大长度。
zone.external.max_clientid_len
| Type | Default |
|---|---|
| integer | - |
说明
允许的 Client ID 串的最大长度。
zone.external.max_topic_levels
| Type | Default |
|---|---|
| integer | - |
说明
允许客户端订阅主题的最大层级。0 表示不限制。
Warning
Topic层级过多可能导致订阅时的性能问题。
zone.external.max_qos_allowed
| Type | Optional Value | Default |
|---|---|---|
| enum | 0, 1, 2 |
- |
说明
允许客户端发布的最大 QoS 等级。
zone.external.max_topic_alias
| Type | Default |
|---|---|
| integer | - |
说明
允许最大的主题别名数。0 表示不支持主题别名。
zone.external.retain_available
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
- |
说明
是否支持 Retain 消息。
zone.external.wildcard_subscription
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
- |
说明
是否支持订阅通配主题。
zone.external.shared_subscription
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
- |
说明
是否支持共享订阅。
zone.external.server_keepalive
| Type | Default |
|---|---|
| integer | - |
说明
服务端指定的 Keepalive 时间。用于 MQTT v5.0 协议的 CONNACK 报文。
zone.external.keepalive_backoff
| Type | Optional Value | Default |
|---|---|---|
| float | > 0.5 | 0.75 |
说明
Keepalive 退避指数。EMQX 如果在 Keepalive * backoff * 2 的时间内未收到客户端的任何数据报文,则认为客户端已心跳超时。
zone.external.max_subscriptions
| Type | Default |
|---|---|
| integer | 0 |
说明
单个客户端允许订阅的最大主题数。0 表示不限制。
zone.external.upgrade_qos
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
off |
说明
允许 EMQX 在投递消息时,强制升级消息的 QoS 等级为订阅的 QoS 等级。
zone.external.max_inflight
| Type | Default |
|---|---|
| integer | 32 |
说明
飞行窗口大小。飞行窗口用于存储未被应答的 QoS 1 和 QoS 2 消息。
zone.external.retry_interval
| Type | Default |
|---|---|
| duration | 30s |
说明
消息重发间隔。EMQX 在每个间隔检查是否需要进行消息重发。
zone.external.max_awaiting_rel
| Type | Default |
|---|---|
| integer | 100 |
说明
QoS 2 消息的最大接收窗口,配置 EMQX 能够同时处理多少从客户端发来的 QoS 2 消息。0 表示不限制。
zone.external.await_rel_timeout
| Type | Default |
|---|---|
| duration | 300s |
说明
QoS 2 消息处理超时时间,在超时后若还未收到 QoS 的 PUBREL 报文,则将消息从接收窗口中丢弃。
zone.external.session_expiry_interval
| Type | Default |
|---|---|
| duration | 2h |
说明
会话默认超时时间,主要用于 MQTT v3.1 和 v3.1.1 协议。在 MQTT v5.0 中,该值通常会携带在客户端的连接报文中。
zone.external.max_mqueue_len
| Type | Default |
|---|---|
| integer | 1000 |
说明
消息队列最大长度。当飞行窗口满,或客户端离线后,消息会被存储至该队列中。0 表示不限制。
zone.external.mqueue_priorities
| Type | Optional Value | Default |
|---|---|---|
| string | none, <Spec> |
none |
说明
队列消息优先级配置:
none:表示无优先级区分。<Spec>:表示为一个消息优先表,它配置了某主题下消息的优先级。例如:topic/1=10:表示主题topic/1的消息优先级为10。topic/1=10,topic/2=8:表示配置了两个主题的优先级,其分别为10和8。- 其中,优先级数值越高,优先等级越高。
当消息队列长度有限时,会优先丢弃低优先级的消息。
zone.external.mqueue_default_priority
| Type | Optional Value | Default |
|---|---|---|
| enum | highest, lowest |
highest |
说明
消息默认的优先等级。
zone.external.mqueue_store_qos0
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
true |
说明
消息队列是否存储 QoS 0 消息。
zone.external.enable_flapping_detect
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
off |
说明
是否开启 Flapping 检查。
zone.external.mountpoint
| Type | Default |
|---|---|
| string | - |
说明
主题挂载点。配置后,所有订阅和发布的主题在 EMQX 都会为其增加一个前缀。
其中可用的占位符有:
%c:表示客户端的 Client ID。%u:表示客户端的 Username。
例如,配置挂载点为 user/%c/。那么 Client ID 为 tom 的客户端在发布主题 open 消息时,实际在 EMQX 中路由的主题是 user/tom/open。
zone.external.use_username_as_clientid
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
false |
说明
是否用客户端的 Username 作为其 Client ID。
zone.external.ignore_loop_deliver
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
false |
说明
是否忽略自己发送的消息。如果忽略,则表明 EMQX 不会向消息的发送端投递此消息。
zone.external.strict_mode
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
false |
说明
是否开启严格检查模式。严格检查模式会更细致的检查 MQTT 报文的正确性。
zoneinternal
zone.internal.allow_anonymous
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
true |
说明
是否允许匿名用户登录系统。
zone.internal.enable_stats
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
on |
说明
是否开启客户端状态统计。
zone.internal.enable_acl
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
off |
说明
是否开启 ACL 检查。
zone.internal.acl_deny_action
| Type | Optional Value | Default |
|---|---|---|
| enum | ignore, disconnect |
ignore |
说明
ACL 检查失败后,执行的操作。
ignore:不做任何操作。disconnect:断开连接。
zone.internal.force_gc_policy
| Type | Default |
|---|---|
| string | - |
说明
当收到一定数量的消息,或字节,就强制执行一次垃圾回收。
格式:<Number>|<Bytes>。
例如,16000|16MB 表示当收到 16000 条消息,或 16MB 的字节流入就强制执行一次垃圾回收。
zone.internal.wildcard_subscription
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
- |
说明
是否支持订阅通配主题。
zone.internal.shared_subscription
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
- |
说明
是否支持共享订阅。
zone.internal.max_subscriptions
| Type | Default |
|---|---|
| integer | 0 |
说明
单个客户端允许订阅的最大主题数。0 表示不限制。
zone.internal.max_inflight
| Type | Default |
|---|---|
| integer | 128 |
说明
飞行窗口大小。飞行窗口用于存储未被应答的 QoS 1 和 QoS 2 消息。
zone.internal.max_awaiting_rel
| Type | Default |
|---|---|
| integer | 1000 |
说明
QoS 2 消息的最大接收窗口,配置 EMQX 能够同时处理多少从客户端发来的 QoS 2 消息。0 表示不限制。
zone.internal.max_mqueue_len
| Type | Default |
|---|---|
| integer | 10000 |
说明
消息队列最大长度。当飞行窗口满,或客户端离线后,消息会被存储至该队列中。0 表示不限制。
zone.internal.mqueue_store_qos0
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
true |
说明
消息队列是否存储 QoS 0 消息。
zone.internal.enable_flapping_detect
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
off |
说明
是否开启 Flapping 检查。
zone.internal.force_shutdown_policy
| Type | Default |
|---|---|
| string | - |
说明
当进程消息队列长度,或占用的内存字节到达某值,就强制关闭该进程。
这里的 消息队列 指的是 Erlang 进程的 消息邮箱,并非 QoS 1 和 QoS 2 的 mqueue。
格式:<Number>|<Bytes>。
例如,32000|32MB 表示当进程堆积了 32000 条消息,或进程占用内存达到 32MB 则关闭该进程。
zone.internal.mountpoint
| Type | Default |
|---|---|
| string | - |
说明
主题挂载点。配置后,所有订阅和发布的主题在 EMQX 都会为其增加一个前缀。
其中可用的占位符有:
%c:表示客户端的 Client ID。%u:表示客户端的 Username。
例如,配置挂载点为 user/%c/。那么 Client ID 为 tom 的客户端在发布主题 open 消息时,实际在 EMQX 中路由的主题是 user/tom/open。
zone.internal.ignore_loop_deliver
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
false |
说明
是否忽略自己发送的消息。如果忽略,则表明 EMQX 不会向消息的发送端投递此消息。
zone.internal.strict_mode
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
false |
说明
是否开启严格检查模式。严格检查模式会更细致的检查 MQTT 报文的正确性。
zone.internal.bypass_auth_plugins
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
true |
说明
是否允许该 Zone 下的客户端绕过认证插件的认证步骤。
tcpexternal
listener.tcp.external
| Type | Default |
|---|---|
| string | 0.0.0.0:1883 |
说明
配置名称为 external 的 MQTT/TCP 监听器的监听地址。
示例
1883:表监听 IPv4 的 0.0.0.0:1883。 127.0.0.1:1883:表监听地址为 127.0.0.1 网卡上的 1883 端口。 ::1:1883:表监听 IPv6 地址为 ::1 网卡上的 1883 端口。
listener.tcp.external.acceptors
| Type | Default |
|---|---|
| integer | 8 |
说明
监听器的接收池大小。
listener.tcp.external.max_connections
| Type | Default |
|---|---|
| integer | 1024000 |
说明
监听器允许的最大并发连接数量。
listener.tcp.external.max_conn_rate
| Type | Default |
|---|---|
| integer | 1000 |
说明
监听器允许的最大接入速率。单位:个/秒
listener.tcp.external.active_n
| Type | Default |
|---|---|
| integer | 100 |
说明
监听器持续接收 TCP 报文的次数。
listener.tcp.external.zone
| Type | Default |
|---|---|
| string | external |
说明
监听器所属的配置域 (Zone)。
listener.tcp.external.rate_limit
| Type | Default |
|---|---|
| string | - |
说明
监听器的速率限制。格式为 <limit>,<duration>。
示例
100KB,10s:表 限制 10 秒内的流入字节数不超过 100 KB 。
listener.tcp.external.access.1
| Type | Default |
|---|---|
| string | allow all |
说明
监听器的 ACL 规则列表。它用于设置连接层的白/黑名单。
示例
allow all:表允许所有的 TCP 连接接入。 allow 192.168.0.0/24:表允许网络地址为 192.168.0.0/24 的 TCP 连接接入。
同时,该配置可配置多条规则:
listener.tcp.external.access.1 = deny 192.168.0.1
listener.tcp.external.access.2 = allow all
它表示,除 192.168.0.1 外的 TCP 连接都允许接入。
listener.tcp.external.proxy_protocol
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
- |
说明
监听器是否开启 Proxy Protocol 的支持。
如果 EMQX 集群部署在 HAProxy 或 Nginx 后,且需要拿到客户端真实的源 IP 地址与端口,则需打开此配置。
Proxy Protcol 参考: https://www.haproxy.com/blog/haproxy/proxy-protocol
(opens new window)。
listener.tcp.external.proxy_protocol_timeout
| Type | Default |
|---|---|
| duration | - |
说明
设置 Proxy Protocol 解析的超时时间。如果该时间内没收到 Proxy Protocol 的报文,EMQX 会关闭其连接。
listener.tcp.external.peer_cert_as_username
| Type | Optional Value | Default |
|---|---|---|
| enum | cn, dn, crt, pem, md5 |
cn |
说明
使用客户端证书来覆盖 Username 字段的值。其可选值为:
- cn:客户端证书的 Common Name 字段值
- dn:客户端证书的 Subject Name 字段值
- crt:DER 格式编码的客户端证书二进制
- pem:基于 DER 格式上的 base64 编码后的字符串
- md5:DER 格式证书的 MD5 哈希值
注意:在 TCP 的监听器下,该配置仅在负载均衡服务器终结 SSL 的部署情况下可以用;且负载均衡服务器需要配置 Proxy Protocol 将证书域的内容给发送至 EMQX。例如 HAProxy 的配置可参考 send-proxy-v2-ssl
(opens new window)
listener.tcp.external.peer_cert_as_clientid
| Type | Optional Value | Default |
|---|---|---|
| enum | cn, dn, crt, pem, md5 |
cn |
说明
使用客户端证书来覆盖 ClientID 字段的值。其可选值的含义同上。
listener.tcp.external.backlog
| Type | Default |
|---|---|
| integer | 1024 |
说明
TCP 连接队列的最大长度。它表明了系统中允许的正在三次握手的 TCP 连接队列最大个数。
listener.tcp.external.send_timeout
| Type | Default |
|---|---|
| duration | 15s |
说明
TCP 报文发送超时时间。
listener.tcp.external.send_timeout_close
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
on |
说明
TCP 报文发送超时后,是否关闭该连接。
listener.tcp.external.recbuf
| Type | Default |
|---|---|
| bytesize | - |
说明
TCP 接收缓存区大小(操作系统内核级参数)
参见:<http://erlang.org/doc/man/inet.html>
listener.tcp.external.sndbuf
| Type | Default |
|---|---|
| bytesize | - |
说明
TCP 发送缓存区大小(操作系统内核级参数)。
参见:http://erlang.org/doc/man/inet.html
(opens new window)。
listener.tcp.external.buffer
| Type | Default |
|---|---|
| bytesize | - |
说明
TCP 缓冲区大小 (用户级)。
该值建议大于等于 sndbuff 和 recbuff 的最大值,以避免一些性能问题。在不配置的情况下,它默认等于 sndbuff 和 recbuff 的最大值。
参见:http://erlang.org/doc/man/inet.html
(opens new window)。
listener.tcp.external.tune_buffer
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
- |
说明
如果打开此配置,请设置该值等于 sndbuff 与 recbuff 的最大值。
listener.tcp.external.nodelay
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
true |
说明
即 TCP_NODELAY 参数。开启该选项即允许小的 TCP 数据报文将会立即发送。
listener.tcp.external.reuseaddr
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
true |
说明
即 SO_REUSEADDR 参数。开启该选项即允许本地重用端口,无需等待 TIME_WAIT 状态结束。
tcpinternal
listener.tcp.internal
| Type | Default |
|---|---|
| string | 127.0.0.1:11883 |
说明
配置名称为 internal 的 MQTT/TCP 监听器的监听地址。
示例
11883:表监听 IPv4 的 0.0.0.0:11883。 127.0.0.1:11883:表监听地址为 127.0.0.1 网卡上的 11883 端口。 ::1:11883:表监听 IPv6 地址为 ::1 网卡上的 11883 端口。
listener.tcp.internal.acceptors
| Type | Default |
|---|---|
| integer | 4 |
说明
监听器的接收池大小。
listener.tcp.internal.max_connections
| Type | Default |
|---|---|
| integer | 1024000 |
说明
监听器允许的最大并发连接数量。
listener.tcp.internal.max_conn_rate
| Type | Default |
|---|---|
| integer | 1000 |
说明
监听器允许的最大接入速率。单位:个/秒
listener.tcp.internal.active_n
| Type | Default |
|---|---|
| integer | 1000 |
说明
监听器持续接收 TCP 报文的次数。
listener.tcp.internal.zone
| Type | Default |
|---|---|
| string | internal |
说明
监听器所属的配置域 (Zone)。
listener.tcp.internal.rate_limit
| Type | Default |
|---|---|
| string | - |
说明
监听器的速率限制。格式为 <limit>,<duration>。
示例
100KB,10s:表 限制 10 秒内的流入字节数不超过 100 KB 。
listener.tcp.internal.backlog
| Type | Default |
|---|---|
| integer | 512 |
说明
TCP 连接队列的最大长度。它表明了系统中允许的正在三次握手的 TCP 连接队列最大个数。
listener.tcp.internal.send_timeout
| Type | Default |
|---|---|
| duration | 5s |
说明
TCP 报文发送超时时间。
listener.tcp.internal.send_timeout_close
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
on |
说明
TCP 报文发送超时后,是否关闭该连接。
listener.tcp.internal.recbuf
| Type | Default |
|---|---|
| bytesize | 64KB |
说明
TCP 接收缓存区大小(操作系统内核级参数)
listener.tcp.internal.sndbuf
| Type | Default |
|---|---|
| bytesize | 64KB |
说明
TCP 发送缓存区大小(操作系统内核级参数)
listener.tcp.internal.buffer
| Type | Default |
|---|---|
| bytesize | - |
说明
TCP 缓冲区大小 (用户级)。
listener.tcp.internal.tune_buffer
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
- |
说明
如果打开此配置,请设置该值等于 sndbuff 与 recbuff 的最大值。
listener.tcp.internal.nodelay
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
false |
说明
即 TCP_NODELAY 参数。开启该选项即允许小的 TCP 数据报文将会立即发送。
listener.tcp.internal.reuseaddr
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
true |
说明
即 SO_REUSEADDR 参数。开启该选项即允许本地重用端口,无需等待 TIME_WAIT 状态结束。
tlsexternal
listener.ssl.external
| Type | Default |
|---|---|
| string | 0.0.0.0:8883 |
说明
配置名称为 external 的 SSL 监听器。
listener.ssl.external.acceptors
| Type | Default |
|---|---|
| integer | 16 |
说明
监听器的接收池大小。
listener.ssl.external.max_connections
| Type | Default |
|---|---|
| integer | 102400 |
说明
监听器允许的最大并发连接数量。
listener.ssl.external.max_conn_rate
| Type | Default |
|---|---|
| integer | 500 |
说明
监听器允许的最大接入速率。单位:个/秒。
listener.ssl.external.active_n
| Type | Default |
|---|---|
| integer | 100 |
说明
监听器持续接收 TCP 报文的次数。
listener.ssl.external.zone
| Type | Default |
|---|---|
| string | external |
说明
监听器所属的配置组 (Zone)。
listener.ssl.external.access.1
| Type | Default |
|---|---|
| string | allow all |
说明
监听器的 ACL 规则列表。它用于设置连接层的白/黑名单。
例如:
allow all:表允许所有的 TCP 连接接入。 allow 192.168.0.0/24:表允许网络地址为 192.168.0.0/24 的 TCP 连接接入。
同时,该配置可配置多条规则:
listener.ssl.external.access.1 = deny 192.168.0.1
listener.ssl.external.access.2 = allow all
listener.ssl.external.rate_limit
| Type | Default |
|---|---|
| string | - |
说明
监听器的速率限制。格式为 <limit>,<duration>。
listener.ssl.external.proxy_protocol
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
- |
说明
监听器是否开启 Proxy Protocol 的支持。
如果 EMQX 集群部署在 HAProxy 或 Nginx 后,且需要拿到客户端真实的源 IP 地址与端口,则需打开此配置。
Proxy Protcol 参考: https://www.haproxy.com/blog/haproxy/proxy-protocol
(opens new window)。
listener.ssl.external.proxy_protocol_timeout
| Type | Default |
|---|---|
| duration | - |
说明
设置 Proxy Protocol 解析的超时时间。如果该时间内没收到 Proxy Protocol 的报文,EMQX 会关闭其连接。
listener.ssl.external.tls_versions
| Type | Default |
|---|---|
| string | tlsv1.3,tlsv1.2,tlsv1.1,tlsv1 |
说明
指定服务端支持的 SSL 的版本列表。详情请参见 http://erlang.org/doc/man/ssl.html
(opens new window)。
listener.ssl.external.handshake_timeout
| Type | Default |
|---|---|
| duration | 15s |
说明
指定 SSL 握手过程的超时时间。
listener.ssl.external.depth
| Type | Default |
|---|---|
| number | 10 |
说明
证书链中非自签发的中间证书的最大数量。如果该值为 0 则表示,对端证书必须是根 CA 直接授信的。
listener.ssl.external.key_password
| Type | Default |
|---|---|
| string | - |
说明
证书密钥文件的密码。如果你的证书密钥设置了密码,则需要配置该选项。
listener.ssl.external.keyfile
| Type | Default |
|---|---|
| string | etc/certs/key.pem |
说明
指定 SSL 的私钥文件 (PEM)。
listener.ssl.external.certfile
| Type | Default |
|---|---|
| string | etc/certs/cert.pem |
说明
指定 SSL 的证书文件 (PEM)。
listener.ssl.external.cacertfile
| Type | Default |
|---|---|
| string | etc/certs/cacert.pem |
说明
指定 SSL 的 CA 证书文件 (PEM)。该文件应包含发布服务器证书的所有中间CA证书以及根证书。 该文件还应包含所有受信CA的证书用以用于验证客户端的证书。
listener.ssl.external.enable_ocsp_stapling
| Type | Default |
|---|---|
| boolean | false |
说明
在 e4.4.11 中引入。
是否为监听器启用OCSP Stapling 功能。 如果设置为 true,则需要定义OCSP响应者的URL。 这个响应将被缓存,并作为 TLS 握手的一部分发送给连接的客户端。 注意:仅支持 TLS 1.2 和 TLS 1.3。
listener.ssl.external.ocsp_responder_url
| Type | Default |
|---|---|
| string | - |
说明
在 e4.4.11 中引入。
启用 OCSP Stapling 时,用于检查服务器证书的 OCSP 应答服务 URL。 应答的内容会被缓存,并定期刷新。
listener.ssl.external.ocsp_issuer_pem
| Type | Default |
|---|---|
| string | - |
说明
在 e4.4.11 中引入。
该文件用于存放 OCSP Responder 的 PEM 格式编码的证书。 该证书用于校验 OCSP Responder 返回的内容。
listener.ssl.external.ocsp_refresh_interval
| Type | Default |
|---|---|
| duration | 5m |
说明
在 e4.4.11 中引入。
刷新 OCSP Stapling 的间隔。 如果响应在刷新期间未能被获取,先前缓存的 响应仍将被使用,直到从 OCSP Responder 那里成功地获取一个较新的响应。 该配置不能小于 1 分钟。
listener.ssl.external.ocsp_refresh_http_timeout
| Type | Default |
|---|---|
| duration | 15s |
说明
在 e4.4.11 中引入。
从 OCSP Responder 处获取 OCSP Stapling 响应的最长时间。
listener.ssl.external.enable_crl_check
| Type | Default |
|---|---|
| boolean | false |
说明
在 e4.4.11 中引入。
是否为该监听器启用 CRL 验证和缓存。
注意:当缓存没有命中时,EMQX 会尝试在运行时从客户端证书中携带的 URL 来下载最新的 CRL。如果下载失败,EMQX 会拒绝该客户端的连接。
listener.ssl.external.crl_cache_urls
| Type | Default |
|---|---|
| string | - |
说明
在 e4.4.11 中引入。
以逗号分隔的URL列表,用于获取和缓存 CRL 列表的服务器。 必须在路径中包括CRL文件的路径(例如: http://my.crl.server/intermediate.crl.pem, http://my.other.crl.server/another.crl.pem)。
crl_cache_http_timeout
| Type | Default |
|---|---|
| duration | 15s |
说明
在 e4.4.11 中引入。
获取 CRL 列表时 HTTP 请求的超时。适用于所有监听器。
crl_cache_refresh_interval
| Type | Default |
|---|---|
| duration | 15m |
说明
在 e4.4.11 中引入。
从服务器刷新 CRL 的周期。 适用于所有 URL 和监听器。 不能短于1分钟。
listener.ssl.external.dhfile
| Type | Default |
|---|---|
| string | etc/certs/dh-params.pem |
说明
若使用 Ephemeral Diffie-Helman 算法,指定算法使用的 key 文件。
listener.ssl.external.verify
| Type | Optional Value | Default |
|---|---|---|
| enum | verify_peer, verify_none |
verify_peer |
说明
指定握手过程中是否校验客户端。
listener.ssl.external.fail_if_no_peer_cert
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
false |
说明
SSL 握手过程中若客户端没有证书,是否让握手失败。
listener.ssl.external.ciphers
| Type | Default |
|---|---|
| string | ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-GCM-SHA384,ECDHE-ECDSA-AES256-SHA384,ECDHE-RSA-AES256-SHA384,ECDHE-ECDSA-DES-CBC3-SHA,ECDH-ECDSA-AES256-GCM-SHA384,ECDH-RSA-AES256-GCM-SHA384,ECDH-ECDSA-AES256-SHA384,ECDH-RSA-AES256-SHA384,DHE-DSS-AES256-GCM-SHA384,DHE-DSS-AES256-SHA256,AES256-GCM-SHA384,AES256-SHA256,ECDHE-ECDSA-AES128-GCM-SHA256,ECDHE-RSA-AES128-GCM-SHA256,ECDHE-ECDSA-AES128-SHA256,ECDHE-RSA-AES128-SHA256,ECDH-ECDSA-AES128-GCM-SHA256,ECDH-RSA-AES128-GCM-SHA256,ECDH-ECDSA-AES128-SHA256,ECDH-RSA-AES128-SHA256,DHE-DSS-AES128-GCM-SHA256,DHE-DSS-AES128-SHA256,AES128-GCM-SHA256,AES128-SHA256,ECDHE-ECDSA-AES256-SHA,ECDHE-RSA-AES256-SHA,DHE-DSS-AES256-SHA,ECDH-ECDSA-AES256-SHA,ECDH-RSA-AES256-SHA,AES256-SHA,ECDHE-ECDSA-AES128-SHA,ECDHE-RSA-AES128-SHA,DHE-DSS-AES128-SHA,ECDH-ECDSA-AES128-SHA,ECDH-RSA-AES128-SHA,AES128-SHA |
说明
指定服务端支持的密码套件。
listener.ssl.external.psk_ciphers
| Type | Default |
|---|---|
| string | PSK-AES128-CBC-SHA,PSK-AES256-CBC-SHA,PSK-3DES-EDE-CBC-SHA,PSK-RC4-SHA |
说明
若使用 PSK 算法,指定服务端支持的 PSK Cipher 列表。注意 ‘listener.ssl.external.ciphers’ 和 ‘listener.ssl.external.psk_ciphers’ 只能配置一个。
listener.ssl.external.secure_renegotiate
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
off |
说明
指定在客户端不遵循 RFC 5746 的情况下,是否拒绝 renegotiation 请求。
listener.ssl.external.reuse_sessions
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
on |
说明
指定是否支持 SSL session 重用。详情见 http://erlang.org/doc/man/ssl.html
(opens new window)。
listener.ssl.external.honor_cipher_order
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
on |
说明
指定是否使用服务端的偏好设置选择 Ciphers。
listener.ssl.external.peer_cert_as_username
| Type | Optional Value | Default |
|---|---|---|
| enum | cn, dn, crt, pem, md5 |
cn |
说明
使用客户端证书来覆盖 Username 字段的值。其可选值为:
- cn:客户端证书的 Common Name 字段值
- dn:客户端证书的 Subject Name 字段值
- crt:DER 格式编码的客户端证书二进制
- pem:基于 DER 格式上的 base64 编码后的字符串
- md5:DER 格式证书的 MD5 哈希值
注意 listener.ssl.external.verify 应当设置为 verify_peer。
listener.ssl.external.peer_cert_as_clientid
| Type | Optional Value | Default |
|---|---|---|
| enum | cn, dn, crt, pem, md5 |
cn |
说明
使用客户端证书来覆盖 ClientID 字段的值。其可选值的含义同上。
注意 listener.ssl.external.verify 应当设置为 verify_peer。
listener.ssl.external.backlog
| Type | Default |
|---|---|
| integer | 1024 |
说明
TCP 连接队列的最大长度。它表明了系统中允许的正在三次握手的 TCP 连接队列最大个数。
listener.ssl.external.send_timeout
| Type | Default |
|---|---|
| duration | 15s |
说明
TCP 报文发送超时时间。
listener.ssl.external.send_timeout_close
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
on |
说明
TCP 报文发送超时后,是否关闭该连接。
listener.ssl.external.recbuf
| Type | Default |
|---|---|
| bytesize | - |
说明
TCP 接收缓存区大小(操作系统内核级参数)。
参见:http://erlang.org/doc/man/inet.html
(opens new window)。
listener.ssl.external.sndbuf
| Type | Default |
|---|---|
| bytesize | - |
说明
TCP 发送缓存区大小(操作系统内核级参数)。
参见:http://erlang.org/doc/man/inet.html
(opens new window)。
listener.ssl.external.buffer
| Type | Default |
|---|---|
| bytesize | - |
说明
TCP 缓冲区大小 (用户级)。
该值建议大于等于 sndbuff 和 recbuff 的最大值,以避免一些性能问题。在不配置的情况下,它默认等于 sndbuff 和 recbuff 的最大值。
参见:http://erlang.org/doc/man/inet.html
(opens new window)。
listener.ssl.external.tune_buffer
| Type | Optional Value | Default |
|---|---|---|
| enum | on, off |
- |
说明
如果打开此配置,请设置该值等于 sndbuff 与 recbuff 的最大值。
listener.ssl.external.nodelay
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
true |
说明
即 TCP_NODELAY 参数。开启该选项即表示禁用 Nagle 算法,小包将被立即发送。
listener.ssl.external.reuseaddr
| Type | Optional Value | Default |
|---|---|---|
| enum | true, false |
true |
说明
即 SO_REUSEADDR 参数。开启该选项即允许本地重用端口,无需等待 TIME_WAIT 状态结束。
wsexternal
listener.ws.external
| Type | Default |
|---|---|
| string | 8083 |
说明
配置名称为 external 的 MQTT/WS 监听器的监听地址。
示例
8083:表监听 IPv4 的 0.0.0.0:8083。 127.0.0.1:8083:表监听地址为 127.0.0.1 网卡上的 8083 端口。 ::1:8083:表监听 IPv6 地址为 ::1 网卡上的 8083 端口。
listener.ws.external.mqtt_path
| Type | Default |
|---|---|
| string | /mqtt |
说明
WebSocket 的 MQTT 协议路径。因此 EMQX 的 WebSocket 的地址是: ws://{ip}:{port}/mqtt。
listener.ws.external.acceptors
| Type | Default |
|---|---|
| integer | 4 |
说明
监听器的接收池大小。
listener.ws.external.max_connections
| Type | Default |
|---|---|
| integer | 102400 |
说明
监听器允许的最大并发连接数量。
listener.ws.external.max_conn_rate
| Type | Default |
|---|---|
| integer | 1000 |
说明
监听器允许的最大接入速率。单位:个/秒
listener.ws.external.active_n
| Type | Default |
|---|---|
| integer | 100 |
说明
监听器持续接收 TCP 报文的次数。
listener.ws.external.rate_limit
| Type | Default |
|---|---|
| string | 100KB,10s |
说明
监听器的速率限制。格式为 <limit>,<duration>。
示例
100KB,10s:表 限制 10 秒内的流入字节数不超过 100 KB 。
(本文超出站点单文档体积上限,已按小节截断)
