gpt4 book ai didi

linux - 错误 : Unable to write pid file Mosquitto v2. 0.3

转载 作者:行者123 更新时间:2023-12-05 09:36:02 51 4
gpt4 key购买 nike

由于我在 Ubuntu 16.04 上更新了 Mosquitto v2.0.3,用户无法连接到代理。

当我尝试使用 /usr/sbin/mosquitto -c/etc/mosquitto/mosquitto.conf 运行时,它抛出了以下消息。2020-12-22|12:37:02:错误:无法写入 pid 文件。

我看到有些人有同样的问题,所以我在 mosquitto 配置中添加了 pid_file/var/run/mosquitto/mosquitto.pid 但问题并没有消失。

我在 /lib/systemd/system/mosquitto.service 中有这个:

[Unit]
Description=Mosquitto MQTT Broker
Documentation=man:mosquitto.conf(5) man:mosquitto(8)
After=network.target
Wants=network.target

[Service]
Type=notify
NotifyAccess=main
ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto
ExecStartPre=/bin/chown mosquitto: /var/log/mosquitto
ExecStartPre=/bin/mkdir -m 740 -p /var/run/mosquitto
ExecStartPre=/bin/chown mosquitto: /var/run/mosquitto

[Install]
WantedBy=multi-user.target

mosquitto.conf 文件配置为:

# 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/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

listener 1883

log_type error
log_type notice
log_type information
log_type debug
log_type all
log_dest topic
log_type warning

allow_anonymous false
connection_messages true
max_keepalive 10
log_timestamp true
log_timestamp_format %Y-%m-%d|%H:%M:%S

password_file /etc/mosquitto/pwfile

####################################################
# MOSQUITTO LISTENER WITH SLL
####################################################

listener 8883
protocol mqtt
allow_anonymous false

#PARA BROKER EN PC
cafile /etc/mosquitto/certs/ca.crt
keyfile /etc/mosquitto/certs/server.key
certfile /etc/mosquitto/certs/server.crt

#PARA BROKER EN RASPBERRY PI 3
#cafile /etc/mosquitto/certs/ca_pi.crt
#keyfile /etc/mosquitto/certs/server_pi.key
#certfile /etc/mosquitto/certs/server_pi.crt

tls_version tlsv1.2

当我从终端运行 systemctl status mosquitto 时,它显示了以下消息...

● mosquitto.service - Mosquitto MQTT Broker
Loaded: loaded (/etc/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since mar 2020-12-22 13:06:13 -04; 5s ago
Docs: man:mosquitto(8)
man:mosquitto.conf(5)
Process: 22889 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE)
Main PID: 22889 (code=exited, status=1/FAILURE)

dic 22 13:06:13 carmenmoncada systemd[1]:

我不知道发生了什么,有人可以帮我解决这个问题吗?提前致谢问候。

最佳答案

sudo mkdir -m 777 mosquitto

永远不要这样做!

就地试试这个:

sudo mkdir /var/run/mosquitto/ && sudo chown mosquitto: /var/run/mosquitto

并放入/etc/mosquitto/mosquitto.conf

...
pid_file /var/run/mosquitto/mosquitto.pid
...

关于linux - 错误 : Unable to write pid file Mosquitto v2. 0.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65415019/

51 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com