MQTT--linux安装部署(CentOS)
OS环境: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 1883
listener 8080
protocol 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安装部署(CentOS)的更多相关文章
- Linux安装部署jdk+tomcat+mysql
Linux安装部署测试环境 1. JDK安装下载 安装 yum search jdk 找到合适的jdk版本,以下图中的版本为例 yum install java-1.8.0-openjdk.x86_6 ...
- Linux安装部署FTP服务器
Linux安装部署FTP服务器 本文章会将安装FTP服务器的步骤以及一些遇到的问题来记录下 因为项目中要与第三方对接数据,需要用到FTP服务器以提供他们每天上传数据,因为之前在本地的VMware虚 ...
- Linux安装部署Redis(超级详细)
前言 网上搜索了一筐如何在Linux下安装部署Redis的文章,各种文章混搭在一起勉强安装成功了.自己也记录下,方便后续安装时候有个借鉴之处. Redis版本 5.0.4 服务器版本 Linux Ce ...
- linux安装部署Nginx
两个参考地址: NGINX的百度百科:https://baike.baidu.com/item/nginx/3817705?fr=aladdin NGINX的中文网站:http://www.nginx ...
- Linux安装部署
Linux桌面发行版 UbuntuCentOSRed heat LinuxOracle Linux 一.系统安装 1.系统分区 若手动分区swap和根分区必须创建,推荐创建boot分区. /----- ...
- MQTT linux centOS7 部署
系统版本centos7 X64 1.设置保存安装包路径 # cd /usr/local/src 2.开始下载源包 官网资源: https://mosquitto.org/files/source/ # ...
- Linux 安装部署 Redis
一.Redis介绍 Redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcache类似,但很大程度补偿了Memcache的不足,它支持存储的value类型相对更多 ...
- Linux安装软件-CentOS和Ubuntu介绍
开发十年,就只剩下这套架构体系了! >>> 不同Linux发行版的软件安装会有不同的方式,其中CentOS安装软件的主要方式是rpm和yum,Ubuntu可以使用apt-get, ...
- [Linux] 安装JBoss - CentOS
CentOS安装Jboss 7 AS方法:(安装java跳过) 1.首先下载JBoss 7 AS的zip文件. 2.使用SSH,上传到CentOS中.(如何使用的是wget命令下载,可以跳过些步),这 ...
随机推荐
- JDK7集合框架源码阅读(二) LinkedList
基于版本jdk1.7.0_80 java.util.LinkedList 代码如下 /* * Copyright (c) 1997, 2011, Oracle and/or its affiliate ...
- Codeforces Gym100952 D. Time to go back-杨辉三角处理组合数 (2015 HIAST Collegiate Programming Contest)
D. Time to go back time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Python的并发并行[1] -> 线程[0] -> threading 模块
threading模块 / threading Module 1 常量 / Constants Pass 2 函数 / Function 2.1 setprofile()函数 函数调用: thread ...
- jmeter引用cookies进行登录实战
以jmeter登录接口为例,就下面的这个登录页面 在测试之前,我们输入用户和密码先手动登录下,看看有那些网络信息,使用fiddler抓包 登录发送的是这个请求,我们看下使用什么方式,以及用到那些参数 ...
- 在CentOS 7上安装Node.js
一.安装1.进入官网下载最新版本https://nodejs.org/en/ 选择下载后上传或直接使用wget下载 wget https://nodejs.org/dist/v8.11.2/node- ...
- How to not display “Commit point reached - logical record count” counts
You can use the keyword silent, which is available in the options clause. You can set the followin ...
- ORACLE查询当前连接的用户信息及操作的SQL语句
ORACLE--查询当前连接的用户信息及操作的SQL语句 select sid, status, v$session.username 用户名, last_call ...
- Windows下将ISO镜像制作成U盘启动的工具(U盘启动工具/UltraISO/Rufus/Universal-USB)
说明:基于Windows的U盘启动制作都是非常的简单,在软件上指定ISO文件之后,一般都是选择写入到哪个U盘即可. 1.UltraISO 2.Rufus 3.Universal-USB 4.大白菜
- iOS学习4_UITableView的使用
UITableView相当于Android里面的ListView.但功能却比ListView强大太多. 使用UITableView须要指定数据源和代理. 1.显示全部的行 遵守UITableViewD ...
- Tomcat Deployment failure ,locked one or more files
在用Eclipse+Tomcat配置J2EE项目时,出现如下提示错误: Undeployment Failure could not be redeployed because it could no ...