centos 7 部署 MQTT

官方教程  :头痛的是nginx 和 mqtt布局有所冲突,后台不能使用须要调整,固然是用 nginx自家的布局没问题,可是要收费html

1.因为emqttd是用Erlang语言编写的,因此,在Linux下安装时,须要先安装Erlang。java

安装依赖库

sudo yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel

获取源码包

wget http://www.erlang.org/download/otp_src_R13B04.tar.gz

解压、编译、安装

tar xfvz otp_src_R13B04.tar.gz
cd otp_src_R13B04/

 /**************************此时开始到下面对接处****************************/node

编译此时会出大问题,会提示没有java什么的,须要进行下面操做,linux

这里主要注意 APPLICATIONS DISABLED 部分的提示,其余两部分是不影响编译的。nginx

jinterface : No Java compiler found 什么?没有java编译器?其实这里咱们能够选择用gcc等其余方式来编译erlang。c++

若是你安装了gcc,这里就用不上java编译了,所以能够在configure时增长 –disable-javac 避免第二个错误; shell

odbc : ODBC library – link check failed  表示你未安装unixODBC库centos

好吧,想办法安装下unixODBC:api

安装 ODBC服务器

下载unixODBC源码包(http://www.unixodbc.org/unixODBC-2.2.1.tar.gz)放到某处好比/usr/local下,而后运行下述命令:

tar zxvf unixODBC-2.2.1.tar.gz

  cd unixODBC-2.2.1

  ./configure --prefix=/usr/local/unixODBC-2.2.1 --includedir=/usr/include --libdir=/usr/lib -bindir=/usr/bin --sysconfdir=/etc --enable-gui=no

    make

    make install

 紧接着会出现 checking for X... 
configure: error: Can't find X includes

解决方法:

./configure --x-includes=/usr/include/X11

后又出现

checking for X... configure: error: Can't find X libraries. Please check your installation and add the correct paths!

./configure --x-includes=/usr/include/X11 --x-libraries=/usr/lib/X11

 /**************************回到最原来的地方****************************/

以后回过头cd到以前的otp_src_R13B04目录

执行

./configure --prefix=/home/erlang --without-javac

make

make install

上一步会出现(正常情况)

*********************************************************************
**********************  APPLICATIONS DISABLED  **********************
*********************************************************************

jinterface     : Java compiler disabled by user

*********************************************************************
*********************************************************************
**********************  APPLICATIONS INFORMATION  *******************
*********************************************************************

wx             : wxWidgets not found, wx will NOT be usable

*********************************************************************
*********************************************************************
**********************  DOCUMENTATION INFORMATION  ******************
*********************************************************************

documentation  : 
                 xsltproc is missing.
                 fop is missing.
                 The documentation can not be built.

*********************************************************************

虽然会等待一会,可是最终仍是成功了,至少个人是成功了,哈哈

作个ln吧,你要是不想要就不用执行这个命令了.

ln -s /usr/local/erlang/bin/erl /usr/local/bin/erl

设置环境变量以便下一步安装时使用(这个只是临时性的设置)

export PATH=$PATH:/usr/local/erlang/bin/

或者永久设置

编辑/etc/profile文件,而后在最下边加上

gedit /etc/profile

export PATH=$PATH:/usr/local/erlang/bin/

部署EMQ

下载和安装

到这里获取Linux通用安装包:http://emqtt.com/docs/v2/install.html#linux

unzip emqttd-centos7-v2.0.zip

控制台调试模式启动,检查 EMQ 是否可正常启动:

cd emqttd && ./bin/emqttd console

EMQ 消息服务器如启动正常,控制台输出:

alarm_handler: {set,{system_memory_high_watermark,[]}}
starting emqttd on node 'emq@127.0.0.1'
emqttd ctl is starting...[ok]
emqttd hook is starting...[ok]
emqttd router is starting...[ok]
emqttd pubsub is starting...[ok]
emqttd stats is starting...[ok]
emqttd metrics is starting...[ok]
emqttd pooler is starting...[ok]
emqttd trace is starting...[ok]
emqttd client manager is starting...[ok]
emqttd session manager is starting...[ok]
emqttd session supervisor is starting...[ok]
emqttd wsclient supervisor is starting...[ok]
emqttd broker is starting...[ok]
emqttd alarm is starting...[ok]
emqttd mod supervisor is starting...[ok]
emqttd bridge supervisor is starting...[ok]
emqttd access control is starting...[ok]
emqttd system monitor is starting...[ok]
emqttd 2.3.10 is running now
Eshell V9.0  (abort with ^G)
(emq@127.0.0.1)1> Load emq_mod_presence module successfully.
dashboard:http listen on 0.0.0.0:18083 with 4 acceptors.
mqtt:tcp listen on 127.0.0.1:11883 with 4 acceptors.
mqtt:tcp listen on 0.0.0.0:1883 with 16 acceptors.
mqtt:ws listen on 0.0.0.0:8083 with 4 acceptors.
mqtt:ssl listen on 0.0.0.0:8883 with 16 acceptors.
mqtt:wss listen on 0.0.0.0:8084 with 4 acceptors.
mqtt:api listen on 0.0.0.0:8080 with 4 acceptors.

CTRL+c关闭控制台。守护进程模式启动:

./bin/emqttd start

 状态查询先进入目录

cd /home/emqttd/bin
emqttd_ctl status
http://localhost:8080/status

中止服务

emqttd stop
相关文章
相关标签/搜索