centos 7 部署 MQTT

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

1.由于emqttd是用Erlang语言编写的,所以,在Linux下安装时,需要先安装Erlang。

安装依赖库

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/

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

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

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

jinterface : No Java compiler found 什么?没有java编译器?其实这里我们可以选择用gcc等其他方式来编译erlang。

如果你安装了gcc,这里就用不上java编译了,因此可以在configure时增加 –disable-javac 避免第二个错误; 

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

好吧,想办法安装下unixODBC:

安装 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

 

posted @ 2018-07-15 21:58  避暑山庄  阅读(4948)  评论(0编辑  收藏  举报