Home >Java >javaTutorial >How to build an MQTT server under Ubuntu

How to build an MQTT server under Ubuntu

坏嘻嘻
坏嘻嘻Original
2018-09-17 10:44:233590browse

The content of this article is about how to build an MQTT server under Ubuntu. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Preface

The blogger previously wrote an article "Building an MQTT Server under Windows". This time I will try to build an MQTT server under Ubuntu. In fact, after downloading the source code package, the rest is almost the same as that article.

Development environment

  • Virtual machine Ubuntu 14.04.5 LTS

  • Apache-Apollo-1.7.1

Preparation work

Since building Apollo environment variables requires JAVA_HOME, you need to install JDK at this time. You can refer to this article: "Ubuntu Installs JDK1.8.0 and Configure environment variables".

Download and decompression

First download Apache-Apollo, download page: http://www.apache.org/dyn/closer.cgi?path=activemq/activemq-apollo/1.7 .1/apache-apollo-1.7.1-unix-distro.tar.gz

Or enter the following command:

wget http://apache.fayea.com/activemq/activemq-apollo/1.7.1/apache-apollo-1.7.1-unix-distro.tar.gz

Decompress the source package:

tar -zxvf apache-apollo-1.7.1-unix-distro.tar.gz

Configuration

Enter the apache-apollo-1.7.1/bin directory

cd apache-apollo-1.7.1/bin/

Enter ./apollo to view the help

pi@raspberry-pi:~/Downloads/apache-apollo-1.7.1/bin$ ./apollo
usage: apollo [--log <log_level>] <command> [<args>]The most commonly used apollo commands are:
    create           creates a new broker instance
    disk-benchmark   Benchmarks your disk&#39;s speed
    help             Display help information    version          Displays the broker versionSee &#39;apollo help <command>&#39; for more information on a specific command.

Create a Broker example: /apollo create mybroker. MQTT servers are all called Broker.

pi@raspberry-pi:~/Downloads/apache-apollo-1.7.1/bin$ ./apollo create mybroker
Creating apollo instance at: mybroker
Generating ssl keystore...

You can now start the broker by executing:  

   "/home/***/Downloads/apache-apollo-1.7.1/bin/mybroker/bin/apollo-broker" run

Or you can setup the broker as system service and run it in the background:

   sudo ln -s "/home/***/Downloads/apache-apollo-1.7.1/bin/mybroker/bin/apollo-broker-service" /etc/init.d/
   /etc/init.d/apollo-broker-service start

There will be prompts later on how to start the server and create a service.

Start Apollo:

pi@raspberry-pi:~/Downloads/apache-apollo-1.7.1/bin$ ./mybroker/bin/apollo-broker run

After checking the print information, you can know the port to which MQTT is connected and the management page port.

Finish.

The above is the detailed content of How to build an MQTT server under Ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn