4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DockerでHiveMQを動かしたメモ

Posted at

これは何?

MQTTブローカーHiveMQをdockerイメージで動かした時のメモです。
HiveMQは商用製品でクローズドソースですが、25クライアントまでは無料で試せます。

dockerイメージのbuild手順

適当に作業ディレクトリを作る

$ mkdir -p docker/hivemq
$ cd docker/hivemq

HiveMQを公式サイトからダウンロードする

HiveMQ公式サイトから最新のHiveMQを落とします。
僕が落としたのはhivemq-2.0.0.zipでした。
ダウンロードしたら先ほど作ったdocker/hivemqディレクトリに保存しておきます。

Dockerfileを作る

Dockerfile
FROM ubuntu
MAINTAINER Shin Hiroe <hogehoge@mail.com>

RUN echo "upgrade apt sources"
RUN apt-get update
RUN apt-get upgrade -y

RUN echo "install wget"
RUN apt-get install wget -y

RUN echo "install unzip"
RUN apt-get install unzip -y

RUN echo "install OpenJDK"
RUN apt-get install openjdk-7-jre -y

RUN echo "install HiveMQ"
COPY ./hivemq-2.0.0.zip /usr/local/
WORKDIR /usr/local
RUN unzip hivemq-2.0.0.zip
WORKDIR /usr/local/hivemq-2.0.0
RUN chmod 755 bin/run.sh
EXPOSE 1883

Dockerfileをもとにイメージを作る

  • -tオプションでubuntu:hivemqという名前をつけます
$ docker build -t ubuntu:hivemq .

ネットワーク設定

はじめてのDocker on Mac OS Xを参考にさせて頂きつつ、VirtualBoxでポートフォワーディングの設定をする。
今回はMQTTの標準ポート1883番を、単純にdockerコンテナの1883番にフォワードします。

コンテナの起動

-p 1883:1883で先ほどVirtualBoxに設定したポートフォワードを指定して起動。

$ docker run -t -p 1883:1883 -i ubuntu:hivemq "/usr/local/hivemq-2.0.0/bin/run.sh"

起動メッセージ。

-------------------------------------------------------------------------

                  _    _  _              __  __   ____
                 | |  | |(_)            |  \/  | / __ \ 
                 | |__| | _ __   __ ___ | \  / || |  | |
                 |  __  || |\ \ / // _ \| |\/| || |  | |
                 | |  | || | \ V /|  __/| |  | || |__| |
                 |_|  |_||_|  \_/  \___||_|  |_| \___\_\

-------------------------------------------------------------------------

  HiveMQ Start Script for Linux/Unix v1.2

-------------------------------------------------------------------------

  HIVEMQ_HOME: /usr/local/hivemq-2.0.0

  JAVA_OPTS:  -Djava.net.preferIPv4Stack=true

-------------------------------------------------------------------------

2014-06-14 10:48:38,358 INFO  - HiveMQ home directory: /usr/local/hivemq-2.0.0
2014-06-14 10:48:38,386 INFO  - Starting HiveMQ Server
2014-06-14 10:48:40,302 INFO  - Created user preferences directory.
2014-06-14 10:48:42,307 WARN  - No license file found. Using free personal licensing with restrictions to 25 connections.
2014-06-14 10:48:42,553 INFO  - Activating statistics callbacks with an interval of 60 seconds
2014-06-14 10:48:42,555 INFO  - Activating $SYS topics with an interval of 60 seconds
2014-06-14 10:48:42,999 INFO  - Starting on all interfaces and port 1883
2014-06-14 10:48:43,028 INFO  - Started HiveMQ 2.0.0 in 4672ms

起動したようです。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?