Installation of Fluent Bit on Ubuntu MATE 22.04.3 LTS
インストール
- Ubuntu MATE 22.04.3 LTS に Fluent Bit の最新版 (v3.0.0) のインストールを試みた。git clone してインストールした。 Ubuntu 用の dep ファイルからインストールもできそうだが、NestDAQ ではソースからコンパイルするのが基本路線なので、それに従う。
- インストールのコマンドは以下の通り。
$ cd $HOME/nestdaq/src $ git clone https://github.com/fluent/fluent-bit $ cd fluent-bit $ cmake -DCMAKE_INSTALL_PREFIX=$HOME/nestdaq \ -B ./build -S . $ cd build $ time make -j10 ... real 0m52.502s user 3m14.021s sys 0m33.659s $ make install ... -- Installing: /home/nestdaq/nestdaq/lib/fluent-bit/libfluent-bit.so -- Installing: /home/nestdaq/nestdaq/bin/fluent-bit -- Installing: /lib/systemd/system/fluent-bit.service CMake Error at src/cmake_install.cmake:97 (file): file INSTALL cannot copy file "/home/nestdaq/nestdaq/src/fluent-bit/init/fluent-bit.service" to "/lib/systemd/system/fluent-bit.service": Permission denied. Call Stack (most recent call first): cmake_install.cmake:54 (include) make: *** [Makefile:120: install] Error 1
ちなみに、fluent-bit ディレクトリに内に最初から build ディレクトリが用意されているので、自前で mkdir build というようにビルドディレクトリを用意しなくても良い。make install すると、バイナリとライブラリが CMAKE_INSTALL_PREFIX で指定されたディレクトリにインストールされるが、システムの方 (/lib/systemd/system/) にも fluent-bit.service というファイルをインストールしようとする。sudo make install とすれば成功しそうだが、NestDAQ の利用を考えると、ユーザーアカウントで済ませたい。とりあえず、/home/nestdaq/nestdaq/bin/fluent-bit というバイナリだけでも使えているので、make install 時のErrorは無視しておく。そのうち、バイナリとライブラリだけをインストールするオプションやらやり方を見つけたい。cmake のオプションをちらっと見てみたが、なんかできなかった。-DFLB_IN_SYSTEMD=off とかやってみたが効果なし。その後、fluent-bit を試しに起動してみる。\$HOME/nestdaq/bin にはパスが通っているはずなので、単に fluent-bit というコマンドを打てば実行できるはず。
$ fluent-bit Fluent Bit v3.0.0 * Copyright (C) 2015-2024 The Fluent Bit Authors * Fluent Bit is a CNCF sub-project under the umbrella of Fluentd * https://fluentbit.io ____________________ < Fluent Bit v2.2.2 > ------------------- \ \ \ __---__ _- /--______ __--( / \ )XXXXXXXXXXX\v. .-XXX( O O )XXXXXXXXXXXXXXX- /XXX( U ) XXXXXXX\ /XXXXX( )--_ XXXXXXXXXXX\ /XXXXX/ ( O ) XXXXXX \XXXXX\ XXXXX/ / XXXXXX \__ \XXXXX XXXXXX__/ XXXXXX \__----> ---___ XXX__/ XXXXXX \__ / \- --__/ ___/\ XXXXXX / ___--/= \-\ ___/ XXXXXX '--- XXXXXX \-\/XXX\ XXXXXX /XXXXX \XXXXXXXXX \ /XXXXX/ \XXXXXX > _/XXXXX/ \XXXXX--__/ __-- XXXX/ -XXXXXXXX--------------- XXXXXX- \XXXXXXXXXXXXXXXXXXXXXXXXXX/ ""VXXXXXXXXXXXXXXXXXXV"" [2024/01/19 14:32:47] [ info] [fluent bit] version=3.0.0, commit=71746b3571, pid=1340185 [2024/01/19 14:32:47] [ info] [storage] ver=1.5.1, type=memory, sync=normal, checksum=off, max_chunks_up=128 [2024/01/19 14:32:47] [ info] [cmetrics] version=0.6.6 [2024/01/19 14:32:47] [ info] [ctraces ] version=0.4.0 [2024/01/19 14:32:47] [ info] [sp] stream processor started
ロゴの中のバージョンが v2.2.2 と書いてあるのが気になるが、間違いな気がする。Crtl-c で終了。fluent-bit –version とすると、以下のように表示される。
$ fluent-bit --version Fluent Bit v3.0.0 Git commit: 71746b35718e856a5f8615f95f35d450a142e8cd
Troubleshooting
- Flex と Bison がないと cmake 時、以下のエラーになる。
$ cmake -DCMAKE_INSTALL_PREFIX=$HOME/nestdaq \ -B ./build -S . -- The C compiler identification is GNU 11.4.0 < Omitted > -- Found Git: /usr/bin/git (found version "2.34.1") -- Git hash: 71746b35718e856a5f8615f95f35d450a142e8cd -- Could NOT find FLEX (missing: FLEX_EXECUTABLE) (Required is at least version "2") -- Could NOT find BISON (missing: BISON_EXECUTABLE) (Required is at least version "3") -- Enabling FLB_REGEX since FLB_PARSER requires CMake Error at CMakeLists.txt:472 (message): Record Accessor feature requires Flex and Bison in your system. This is a build time dependency, you can either install the dependencies or disable the feature setting the CMake option -DFLB_RECORD_ACCESSOR=Off . -- Configuring incomplete, errors occurred! See also "/home/nestdaq/nestdaq/src/fluent-bit/build/CMakeFiles/CMakeOutput.log".
- cmake時の謎のエラーメッセージ。libyaml-dev をインストールすれば良いかと思ったが、それだけではだめで、pkg-config パッケージもインストールすべし。
$ cmake -DCMAKE_INSTALL_PREFIX=$HOME/nestdaq -B ./build -S . -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) <Omitted> -- CFL found in the system. OK Found posix_memalign in stdlib.h -DHAVE_POSIX_MEMALIGN_IN_STDLIB -DHAVE_POSIX_MEMALIGN -- Plugin dirlisting enabled -- Plugin liana enabled [== static ==] -- Plugin mandril enabled -- LINKING monkey-liana-static; -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR) -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) CMake Error at CMakeLists.txt:856 (message): YAML development dependencies required for YAML configuration format handling. This is a build time dependency, you can either install the dependencies or disable the feature setting the CMake option -DFLB_CONFIG_YAML=Off . -- Configuring incomplete, errors occurred! See also "/home/nestdaq/nestdaq/src/fluent-bit/build/CMakeFiles/CMakeOutput.log". See also "/home/nestdaq/nestdaq/src/fluent-bit/build/CMakeFiles/CMakeError.log".
libyaml-dev, lib pkg-config をインストール。cmake のエラーが解消せず、おそらく必要なかったが、python3-yaml, libyaml-cpp-dev パッケージもインストールした。
$ sudo apt install libyaml-dev python3-yaml libyaml-cpp-dev pkg-config
- make 時エラーメッセージ。openssl のヘッダーが見つからない make 時エラーはなんか知らないけどよく見る。cmake は通るのに、make 時にエラーなるのはなんでだろう。CERN ROOT v5 をコンパイルするときも見た気がする。
$ make <Omitted> [ 47%] Building C object src/CMakeFiles/fluent-bit-static.dir/flb_hmac.c.o In file included from /home/nestdaq/nestdaq/src/fluent-bit/src/flb_hmac.c:18: /home/nestdaq/nestdaq/src/fluent-bit/include/fluent-bit/flb_hmac.h:22:10: fatal error: openssl/err.h: No such file or directory 22 | #include <openssl/err.h> | ^~~~~~~~~~~~~~~ compilation terminated. make[2]: *** [src/CMakeFiles/fluent-bit-static.dir/build.make:790: src/CMakeFiles/fluent-bit-static.dir/flb_hmac.c.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:7698: src/CMakeFiles/fluent-bit-static.dir/all] Error 2 make: *** [Makefile:156: all] Error 2
apt search ssl として、openssl/err.h のヘッダーが含まれていそうなパッケージを探す。
$ apt search ssl <Omitted> libssl-dev/jammy-updates,jammy-security 3.0.2-0ubuntu1.12 amd64 Secure Sockets Layer toolkit - development files <Omitted>
経験的に、libssl-dev をインストールすると、openssl/err.h が入りそうな予感がする。あと、apt-file コマンドがインストールされていれば、もっと直接的に openssl/err.h ヘッダーが含まれるパッケージを以下のように探せる。
$ apt-file search openssl/err.h android-libboringssl-dev: /usr/include/android/openssl/err.h libnode-dev: /usr/include/node/openssl/err.h libssl-dev: /usr/include/openssl/err.h libwolfssl-dev: /usr/include/cyassl/openssl/err.h libwolfssl-dev: /usr/include/wolfssl/openssl/err.h python3-pycparser: /usr/share/python3-pycparser/fake_libc_include/openssl/err.h
この結果からどれをインストールすれば良いか判断する必要があるが、通常コンパイルするときにデフォルトで(?)指定される include ディレクトリは /usr/include なので、このディレクトリ直下にある openssl/err.h がインストールされれば良い。そのため、パッケージ libssl-dev をインストールすれば良いことがわかる。以下のコマンドでインストール可能。
$ sudo apt install libssl-dev
- make 時に以下のエラーがでる。
[ 98%] Building C object src/CMakeFiles/fluent-bit-bin.dir/__/lib/lwrb/lwrb/src/lwrb/lwrb.c.o [ 98%] Linking C executable ../bin/fluent-bit /usr/bin/ld: ../library/libfluent-bit.a(flb_tls.c.o): in function `tls_info_callback': /home/nestdaq/nestdaq/src/fluent-bit/src/tls/openssl.c:75: undefined reference to `SSL_get_fd' /usr/bin/ld: /home/nestdaq/nestdaq/src/fluent-bit/src/tls/openssl.c:88: undefined reference to `SSL_state_string_long' /usr/bin/ld: /home/nestdaq/nestdaq/src/fluent-bit/src/tls/openssl.c:93: undefined reference to `SSL_alert_desc_string_long' /usr/bin/ld: /home/nestdaq/nestdaq/src/fluent-bit/src/tls/openssl.c:93: undefined reference to `SSL_alert_type_string_long' /usr/bin/ld: /home/nestdaq/nestdaq/src/fluent-bit/src/tls/openssl.c:100: undefined reference to `SSL_state_string_long' /usr/bin/ld: /home/nestdaq/nestdaq/src/fluent-bit/src/tls/openssl.c:104: undefined reference to `SSL_get_error' /usr/bin/ld: /home/nestdaq/nestdaq/src/fluent-bit/src/tls/openssl.c:112: undefined reference to `SSL_state_string_long' /usr/bin/ld: ../library/libfluent-bit.a(flb_tls.c.o): in function `tls_context_destroy': /home/nestdaq/nestdaq/src/fluent-bit/src/tls/openssl.c:124: undefined reference to `SSL_CTX_free' /usr/bin/ld: ../library/libfluent-bit.a(flb_tls.c.o): in function `load_system_certificates': /home/nestdaq/nestdaq/src/fluent-bit/src/tls/openssl.c:192: undefined reference to `SSL_CTX_load_verify_locations' /usr/bin/ld: /home/nestdaq/nestdaq/src/fluent-bit/src/tls/openssl.c:195: undefined reference to `ERR_print_errors_fp' /usr/bin/ld: ../library/libfluent-bit.a(flb_tls.c.o): in function `tls_context_create': /home/nestdaq/nestdaq/src/fluent-bit/src/tls/openssl.c:239: undefined reference to `TLS_server_method' /usr/bin/ld: /home/nestdaq/nestdaq/src/fluent-bit/src/tls/openssl.c:239: undefined reference to `SSL_CTX_new' < Omitted > /usr/bin/ld: /home/nestdaq/nestdaq/src/fluent-bit/src/flb_crypto.c:264: undefined reference to `ERR_get_error' collect2: error: ld returned 1 exit status make[2]: *** [src/CMakeFiles/fluent-bit-bin.dir/build.make:403: bin/fluent-bit] Error 1 make[1]: *** [CMakeFiles/Makefile2:7757: src/CMakeFiles/fluent-bit-bin.dir/all] Error 2 make: *** [Makefile:156: all] Error 2
apt search tls で検索すると、libtls-dev というパッケージがヒットする。これをインストールすれば良さそうな感じがする。
$ sudo apt install libtls-dev < Omitted > libtls-dev/jammy 3.4.1-2build1 amd64 libtls development files < Omitted >
このパッケージをインストールしてみる。
$ sudo apt install libtls-dev
そのあと、make したが、同じエラーがでる。他にも、libssl3, libtlsh-dev, libcrypto++-dev, libtls-dev などインストールしたがだめ。どうしたものか。。。参照しているディレクトリがだめなのかと考え直し、cmake を行ってから、もう一度 make してみると make が通った。
- make install 時のエラー。sudo をつけずユーザー権限で make install を行うと、エラーになる。サービス起動用の /lib/systemd/system/fluent-bit.service というファイルをコピーしようとしてエラーになる。
$ make install ... -- Installing: /home/nestdaq/nestdaq/lib/fluent-bit/libfluent-bit.so -- Installing: /home/nestdaq/nestdaq/bin/fluent-bit -- Installing: /lib/systemd/system/fluent-bit.service CMake Error at src/cmake_install.cmake:97 (file): file INSTALL cannot copy file "/home/nestdaq/nestdaq/src/fluent-bit/init/fluent-bit.service" to "/lib/systemd/system/fluent-bit.service": Permission denied. Call Stack (most recent call first): cmake_install.cmake:54 (include) make: *** [Makefile:120: install] Error 1
sudo make install とすれば成功しそうだが、NestDAQ の利用を考えると、ユーザーアカウントで済ませたい。とりあえず、/home/nestdaq/nestdaq/bin/fluent-bit というバイナリだけでも使えているので、このErrorは無視。そのうち、バイナリとライブラリだけをインストールするオプションやらやり方を見つけたい。cmake のオプションをちらっと見てみたが、なんかできなかった。-DFLB_IN_SYSTEMD=off とかやってみたが効果なし。