mqtt

1 Mosquitto
1.1 安装验证

# 开放1883端口访问
firewall-cmd --zone=public --add-port=1883/tcp --permanent
firewall-cmd --reload
tar zxvf mosquitto-1.6.9.tar.gz
cd mosquitto-1.6.9
make && make install
adduser mosquitto
cp pwfile.example pwfile
cp /etc/mosquitto/mosquitto.conf.example /etc/mosquitto/mosquitto.conf
# mosquitto.conf添加内容如下
allow_anonymous true
password_file /etc/mosquitto/pwfile
port 1883
#确定命令
mosquitto -c /etc/mosquitto/mosquitto.conf

测试验证

[root@localhost mosquitto]# mosquitto_sub -t rulee
mosquitto_sub: error while loading shared libraries: libmosquitto.so.1: cannot open shared object file: No such file or directory

则参考MQTT研究之mosquitto:【环境搭建】执行

echo "/usr/local/lib" >> /etc/ld.so.con
ldconfig

在打开一个客户端执行mosquitto_pub -h localhost -t rulee -m "hello world",看到消息了,说明成功了

[root@localhost mosquitto]# mosquitto_sub -t rulee
hello rule engine

现在加上访问控制,参考Mosquitto 搭建及配置

# 设置密码
mosquitto_passwd /etc/mosquitto/pwfile mosquitto
############# mosquitto.conf
allow_anonymous false
password_file /etc/mosquitto/pwfile
acl_file /etc/mosquitto/aclfile
port 1883
pid_file /var/run/mosquitto.pid
# 持久化
persistence true
persistence_location /application/mosquitto/
# 日志
log_dest file /application/log/mosquitto/mosquitto.log

############# mosquitto.conf
user mosquitto
topic write test/#
topic read test/#

############# 验证是否可以订阅、发布
mosquitto_sub -h 10.101.5.131 -t "test/#" -u mosquitto -P test123 -i "client1"
mosquitto_pub -h 10.101.5.131 -t "test/abc" -u mosquitto -P test123 -i "client3" -m "hello world"

上述那些都是在本地测试的,现在来通过mqtt工具,比如通信猫来调试
无法连接上MQTT服务器,通过telent监测一下,如果telnet没有开启,参考telnet不是内部或外部命令,小编教你telnet不是内部或外部命令怎么解决
1
性能指标可参考MQTT SERVER 性能测试报告,这个没必要非要自己做一次验证。
Mosquitto 属于轻量级,故而用户管理就不擅长,难道每添加一个用户都要改配置重启?
1.2 内网穿透
先参考使用公共MQTT服务器进行HTTP内网穿透

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

warrah

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值