yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install -y mosquitto
systemctl start 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