图解MQTT服务器搭建

作者:清风拂面 | 创建时间: 2023-06-08
MQTT是IBM推出的一种针对移动终端设备的基于TCP/IP的发布/预订协议,可以连接大量的远程传感器和控制设备。 MQTT的官网里面提供了官方推荐的各种服务器和客户端使用的各种语言版本的API。 下面以服务器apache-apollo-1...
图解MQTT服务器搭建

操作方法

下载Apollo服务器,下载后解压。如下图所示:

bin下包含apollo和apollo.cmd两个文件,如下图所示:

运行apache-apollo-1.7.1\bin\apollo.cmd,输入create mybroker(名字任意取,这里是根据官网介绍的来取的)创建服务器实例,服务器实例包含了所有的配置,运行时数据等,并且和一个服务器进程关联。如果双击apollo.cmd出现闪一下就关闭的情况,则需要在命令行中敲入命令,如下图所示:

create mybroker之后会在bin目录下生成mybroker文件夹,如下图所示: 里面包含有很多信息,其中etc\apollo.xml文件下是配置服务器信息的文件,etc\users.properties文件包含连接MQTT服务器时用到的用户名和密码,可以修改原始的admin=password,可以接着换行添加新的用户名密码。

打开cmd,运行apache-apollo-1.7.1\bin\mybroker\bin\apollo-broker.cmd run 开启服务器,如下图所示:

可以在浏览器中输入http://127.0.0.1:61680/,其自动转入:http://127.0.0.1:61680/console/index.html,apollo的登录页面,如下图所示: 此界面表示已经安装成功:该登录的用户名和密码在\apache-apollo-1.7.1\bin\mybroker\etc\users.properties里,打开users.properties文件: ## ---------------------------------------------------------------------------  ## Licensed to the Apache Software Foundation (ASF) under one or more  ## contributor license agreements. See the NOTICE file distributed with  ## this work for additional information regarding copyright ownership.  ## The ASF licenses this file to You under the Apache License, Version 2.0  ## (the "License"); you may not use this file except in compliance with  ## the License. You may obtain a copy of the License at  ##  ## http://www.apache.org/licenses/LICENSE-2.0  ##  ## Unless required by applicable law or agreed to in writing, software  ## distributed under the License is distributed on an "AS IS" BASIS,  ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  ## See the License for the specific language governing permissions and  ## limitations under the License.  ## --------------------------------------------------------------------------- #  # The list of users that can login. This file supports both plain text or  # encrypted passwords. Here is an example what an encrypted password  # would look like:  #  # admin=ENC(Cf3Jf3tM+UrSOoaKU50od5CuBa8rxjoL)  # admin=password

经过上面的简单步骤,服务器基本上就已经完成。输入admin,password就可以登录了,如下图所示:

点击展开全文

更多推荐