0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ubuntu24.04, 22.04でEMQXをソースコードからビルドする

Last updated at Posted at 2025-05-01

はじめに

本記事は、MQTTブローカー「EMQX」を Ubuntu 22.04 または 24.04 上でソースコードからビルドし、起動するまでの手順をまとめた備忘録です。

今回の環境

  • Ubuntu 22.04.5 LTS
    または
  • Ubuntu 24.04.2 LTS

依存関係

EMQXをソースコードからビルドするためには、以下のパッケージが必要です。

  • Erlang/OTP
    • EMQX 4.4 は OTP 24 が必要
    • EMQX 5.0 ~ 5.3 は OTP 24 または 25 に対応
    • EMQX 5.4 以降は OTP 25 または 26 が必要

記事執筆時の最新バージョン EMQX 5.8 では OTP 27 が推奨とされています。

  • GCC:バージョン 4.8 以上
  • Git
  • make
  • openssl-devel(Ubuntuでは libssl-dev)
  • libcurl-devel(Ubuntuでは libcurl4-openssl-dev)

1. Erlang パッケージをインストール

リポジトリを使用したインストール方法もありますが、今回は単純に.debパッケージをダウンロードして直接インストールしました。

ls
esl-erlang_27.3.3-1~ubuntu~jammy_amd64.deb

sudo apt install ./esl-erlang_27.3.3-1~ubuntu~jammy_amd64.deb
  • 確認
$ erl
Erlang/OTP 27 [erts-15.2.6] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Eshell V15.2.6 (press Ctrl+G to abort, type help(). for help)
1> q(). # 終了
ok

2. その他のパッケージを一括でインストール

sudo apt update && sudo apt install -y \
  build-essential \      # GCC, g++, make など
  git \                  # Git
  libssl-dev \           # OpenSSL
  libcurl4-openssl-dev \ # cURL

3. EMQXソースコードの取得&ビルド

git clone https://github.com/emqx/emqx.git
cd emqx
make

ビルドエラーへの対応

make実行時に以下のようなエラーが発生したため、追加で以下のパッケージをインストールしました。

エラー
# エラー⓵: krb5.hが 見つからない
/home/****/emqx/_build/default/lib/sasl_auth/c_src/sasl_auth.c:3:10: fatal error: krb5.h: No such file or directory
    3 | #include <krb5.h>
      |          ^~~~~~~~

# エラー⓶: sasl/sasl.h が見つからない
/home/****/emqx/_build/default/lib/sasl_auth/c_src/sasl_auth.c:4:10: fatal error: sasl/sasl.h: No such file or directory
    4 | #include <sasl/sasl.h>
      |          ^~~~~~~~~~~~~
追加
sudo apt-get install -y libkrb5-dev
sudo apt-get install -y libsasl2-dev
  • ビルド成功時のログ(抜粋)
===> Analyzing applications...
===> Compiling emqx_connector_jwt
===> Compiling emqx_utils
===> Compiling emqx
===> Compiling emqx_durable_storage
===> Compiling emqx_ds_builtin_local
===> Compiling emqx_ds_backends
===> Compiling emqx_resource
===> Compiling emqx_mongodb
===> Compiling emqx_auth
===> Compiling emqx_auth_mongodb
===> Compiling emqx_ctl
===> Compiling emqx_retainer
===> Compiling emqx_modules
===> Compiling emqx_connector
===> Compiling emqx_bridge
===> Compiling emqx_rule_engine
===> Compiling emqx_bridge_http
===> Compiling emqx_dashboard
===> Compiling emqx_auto_subscribe
===> Compiling emqx_ldap
===> Compiling emqx_mysql
===> Compiling emqx_plugins
===> Compiling emqx_management
===> Compiling emqx_redis
===> Compiling emqx_auth_redis
===> Compiling emqx_postgresql
===> Compiling emqx_auth_postgresql
===> Compiling emqx_auth_mysql
===> Compiling emqx_auth_mnesia
===> Compiling emqx_auth_ldap
===> Compiling emqx_auth_jwt
===> Compiling emqx_auth_http
===> Compiling emqx_gateway
===> Compiling emqx_gateway_exproto
===> Compiling emqx_telemetry
===> Compiling emqx_prometheus
===> Compiling emqx_machine
===> Compiling emqx_gateway_stomp
===> Compiling emqx_gateway_mqttsn
===> Compiling emqx_bridge_mqtt
===> Compiling emqx_slow_subs
===> Compiling emqx_gateway_coap
===> Compiling emqx_gateway_lwm2m
===> Compiling emqx_conf
===> Compiling emqx_psk
===> Compiling emqx_exhook
DS backends available for this release (ce): [emqx_ds_builtin_local]
===> Assembling release emqx-5.8.5-g48359902...
===> Release successfully assembled: _build/emqx/rel/emqx

4. EMQX の起動&動作確認

ビルド完了後、以下のコマンドで EMQX を起動します。

起動
~/emqx$ _build/emqx/rel/emqx/bin/emqx start
WARNING: DB Backend is RLOG, but an incompatible OTP version has been detected. Falling back to using Mnesia DB backend.
WARNING: Default (insecure) Erlang cookie is in use.
WARNING: Configure node.cookie in /home/sdoi/emqx/_build/emqx/rel/emqx/etc/emqx.conf or override from environment variable EMQX_NODE__COOKIE
WARNING: NOTE: Use the same cookie for all nodes in the cluster.
EMQX 5.8.5-g48359902 is started successfully!

その後、ブラウザで http://<IPアドレス>:18083 にアクセスし、ダッシュボード画面が表示されれば正常に起動しています。

スクリーンショット 2025-05-01 205050.png

  • Username: admin
  • Password: public

停止は別のターミナルで行います。

停止
~/emqx$ _build/emqx/rel/emqx/bin/emqx stop
WARNING: 2539 is marked <defunct>, parent:     PID TTY          TIME CMD
      1 ?        00:00:03 systemd
ok

まとめ

今回は、Ubuntu 環境で EMQX をソースからビルドし、依存関係の解決から起動・動作確認までの手順を紹介しました。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?