기본 콘텐츠로 건너뛰기

MQTT - Mosquitto Broker 설치

잡담 없이 내용만 쓸라니까 맘이 영 허전해서 한줄 끄적이자면.. 
ㅋㅋㅋㅋㅋㅋㅋㅋㅋ 아 이거.. MQTT 알면 알수록 대단한것 같은데 정작 구현하고 얼마만큼에 퍼포먼스를 보여줄지는 내눈으로 보기전까지 못믿겠음 
다만들고 오류만 뿜지 말자 ♥


MQTT - Push Server 개발 과정 - by.용기

( * 작업 배경 : LIVE 1 서버 / CentOS / root )

0. 리눅스 mosquitto 계정 추가 (브로커 설치시 이 계정을 자동으로 찾아서 설치가 진행된다.)
# useradd  mosquitto
# groupadd mosquitto

1. MQTT Broker 설치 (Live1 - CentOS 5.9, Live5 - CentOS 6)
 1) 의존성 패키지 설치 
==================================================================================================
# yum install gcc*
# yum install openssl openssl-devel
# yum install pcre pcre-devel
# yum install zlib zlib-devel
# yum install glibc glibc-devel
==================================================================================================
 - 최신 OpenSSL로 재설치
# cd /usr/local/src
# 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    ->  include /usr/local/openssl/lib  추가
include ld.so.conf.d/*.conf
include /usr/local/openssl/lib
# /sbin/ldconfig
==================================================================================================
 - OpenSSL 버전확인
# openssl version
OpenSSL 1.0.1c 10 May 2012
==================================================================================================
 - mosquitto 다운로드 및 설치 
# cd /usr/local/src
# 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 ld.so.conf.d/*.conf
include /usr/local/openssl/lib
include /usr/local/mosquitto/lib
/usr/lib
/usr/local/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
---------- 
---------- 내가 실제 작성한 내용
export MOSQUITTO_HOM=/usr/local/mosquitto
export PATH=$PATH:$MOSQUITTO_HOME/client
----------
# source /etc/profile
==================================================================================================
 - mosquitto 포트 개방 (1883)
# iptables -I INPUT -m tcp -p tcp --dport 1883 -j ACCEPT
# /sbin/service iptables save
# /sbin/service iptables restart
==================================================================================================
# mkdir /log
# mkdir /log/mosquitto
# touch /log/mosquitto/mosquitto.log
# 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 000.000.000.000 -t /test/1            << 설마 000.000.000.000 에 서버 ip주소를 안쓰고 저대로 쓰진 마시길 
  : 다른쪽에는 pub를 보내면
# mosquitto_pub -h 000.000.000.000 -t /test/1 -m "Hello Mosquitto"

mosquitto_pub -h 000.000.000.000 -t "ALL" -m "{seq:1,type:TEXT,sender_nick:yongki,anal_id:1,noti_msg:helloMqtt,is_cost:N,corp:emoney}"
mosquitto_pub -h 000.000.000.000 -t "ALL" -m "{seq:1,type:IMAGE,sender_nick:yongki,anal_id:1,noti_msg:helloMqtt,is_cost:N,corp:emoney,image_url:'http://img.x1.co.kr/popup/131230/pop_131230_hi.gif'}"

==================================================================================================
[참고]
 - 유닉스 포트 용도
0번 ~ 1023번: 잘 알려진 포트 (well-known port)
1024번 ~ 49151번: 등록된 포트 (registered port)
49152번 ~ 65535번: 동적 포트 (dynamic port)

[파라미터 사용법]
mosquitto_pub is a simple mqtt client that will publish a message on a single topic and exit.
mosquitto_pub version 1.1.2 running on libmosquitto 1.1.2.

Usage: mosquitto_pub [-h host] [-p port] [-q qos] [-r] {-f file | -l | -n | -m message} -t topic
                     [-i id] [-I id_prefix]
                     [-d] [--quiet]
                     [-u username [-P password]]
                     [--will-topic [--will-payload payload] [--will-qos qos] [--will-retain]]
                     [{--cafile file | --capath dir} [--cert file] [--key file]]
                     [--psk hex-key --psk-identity identity]
       mosquitto_pub --help

 -d : enable debug messages.
 -f : send the contents of a file as the message.
 -h : mqtt host to connect to. Defaults to localhost.
 -i : id to use for this client. Defaults to mosquitto_pub_ appended with the process id.
 -I : define the client id as id_prefix appended with the process id. Useful for when the
      broker is using the clientid_prefixes option.
 -l : read messages from stdin, sending a separate message for each line.
 -m : message payload to send.
 -n : send a null (zero length) message.
 -p : network port to connect to. Defaults to 1883.
 -q : quality of service level to use for all messages. Defaults to 0.
 -r : message should be retained.
 -s : read message from stdin, sending the entire input as a message.
 -t : mqtt topic to publish to.
 -u : provide a username (requires MQTT 3.1 broker)
 -P : provide a password (requires MQTT 3.1 broker)
 --help : display this message.
 --quiet : don't print error messages.
 --will-payload : payload for the client Will, which is sent by the broker in case of
                  unexpected disconnection. If not given and will-topic is set, a zero
                  length message will be sent.
 --will-qos : QoS level for the client Will.
 --will-retain : if given, make the client Will retained.
 --will-topic : the topic on which to publish the client Will.
 --cafile : path to a file containing trusted CA certificates to enable encrypted
            communication.
 --capath : path to a directory containing trusted CA certificates to enable encrypted
            communication.
 --cert : client certificate for authentication, if required by server.
 --key : client private key for authentication, if required by server.
 --psk : pre-shared-key in hexadecimal (no leading 0x) to enable TLS-PSK mode.
 --psk-identity : client identity string for TLS-PSK mode.




댓글

이 블로그의 인기 게시물

변액보험판매자격시험공부 요점정리

생명보험협회 주관 변액보험판매자격시험 (PBT)  요점 정리 입니다  아래 내용만 3일정도 외워서  모의고사 4번정도 풀고  시험봤구요  82.5점으로 합격했습니다 모두들 합격하세요 ~!  --------------------------------------------------------------------- 직접금융 / 간접금융 은행 : 간접금융 자금의 공급자와 수요자 사이에서 빌려주고,돌려받는것을 수행해준다 공급자와 수요자가 직접 거래하고 책임지지 않는다 증권사 : 직접금융 기업(공급자)은 주식/채권 발행 -> 증권사는 그것들을 인수역할을함 개인(수요자)는 기업이 발행한 주식/채권을 직접 매매한다 자금의 공급자와 수요자가 직접 책임진다 증권사는 중간연결다리 역할만 한다 금융시장의 기능 자금의 중계 금융자산의 가격결정 유동성 제공 거래비용 절감 ★ 탐색비용, 정보비용등이 금융시장이 있음으로 인해 비용이 절감된다 ★ 위험관리 위험 = 변동성, 위험이크다(변동성이크다), 위험에 대한 보상 = 위험프리미엄 위험회피도가 높은 투자자는 변동성이 높은 투자를 했을때 위험회피도가 낮은 투자자에 비해 위험프리미엄이 높다 시장규율 만기는 1년을 기준으로함 1년 미만 :  자금시장  (단기) 장기시장에비해  거래규모 크다 (유동성 풍부) 1년 이상 :  자본시장  (장기)  오래투자하므로 단기보다  변동폭이 크다 단기시장은 유동성이 풍부하고 변동폭이 크다 (X) : 변동폭이 큰건 장기시장이다 장기상품  주식 채권 자산유동화증권 단기상품 장기상품을 제외하고 전부다 단기상품 콜 금융 기관 끼리 돈을 빌리는것 만기 1일이 대다수 최장만기는 90일 RP (환매채권) 개인 의 채권 투자 방식  증권사가 사들인 기업채권을 개인이 투자하고, 증권사가 개인이 투자한 채권을 다시 사들이는 형태 예금자보호 불가  (영어로된 용어는 예금자보호불가)...

Android 스마트폰 기본 웹브라우저(Chrome:크롬) 호출하는 스키마(URL Scheme)

신용카드결제 페이지 주소를 카톡으로 던졌을때 카톡 내부에서 결제가 이루어지다보니 결제완료까지 정상적으로 처리되지 않는 경우가 발생한다더라 그래서 생각해본게.. 1) 카카오통 채팅방  2) 링크 전송  3) 링크를 클릭하면 스마트폰애 내장된 웹브라우저를 실행하는 URL스키마 실행  4) 실행된 웹브라우저에서 결제페이지로 이동 이 절차를 거치면 카톡 외부로 나와서 독립적인 웹브라우저상에서 결제를 진행하기때문에 정상처리가 가능할것이라고 판단 찾다 찾다가.. 알아낸것이 안드로이드 (가능) - 롤리팝부터 크롬 브라우저가 기본앱이다 - 크롬을 호출방법 intent://www.naver.com#Intent;scheme=http;package=com.android.chrome;end  아이폰 (조건부 가능) - 사파리를 호출하는 앱스키마가 없으며, 사파리를 통해서 검색어를 입력한 검색기능만 가능 - 크롬브라우저 앱이 설치되어있을경우 아래와같이 호출 가능 googlechrome:////www.naver.com <사용법> < html > < body > < script >      var currentOS = "else" ;      var mobile = ( /iphone | ipad | ipod | android/ i .test(navigator.userAgent.toLowerCase()));      if (mobile) {          var userAgent = navigator.userAgent.toLowerCase();    ...

모델링크 - 일반인 모델 매칭 앱 (모델 구인/구직)

일반인 모델 구인구직 앱 - 모델링크 홈페이지 :  https://modellink.modoo.at/?link=8d7jafyh 앱다운로드 랜딩페이지 : https://model-link.web.app 애플 앱스토어 링크 Click 구글 플레이스토어 링크 Click 누구나 모델이 될 수 있고, 모델을 찾을 수 있는 일반인 모델 구인구직 앱 입니다 [ 앱 소개 ] - 제공되는 모든 기능은 무료입니다. 1. 모델 모집 헤어, 메이크업, 뷰티, 타투(문신), 왁싱(제모), 네일아트, 피팅모델 등 여러 분야를 대상으로 사진, 영상 촬영 및 CF(광고), 영화, 드라마 출연 섭외 또는 디자이너 자격증 시험응시 모델, 포트폴리오 제작을 위한 모델 모집공고를 올려보세요 실시간 채팅으로 모델지원자가 직접 연락드릴겁니다 + 게시글 끌어올리기 (끌올) 제공 2. 모델 프로필 등록 무료 또는 저렴한 가격으로 헤어스타일링, 메이크업, 타투(문신), 왁싱(제모), 네일아트를 받고싶거나 사진, 영상 촬영 및 CF(광고), 영화, 드라마 출연 또는 디자이너 자격증 시험응시 모델, 포트폴리오 모델 등 긱(Gig)한 모델 아르바이트를 원하시는분들은 망설이지 말고 모델프로필을 등록해보세요 실시간 채팅으로 모델섭외가 들어올거에요 + 게시글 끌어올리기 (끌올) 제공 3. CHAT (실시간 채팅) 모델링크 앱에서 제공하는 실시간 채팅기능으로 편리하게 모델을 지원하고 섭외할 수 있어요 4. ETC (기타 제공기능) - 업체 주소지 등록 및 지도 제공 - 실시간 푸시메시지 송수신 - 불건전 사용자 신고 - 모집공고 및 모델 즐겨찾기 - 분야, 지역, 성별, 나이, 키(신장) 등을 조건으로 조회결과 필터링 제공 - 관심 지역의 모집공고, 모델지원자 발생 알림 - 개발자에게 문의 및 건의 하기 5. 모델 구인구직 카테고리 - 대분류 : 사진촬영, 영상촬영, 자격증시험, 포트폴리오, 성형/시술 - 소분류 : 헤어 모델, 얼굴 모델, 눈썹/속눈썹 모델, 바디 모델, 피팅 모델,...