centos7 安装mosquitto
作者:互联网
centos7 安装mosquitto
- 添加添加 EPEL 软件库
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- 安装 mosquitto
yum install -y mosquitto
- 启动服务
systemctl start mosquitto
- 测试
打开两个窗口:
1)收消息:mosquitto_sub -t test
2)发消息:mosquitto_pub -t test -h 192.168.2.44 -p 1883 -m “hello, mosquitto”
- 修改配置文件添加用户名密码
vim /etc/mosquitto/mosquitto.conf
#allow_anonymous true 修改成
allow_anonymous false
#password_file 修改成
password_file /etc/mosquitto/pwfile
- 重启服务
systemctl restart mosquitto
- 创建用户名密码
mosquitto_passwd -c /etc/mosquitto/pwfile test-mosquitto
Password: mosquitto
Reenter password:mosquitto
-
打开两个窗口:
1)收消息:mosquitto_sub -t test -h 192.168.2.44 -p 1883 -u ‘test-mosquitto’ -P ‘mosquitto’
2)发消息:mosquitto_pub -t test -h 192.168.2.44 -p 1883 -u ‘test-mosquitto’ -P ‘mosquitto’ -m “hello, mosquitto”
可以下发mqqt工具,方便好用:
链接:https://pan.baidu.com/s/1E_rZrT8x6q_izxdsF6zCjw
提取码:cd9e
标签:2.44,192.168,centos7,etc,mosquitto,pub,test,安装 来源: https://blog.csdn.net/weixin_40668374/article/details/119187320