Several ways to install mosquitto mqtt on Linux
Eclipse Mosquitto is an open source message broker that implements MQTT protocol versions 3.1 and 3.1.1. Provides a lightweight, supportable publish/subscribe message push mode, Mosquitto's lightweight, suitable for all devices from low-power single-board computers to complete servers. The Mosquitto project also provides a C library for implementing MQTT clients and the very popular mosquitto_pub and mosquitto_sub command-line MQTT clients.
Install mosquitto offline on Linux
Official download link: https://mosquitto.org/download/
#下载包
wget http://mosquitto.org/files/source/mosquitto-1.4.5.tar.gz
#解压
tar -zxvf mosquitto-1.4.5.tar.gz
#进入目录,编译
cd mosquitto-1.4.5/
make
sudo make install
#拷贝配置
cp mosquitto.conf /etc/mosquitto/
#查看版本
mosquitto -v
#创建组和用户
groupadd mosquitto
useradd -g mosquitto mosquitto
#查看服务启动
ps -aux | grep mosquitto
#启动服务
mosquitto -c /etc/mosquitto/mosquitto.conf -d -v
Installation of mosquitto-1.6.10 version
#解压mqtt包
tar -zxvf mosquitto-1.6.10.tar.gz
cd mosquitto-1.6.10/
make
sudo make install
#拷贝配置
cp mosquitto.conf /etc/mosquitto/
#拷贝可执行文件
cp /usr/local/sbin/mosquitto /usr/sbin/
#查看帮助
mosquitto -h
#创建分组和用户
groupadd mosquitto
useradd -g mosquitto mosquitto -s /sbin/nologin
#查看启动情况
ps -aux | grep mosquitto
#mqtt启动文件复制指定目录
cp mosquitto.service /etc/systemd/system/
##添加文件执行权限
chmod +x /etc/systemd/system/mosquitto.service
#重新加载配置文件
systemctl daemon-reload
#设置mqtt开机自启
systemctl enable mosquitto.service
#查看mqtt开机启动状态
systemctl is-enabled mosquitto.service
#启动mqtt
systemctl start mosquitto.service
#查看启动状态
systemctl status mosquitto.service
ps -aux | grep mosquitto
Install mosquitto online on CentOS
yum install -y mosquito
Mosquitto MQTT version 2.x and above remote access settings
mosquitto MQTT version 2.x or above, the default is: only local access, and no anonymous access
Add:
allow_anonymous true allows anonymous access
to the listener 1883 can be accessed remotely
cat /etc/mosquitto/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
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
allow_anonymous true
listener 1883
Reference links:
https://www.jianshu.com/p/9e3cb7042a2e
https://www.jianshu.com/p/a0efd843a39f
https://www.shangmayuan.com/a/b088b32fe79d411bb6ac849d.html
https://www. icode9.com/content-3-901950.html
https://www.pianshen.com/article/70141267956/
https://my.oschina.net/wujinghust/blog/661167