emqttd消息服务器可跨平台运行在Linux、FreeBSD、Mac OS X或Windows服务器上。由于emqttd是Erlang编写的,所以,在Linux下安装时,需要先安装Erlang。
注:产品部署建议Linux、FreeBSD服务器,不推荐Windows服务器。
1.安装依赖库
> sudo yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel
2.获取源码包
> wget http://www.erlang.org/download/otp_src_R13B04.tar.gz
3.解压、编译、安装
> tar xfvz otp_src_R13B04.tar.gz
> cd otp_src_R13B04/
> ./configure --with-ssl
> sudo make install
4.可能遇到的错误
{error,{load_Failed,”Failed to load NIF library: ‘/usr/local/lib/erlang/lib/crypto-2.0/priv/lib/crypto.so: undefined symbol: enif_make_new_binary’”}}
那么极有可能是两个原因:
没有安装OpenSSL 你安装了多版本的Erlang,R14A和R13B04冲突造成的,删除erlang相关的文件夹,重新安装即可
Crypto的类库可能多次折磨到你,如果在windows环境中遇到下面的错误:
application: crypto
exited: {shutdown,{crypto_app,start,[normal,[]]}}
那基本上就是因为没有安装OpenSSL的原因,去下载一个Win32OpenSSL安装一下就可以解决,安装过程中按照默认一路next即可。
还需要提醒的是:在centos环境中,建议规划好服务器不要在root目录安装,否则你在make的时候就会遇到错误。
5.emqttd程序包下载
emqttd消息服务器每个版本会发布Ubuntu、CentOS、FreeBSD、Mac OS X、Windows平台的程序包。
下载地址: http://emqtt.com/downloads
Debian http://emqtt.com/downloads/latest/debian
Ubuntu http://emqtt.com/downloads/latest/ubuntu
CentOS http://emqtt.com/downloads/latest/centos
FreeBSD http://emqtt.com/downloads/latest/freebsd
Mac OS X http://emqtt.com/downloads/latest/macosx
Windows http://emqtt.com/downloads/latest/windows
安装包命名由平台、版本、时间组成,例如: emqttd-centos64-0.16.0-beta-20160216.zip
@H_404_88@6.Linux服务器安装(以Centos为例)CentOS平台为例,下载安装包解压: http://emqtt.com/downloads/latest/centos
unzip emqttd-centos64-1.1-beta-20160601.zip
控制台调试模式启动,检查emqttd是否可正常启动:
cd emqttd && ./bin/emqttd console
emqttd消息服务器如启动正常,控制台输出:
starting emqttd on node 'emqttd@127.0.0.1'
emqttd ctl is starting...[done]
emqttd trace is starting...[done]
emqttd pubsub is starting...[done]
emqttd stats is starting...[done]
emqttd metrics is starting...[done]
emqttd retainer is starting...[done]
emqttd pooler is starting...[done]
emqttd client manager is starting...[done]
emqttd session manager is starting...[done]
emqttd session supervisor is starting...[done]
emqttd broker is starting...[done]
emqttd alarm is starting...[done]
emqttd mod supervisor is starting...[done]
emqttd bridge supervisor is starting...[done]
emqttd access control is starting...[done]
emqttd system monitor is starting...[done]
http listen on 0.0.0.0:18083 with 4 acceptors.
mqtt listen on 0.0.0.0:1883 with 16 acceptors.
mqtts listen on 0.0.0.0:8883 with 4 acceptors.
http listen on 0.0.0.0:8083 with 4 acceptors.
Erlang MQTT Broker 1.1 is running now
Eshell V6.4 (abort with ^G)
(emqttd@127.0.0.1)1>
CTRL+c关闭控制台。守护进程模式启动:
./bin/emqttd start
emqttd消息服务器进程状态查询:
./bin/emqttd_ctl status
正常运行状态,查询命令返回:
$ ./bin/emqttd_ctl status
Node 'emqttd@127.0.0.1' is started
emqttd 1.1 is running
emqttd消息服务器提供了状态监控URL:
http://localhost:8083/status
停止服务器:
./bin/emqttd stop
7.其他
此文为简单入门介绍,详细内容可参看链接http://emqtt.com/docs/v1/install.html。
原文链接:https://www.f2er.com/centos/379767.html