Centos7安装mqtt Mosquitto代理服务器

4 篇文章 0 订阅
1 篇文章 0 订阅

1. 添加 EPEL 软件库(如已安装,请跳过此步骤)

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

遇到选择项输入y即可。

2. 查看EPEL安装结果

yum repolist all | grep enabled

3. 安装 Mosquitto

查找 mosquitto 软件包:yum list all | grep mosquitto
查看 mosquitto 信息: yum info mosquitto
安装 mosquitto 软件包: yum install mosquitto
查看安装结果:yum list installed | grep mosquitto

4. 测试Mosquitto

启动 mosquitto 主程序:mosquitto
新建一个ssh窗口;订阅》执行命令:mosquitto_sub -t test
新建一个ssh窗口;发布》执行命令:mosquitto_pub -t test -h localhost -m "hello, world"
可以看到订阅窗口收到:hello, world

5. 开机自启Mosquitto

查找 mosquitto 服务:find / -iname mosquitto* | grep service
设置 mosquitto 服务:systemctl enable mosquitto.service
启动 mosquitto 服务:systemctl start mosquitto.service
查看 mosquitto 状态:systemctl status mosquitto.service
查看进程:ps -aux | grep mosquitto
重启 CentOS:reboot,查看 mosquitto 服务是否自动启动:systemctl list-units | grep mosquitto

6. 配置用户名密码

修改配置,vi /etc/mosquitto/mosquitto.conf
allow_anonymous false
password_file /etc/mosquitto/pwfile.example
配置用户名密码:mosquitto_passwd /etc/mosquitto/pwfile.example 用户名 回车

完。

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值