MQTT--linux安装部署
来源:互联网 发布:泰瑞克埃文斯 数据 编辑:程序博客网 时间:2024/06/06 23:50
http://blog.csdn.net/u011033736/article/details/53218394
我的服务器的版本是CentOS6.5。
1、安装依赖
yum -y install gcc gcc-c++ openssl-devel c-ares-devel libuuid-devel wget cmake
2、为mosquitto增加websocket支持,安装文本socket库文件
解压缩:# tar zxfv libwebsockets-v1.6-stable.tar.gz
3、运行 websocket
# cd libwebsockets-v1.6-stable# mkdir bulid# cd bulid# cmake ..# make && make install
4、安装mosquitto
下载mqtt,我用的是 mosquitto-1.4.8.tar.gz,
解压缩:# tar zxfv mosquitto-1.4.8.tar.gz
5、修改config.mk文件以使后面编译的mosquitto文件支持websocket
# cd /mosquitto-1.4.8
mosquitto-1.4.8目录下的config.mk文件,把config.mk 文件中的 WITH_WEBSOCKETS:=no 改为yes
保存后,执行
# make && make install# ln -s /usr/local/lib/libwebsockets.so.6 /usr/lib64/libwebsockets.so.6# groupadd mosquitto# useradd -g mosquitto mosquitto
6、创建mosquitto.conf、pwfile文件
# cd /etc/mosquitto/
如果该目录下没有mosquitto.conf 和 pwfile
执行
# cp mosquitto.conf.example mosquitto.conf# cp pwfile.example pwfile
然后修改 文件mosquitto.conf ,
511 allow_anonoymous true...537 password_file /etc/mosquitto/pwfile
并在文件最后加入
port 1883listener 8080protocol websockets
7、启动mqtt
# mosquitto -c /etc/mosquitto/mosquitto.conf
8、测试
另外打开两个终端
终端一:
这里其实就是订阅一个主题为”mqtt”的消息。”mqtt”为主题名,假如有客户端发布了主题为”mqtt”的消息,这个终端将会收到消息的内容。
mosquitto_sub -t mqtt
终端二:
这里就是发布一个主题为”mqtt”,内容为”hello mqtt”的消息。
mosquitto_pub -h localhost -t mqtt -m "hello mqtt"
这时终端一会收到:hello mqtt
9、错误解决
在安装过程中,或测试过程中可能会遇到错误:
mosquitto_sub: error while loading shared libraries: libmosquitto.so.1: cannot open shared object file: No such file or directory
解决方法:
# cat /etc/ld.so.conf# echo "/usr/local/lib">>/etc/ld.so.conf# ldconfig
- MQTT--linux安装部署
- Ubuntu安装部署mqtt
- Ubuntu安装部署mqtt
- Linux学习~部署Apollo服务器(mqtt)
- linux系统Ubuntu下简易安装mqtt
- MQTT的学习研究(十六) MQTT的Mosquitto的window安装部署
- linux mqtt
- MQTT broker 集群部署
- Mqtt Broker部署方法
- [MQTT]部署mosquitto服务
- linux centos7 安装MQTT mosquitto时常见异常及解决办法
- linux centos7 安装MQTT mosquitto时常见异常及解决办法
- linux虚拟机安装部署
- Linux valgrind 部署安装
- linux elasticsearch 安装部署
- linux安装部署git
- Linux JDK安装部署
- Linux 安装部署mysql
- 探索AIDL(1) -- 初识AIDL
- 浏览器兼容问题1
- 蓝牙稍微整理
- python装饰器
- MySql从一窍不通到入门(八)复制(replication)和集群(cluster)/读写分离
- MQTT--linux安装部署
- [LeetCode]两行代码快速实现回文数的判断
- 浏览器兼容问题2
- RocketMQ与Kafka对比(18项差异)
- Nodejs+Express中页面控制器及脚本自动加载设计
- 通俗理解九大排序算法
- sort-colors
- javaweb+SSH实现简单的权限管理系统
- MQTT--测试