Mosquitto 1.3.1 버전을 설치하는데 make 에서 에러가 발생..


"mosquitto_internal.h:51:20: error: ares.h: No such file or directory"


 

# make

set -e; for d in lib client src; do make -C ${d}; done

make[1]: Entering directory `/usr/local/mosquitto/lib'

cc -Wall -ggdb -O2  -I. -I.. -I../lib -fPIC -DWITH_TLS -DWITH_TLS_PSK -DWITH_THREADING -DWITH_SRV -c mosquitto.c -o mosquitto.o

In file included from mosquitto.c:46:

mosquitto_internal.h:51:20: error: ares.h: No such file or directory

In file included from mosquitto.c:46:

mosquitto_internal.h:238: error: expected specifier-qualifier-list before 'ares_channel'

mosquitto.c: In function 'mosquitto_loop':

mosquitto.c:841: error: 'struct mosquitto' has no member named 'achan'

mosquitto.c:844: warning: implicit declaration of function 'ares_fds'

mosquitto.c:844: error: 'struct mosquitto' has no member named 'achan'

mosquitto.c:924: error: 'struct mosquitto' has no member named 'achan'

mosquitto.c:925: warning: implicit declaration of function 'ares_process'

mosquitto.c:925: error: 'struct mosquitto' has no member named 'achan'

make[1]: *** [mosquitto.o] Error 1

make[1]: Leaving directory `/usr/local/mosquitto/lib'

make: *** [mosquitto] Error 2


검색을 해보니 SRV 관련 설정을 변경해주면 되는 듯 하다. (http://blog.csdn.net/Netown_Ethereal/article/details/22653125)

DNS 레코드 관련된 거 같은데.. 자세한 건 패스 -.-;;


mosquitto 폴더의 config.mk 를 열어서 WITH_SRV:=yes 를 WITH_SRV:=no 로 변경하고 make 해보자.


# vi config.mk

# Build with SRV lookup support.  

WITH_SRV:=no



오픈소스 MQTT Broker Mosquitto를 설치하자.

 

의존성 패키지 설치

# yum install gcc*

# yum install openssl openssl-devel

# yum install pcre pcre-devel

# yum install zlib zlib-devel

# yum install glibc glibc-devel

 

CentOS는 기본적으로 OpenSSL을 탑재하고 있다.

# openssl version

OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008

 

하지만 최신 OpenSSL로 재설치하자.

# cd /usr/local/src

# wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz

# tar zxvf openssl-1.0.1c.tar.gz

# cp -Rf openssl-1.0.1c /usr/local/openssl

# cd ../openssl/

# export LDFLAGS=-L/usr/local/lib

# export CPPFLAGS=-I/usr/local/include

# make clean

# ./config --prefix=/usr --openssldir=/usr/local/openssl shared threads zlib

# make

# make test

# make install

# make clean

# unset LDFLAGS

# unset CPPFLAGS

# vi /etc/ld.so.conf

# openssl lib 폴더 경로 추가

include /usr/local/openssl/lib

# /sbin/ldconfig

 

OpenSSL 버전확인

# openssl version

OpenSSL 1.0.1c 10 May 2012

 

 

자. Mosquitto를 설치하자.


우선 mosquito 계정을 만들자

# useradd  mosquitto

# groupadd mosquitto

 

소스를 다운받아 설치하자.

# cd /usr/local/src

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

# tar zxvf mosquitto-1.1.2.tar.gz

# cp -Rf mosquitto-1.1.2 /usr/local/mosquitto

# cd ../mosquitto

# make && make install

# vi /etc/ld.so.conf

include /usr/local/mosquitto/lib

# /sbin/ldconfig

# ln -s /usr/local/mosquitto/lib/libmosquitto.so.1 /usr/lib/libmosquitto.so.1

 

MOSQUITTO_HOME 셋팅

# vi /etc/profile

MOSQUITTO_HOME=/usr/local/mosquitto

export MOSQUITTO_HOME

PATH=$PATH:$MOSQUITTO_HOME/src

export PATH

# source /etc/profile

 

mosquitto 포트 개방 (1883)

# iptables -I INPUT -m tcp -p tcp --dport 1883 -j ACCEPT

# /sbin/service iptables save

# /sbin/service iptables restart

 

구동하기 (http://mosquitto.org/man/mosquitto-8.html)

# mosquitto -c /usr/local/mosquitto/mosquitto.conf -d > /log/mosquitto/mosquitto.log 2>&1

 

잘 구동되었나 확인

# tail -f /log/mosquitto/mosquitto.log

1361175067: mosquitto version 1.1.2 (build date 2013-02-18 16:12:55+0900) starting

1361175067: Config loaded from mosquitto.conf.

1361175067: Opening ipv6 listen socket on port 1883.

1361175067: Opening ipv4 listen socket on port 1883.

 

테스트를 해보자.

한쪽에는 sub를 실행해놓구

# mosquitto_sub -h 192.168.0.201 -t /test/1

다른쪽에는 pub를 보내면

# mosquitto_pub -h 192.168.0.201 -t /test/1 -m "testtest"

sub쪽에 메시지가 잘 도착할 것이다.

+ Recent posts