persistence - mosquitto.db 文件未创建
问题描述
在测试 mosquitto Persistence 的过程中,我已从 Persistence 位置删除 mosquitto.db 以启用新的开始。但是,令我懊恼的是,即使在我重新启动代理后,该文件也不会创建。
经纪人根据配置创建 .db 文件是不是我弄错了?任何有关如何获取新 mosquitto.db 文件的指针将不胜感激。
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
pid_file /var/run/mosquitto.pid
max_inflight_messages 1
persistence true
persistence_file mosquitto.db
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
password_file /etc/mosquitto/passwd
allow_anonymous false
max_queued_messages 1000000
autosave_interval 30
# autosave_on_changes false
解决方案
如果您在代理运行时删除文件,它可能不会重新创建,因为代理已经拥有一个打开的文件句柄。
在进程打开文件时删除文件实际上并不会删除文件,只是它在目录中的条目,进程将继续读/写文件,直到句柄关闭。
如果您在删除文件后重新启动 mosquitto,它不会写入文件,直到它实际上有一些数据要写入它,例如
- 有一个订阅的客户端(在 QOS 1 或 2)
- 发送一些消息
- 断开订阅者
- 发送更多消息
- 关闭蚊子
现在应该写入包含在客户端断开连接时发布的消息的文件。
推荐阅读
- c++ - 仅在按 enter 时显示输出
- php - 返回一个 xml 文件,避免回显它
- php - 如何解决在执行“composer install”时找不到受支持的加密?
- amazon-web-services - 使用部署脚本时出现 AWS 身份验证问题
- kubernetes - 修改 pod 映像时,Replicaset 不会更新 pod
- c++ - 红帽:使用
编译正常但链接器找不到 __atomic_store_16; 什么图书馆? - php - 我们可以为 OpenSSL ECC 拥有多个公钥和一个私钥吗?
- angularjs - .withButtons() 不是函数
- android - 在android studio中重构移动文件时出现意外的元素类型类
- mysql - 如何连接日期并在日期月份下检索