Ubuntu에 Mosquitto(MQTT Broker) 3분 설치

Install Mosquitto (MQTT Broker) on Ubuntu in 3 minutes

Posted by dydtjr1128 on January 07, 2018 · 2 mins read MQTT

Ubuntu에서 Mosquitto(MQTT Broker) 설치하기


/img/Ch

※본 글은 Mosquitto1.4.14 버전 기준으로 작성되었습니다.

  1. 환경 설정
    OS - Ubuntu 16.04.3-desktop-amd64
    Source - mosquitto-1.4.14

  2. 사전 설치 라이브러리
    sudo apt-get install openssl build-essential libc-ares-dev uuid-dev libssl-dev libcurl4-openssl-dev libmysqlclient-dev
    
  3. Mosquitto 설치
    cd ~ 
    wget http://mosquitto.org/files/source/mosquitto-1.4.14.tar.gz
    tar xvf mosquitto-1.4.14.tar.gz
    cd mosquitto-1.4.14 
    make 
    sudo make install
    
  4. Mosquitto 실행
    sudo mosquitto
    
  5. Test
    mosquitto_sub -h 127.0.0.1 -t 'topic'
    mosquitto_pub -h 127.0.0.1 -t 'topic' -m "Hello Mosquitto!"
    
    #유저 pw, name 설정 한 경우
    mosquitto_pub -t 'topic' -u username -P password -m 'message' 
    mosquitto_sub -t 'topic' -u username -P password
    

※ Mosquitto Command

-c, –config-file
Load configuration from a file. If not given, the default values as described in mosquitto.conf(5) are used.
-d, –daemon
Run mosquitto in the background as a daemon. All other behaviour remains the same.
-p, –port
Listen on the port specified instead of the default 1883. This acts in addition to the port setting in the config file. May be specified multiple times to open multiple sockets listening on different ports. This socket will be bound to all network interfaces.
-v, –verbose
Use verbose logging. This is equivalent to setting log_type to all in the configuration file. This overrides and logging options given in the configuration file.

※ Mosquitto 서비스 종료 시키는 방법

sudo /etc/init.d/mosquitto stop