centos搭建MQTT服务器Mosquitto

1.安装工具

yum install gcc gcc-c++

yum install openssl-devel

yum install c-ares-devel

yum install libuuid-devel

yum install wget

yum install cmake

yum install build-essential python quilt devscripts python-setuptools python3 

yum install libssl-dev libc-ares-dev uuid-dev daemon openssl-devel

 

2.下载并编译安装libwebsockets

wget https://libwebsockets.org/git/libwebsockets/snapshot/libwebsockets-2.0.2.tar.gz

tar zxvf libwebsockets-2.0.2.tar.gz

cd libwebsockets-2.0.2

mkdir build

cd build

cmake .. -DLIB_SUFFIX=64

make install

ldconfig

 

3.修正链接库

vim /etc/ld.so.conf.d/liblocal.conf

/usr/local/lib64

/usr/local/lib

 

ldconfig

 

4.下载并编译安装mosquitto

wget http://mosquitto.org/files/source/mosquitto-1.4.9.tar.gz

tar -xzvf mosquitto-1.4.9.tar.gz

cd mosquitto-1.4.9

更改configure.mk中

WITH_WEBSOCKETS:=no

WITH_WEBSOCKETS:=yes

make

make install

cp mosquitto.conf /etc/mosquitto

 

5.修改mosquitto.conf文件

在/etc/mosquitto/mosquitto.conf的Default Listener一节添加如下几行:

CentOS 安装Mosquitto及测试 - allegro_tyc - allegro_tyc的博客

 

6.运行mosquitto

mosquitto -c /etc/mosquitto/mosquitto.conf

mosquitto -c /etc/mosquitto/mosquitto.conf -v

或mosquitto -c /etc/mosquitto/mosquitto.conf -d

 

7.本机测试mosquitto

在服务器上新建两个shell,A和B

A 订阅主题:

mosquitto_sub -t topicA

B 推送消息:

mosquitto_pub -t topicA -h localhost -m "topicA test"

 

PS:

MQTT监控软件链接

http://www.jensd.de/apps/mqttfx/1.7.1/

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值