Appearance
配置
FreeMQTT Plus 集群配置位于 ~/freemqttplus-compose/conf.d路径下。
配置文件 config.toml
toml
[freemqtt]
# 通用配置
[freemqtt.common]
# 用于生成客户端的 token 和 MQTT 客户端连接鉴权用的秘钥
# 必须为64位十六进制字符串(二进制256位秘钥)
# 一定要注意保管,避免向外泄漏
secret = "F593BDE387F7530CF0F35CC2DB763F755AB770E779C0FD0C3AB018E7439E2A3D"
# 最大topic & topic filter 级别,默认 6
maximum_topic_level = 6
# 发布 FreeMQTT 统计信息间隔
pub_sys_stat_interval = 15 # in seconds
# MQTT 5.0 属性配置
[freemqtt.properties]
session_expiry_interval = 7200 # in second
message_expiry_interval = 7200 # in second
receive_maximum = 1024
maximum_packet_size = 2097152 # 2*1024*1024 = 2M bytes
maximum_qos = 2
retain_available = true
topic_alias_maximum = 64
wildcard_subscription_available = true
subscription_identifiers_available = true
shared_subscription_available = true
server_keep_alive = 60 # in second
response_information = "Welcome to FreeMQTT Broker."
# cluster A node list
[freemqtt.anode]
list = [
{ nodeid='A1', address='fmq-a1', tcp_port=1883, ws_port=1080 },
{ nodeid='A2', address='fmq-a2', tcp_port=1883, ws_port=1080 },
{ nodeid='A3', address='fmq-a3', tcp_port=1883, ws_port=1080 },
]
# cluster B node list
[freemqtt.bnode]
list = [
{ nodeid='B1', address='fmq-b1', port=9200},
{ nodeid='B2', address='fmq-b2', port=9200},
]
# FreeMQTT Plus cluster logging
[freemqtt.logging]
address = "fmq-log"
port = 9300
path = "./log/freemqttc.log"
#path = "console"
maxim_size = 10485760 # 10M
level = 20 # logging.NOTSET = 0, logging.DEBUG = 10, logging.INFO = 20, logging.WARNING = 30, logging.ERROR = 40, logging.CRITICAL = 50
更改 secret
在实际部署到生产环境时,为了安全,不建议使用 config.toml 中 secret 的默认值。
- secret 是 256 bit, 即长度为64的十六进制的字符串。
- 可以手动更改,但要保证长度为64个字符,字符是十六进制的字符(0-9 A-F)
亦可以用如下的命令随机生成 secret 值:
bash
$ sudo docker exec fmq-a1 /freemqttd/gen_secret
secret: ECE10149E6F5FC94C1289B4E3C923351B40038E82BE602E917CEA3C9EF79410D
更新 secret 后, FreeMQTT Plus 集群需重新启动并且客户端的token也需要重新生成。