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
相關文章
相關標籤/搜索