sudo wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key sudo apt-key add mosquitto-repo.gpg.key cd /etc/apt/sources.list.d/ sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list sudo apt-get update sudo apt-get install mosquitto安裝三個 Mosquitto proper 會用到的程式庫
mosquitto – the MQTT broker (or in other words, a server)
mosquitto-clients – command line clients, very useful in debugging
python-mosquitto – the Python language bindings
sudo apt-get install mosquitto mosquitto-clients python-mosquitto安裝完後mosquitto會立即執行,但還需要進行部分設定,所以先停止
sudo /etc/init.d/mosquitto stop開啟設定檔案
sudo nano /etc/mosquitto/mosquitto.conf修改找到 log_dest 列,將後面改為 topic,如下
log_dest topic並再增加下面六個參數後存檔
log_type error log_type warning log_type notice log_type information connection_messages true log_timestamp true重新啟動mosquitto
sudo /etc/init.d/mosquitto start進行測試,開啟終端機,輸入下列指令
mosquitto_sub -d -t hello/world再開啟另一個終端機,輸入下列指令
mosquitto_pub -d -t hello/world -m "Hello from Terminal 2!"
會在第一個開啟的終端機看到如上畫面 |
會在第二個開啟的終端機看到如上畫面 |
沒有留言:
張貼留言