Mosquitto Ubuntu 安装

来源:互联网 发布:希腊移民知乎 编辑:程序博客网 时间:2024/05/19 22:25

参考官网

As of version 11.10 Oneiric Ocelot, mosquitto will be in the Ubuntu repositories so you can install as with any other package. If you are on an earlier version of Ubuntu or want a more recent version of mosquitto, add the mosquitto-dev PPA to your repositories list – see the link for details. mosquitto can then be installed from your package manager.sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppasudo apt-get updateIf the command “apt-add-repository” is not recognised, it can be installed with:sudo apt-get install python-software-properties

操作过程

root@iZwz92tbw6nsayzyqcumgdZ:~/download# apt-get install software-properties-common Reading package lists... DoneBuilding dependency tree       Reading state information... Donesoftware-properties-common is already the newest version.0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.root@iZwz92tbw6nsayzyqcumgdZ:~/download# root@iZwz92tbw6nsayzyqcumgdZ:~/download# root@iZwz92tbw6nsayzyqcumgdZ:~/download# apt-get install python-software-properties Reading package lists... DoneBuilding dependency tree       Reading state information... Donepython-software-properties is already the newest version.root@iZwz92tbw6nsayzyqcumgdZ:~/download# sudo add-apt-repository ppa:mosquitto-dev/mosquitto-ppa More info: https://launchpad.net/~mosquitto-dev/+archive/ubuntu/mosquitto-ppaPress [ENTER] to continue or ctrl-c to cancel adding itgpg: keyring `/tmp/tmphm49azto/secring.gpg' createdgpg: keyring `/tmp/tmphm49azto/pubring.gpg' createdgpg: requesting key 262C4500 from hkp server keyserver.ubuntu.comgpg: /tmp/tmphm49azto/trustdb.gpg: trustdb createdgpg: key 262C4500: public key "Launchpad mosquitto" importedgpg: Total number processed: 1gpg:               imported: 1  (RSA: 1)OKroot@iZwz92tbw6nsayzyqcumgdZ:~/download# root@iZwz92tbw6nsayzyqcumgdZ:~/download# sudo apt-get updateIgn http://mirrors.cloud.aliyuncs.com trusty InReleaseIgn http://mirrors.aliyun.com trusty InRelease                           Get:1 http://mirrors.aliyun.com trusty-security InRelease [65.9 kB]      Get:2 http://mirrors.cloud.aliyuncs.com trusty-security InRelease [65.9 kB]    Get:3 http://mirrors.cloud.aliyuncs.com trusty-updates InRelease [65.9 kB]     Get:4 http://mirrors.cloud.aliyuncs.com trusty-proposed InRelease [65.9 kB]    Hit http://mirrors.cloud.aliyuncs.com trusty-backports InRelease      ......................................root@iZwz92tbw6nsayzyqcumgdZ:~/download# root@iZwz92tbw6nsayzyqcumgdZ:~/download# sudo apt-get install mosquittoReading package lists... DoneBuilding dependency tree       Reading state information... DoneThe following extra packages will be installed:  libwebsockets3The following NEW packages will be installed:................................## 安装完成自动运行## 客户端安装root@iZwz92tbw6nsayzyqcumgdZ:/etc/mosquitto# sudo apt-get install mosquitto.clientsReading package lists... DoneBuilding dependency tree   

测试过程

打开两个终端,一个发布,一个订阅

发布test

admin@iZwz92tbw6nsayzyqcumgdZ:/data$ mosquitto_pub -h 127.0.0.1 -t test -m 'sfasfds'admin@iZwz92tbw6nsayzyqcumgdZ:/data$ 

订阅test

root@iZwz92tbw6nsayzyqcumgdZ:/etc/mosquitto# root@iZwz92tbw6nsayzyqcumgdZ:/etc/mosquitto# mosquitto_sub -h 127.0.0.1 -t testhello MqTTaskdfsld

常用命令

sudo service mosquitto start #启动sudo service mosquitto status #查看状态sudo service mosquitto restart #重启sudo service mosquitto stop #停止

监听端口(1883)

admin@iZwz92tbw6nsayzyqcumgdZ:/data$ netstat -an |grep 1883tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN     tcp6       0      0 :::1883                 :::*                    LISTEN     admin@iZwz92tbw6nsayzyqcumgdZ:/data$ 
0 0
原创粉丝点击