银河麒麟系统ARM架构安装mqtt
·
安装mosquitto 软件包
yum install mosquitto

设置用户名和密码
切换到安装目录,打开配置文件,开启密码
cd /etc/mosquitto
vi mosquitto.conf
修改以下2个参数
allow_anonymous:是否允许匿名登录
默认:#allow_anonymous
修改后:allow_anonymous false
password_file:密码保存路径
默认:#password_file
修改后:password_file /etc/mosquitto/password (这里的地址根据自己文件实际位置填写)
开启websocket及监听端口
# MQTT协议
port 18820
# websockets协议
listener 12788
protocol websockets
#禁止匿名登录
allow_anonymous false
#存放用户的文件
password_file /etc/mosquitto/password
创建用户名和密码
创建时需要连续两次输入密码。
1、这将创建一个新的密码文件 /path/to/passwordfile,其中包含用户名 username 和你输入的密码
mosquitto_passwd -c /path/to/passwordfile username

2、不使用 -c 选项,mosquitto_passwd 命令将向现有的密码文件中添加新用户或更新现有用户的密码,而不会覆盖整个文件
mosquitto_passwd /path/to/passwordfile username
- 使用 -c 选项时,会创建新密码文件或覆盖现有文件。
- 不使用 -c 选项时,会向现有密码文件中添加新用户或更新现有用户密码。
启动mqtt
systemctl start mosquitto
设置服务自启
systemctl enable mosquitto
验证端口
lsof -i:18820
losf -i:12788

更多推荐



所有评论(0)