centOS7下安裝mosquitto服務
- 2020 年 2 月 13 日
- 筆記
在centOS7下安裝mosquitto可以使用yum安裝,也可以直接下載源代碼安裝,我一般使用源代碼安裝,因為需要mosquitto的提供的C++頭文件以及對應的so動態連接庫進行C++的mqtt客戶端封裝。 github上面的源代碼地址為:Eclipse Mosquitto – An open source MQTT broker https://mosquitto.org https://www.eclipse.org/mosquitto/download/ https://mosquitto.org/download/ 安裝完之後需要配置,在CSDN上面找到一篇不錯的博客,地址為:MQTT服務器搭建–Mosquitto用戶名密碼配置 還有一篇博客:Mosquitto 高級應用之用戶配置 我在配置mosquitto.conf配置文件時出現一個錯誤如下:
Error: Invalid user 'mosquitto'. The reason is simple, user is not configured. As user is root we have to declare root user un mosquitto configuration. So edit /etc/mosquitto/mosquitto.conf file and add at user sectionuser root需要配置當前用戶名。
原因找到了,centOS7系統下默認沒有mosquitto這個用戶,解決方法有兩個: 1、將user mosquitto哪一行配置改成user root 2、添加一個mosquitto用戶
su root adduser mosquitto passwd mosquitto