Linux系统在线安装Mosquitto

46 阅读1分钟

1、 安装mqtt服务:yum install mosquitto

2、 修改监听配置信息:vim /etc/mosquitto/mosquitto.conf

# 设置是否允许匿名连接,如果禁止匿名连接,则需要配置账号、密码连接
allow_anonymous true
# mqtt 协议配置,分为ipv4和ipv6两种,当前可以只配置启用一种
listener 1883
protocol mqtt
# webscoket 协议配置,如果有的话需要配置,分为ipv4和ipv6两种,当前可以只配置启用一种
listener 8000
protocol websockets
# 允许的最大连接数,-1表示没有限制
max_connections -1

# 密码文件路径,禁止匿名连接配置,允许匿名则不用配置(这个配置可忽略)
#password_file /etc/mosquitto/pwfile.example

3、 添加用户和密码:

mosquitto_passwd -c pwfile.example   admin
输入用户名之后回车,两次输入密码   admin

4、 启动mqtt服务:systemctl start mosquitto