もしかしたらほとんど需要はないかもしれませんが備忘録として。
昨年の夏、下記の記事をUpしました。
この記事はLogstashを使ってPaloaltoのログをManticoreSearchのIndexとして登録+それを自前のAPIでブラウザ上に表示させるところまでの記事となります。
OpensearchやElasticsearchであれば当たり前のように実装されている文字列・数値の判定がこの時はまだ正しく実装されておらず、やむなくログ自体をすべて文字列にしてLogstashに読み込ませて処理していました。
実は現在(2024/8/11)でもこの仕様は改善されていないようだったので、自分で改修してテストしようおもいましたが、ubuntu22.04を使用したビルドは依存関係が原因で難航。これは骨が折れるかと思いきや、よくよく確認するとビルド環境がご丁寧に準備されていたというオチ。(ちゃんと最初に調べるべきですね。)
という事で、その内容について記載となります。
前提(Docker環境が必要です)
OS:CentOS7.9
Docker: 23.0.1, build a5ee5b1
docker-compose: 1.28.2, build 67630359
1. 事前準備
まずはgitからcloneし、ディレクトリを移動しておきます。
git clone https://github.com/manticoresoftware/manticoresearch.git
cd manticoresearch/dist/build_dockers/cross/external_toolchain/
次に、buildてimageを作成します。
docker build .
[root@docker001 tmp]# docker images | head -n 2 # IMAGE ID をメモする
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> fb58f1dc27f9 9 hours ago 1.49GB
では、コンテナを起動しましょう。ディレクトリをmanticoresearchに移動してdocker runで起動します。
cd ../../../..
docker run -it --rm -v $(pwd):/manticore -e DISTR=bullseye -e arch=x86_64 -e SYSROOT_URL=https://repo.manticoresearch.com/repository/sysroots -e boosboost=boost_nov22 -e sysroot=roots_nov22 fb58f1dc27f9 bash
コンテナ起動時のログ
Arch is x86_64
Distr is bullseye
Sysroot URL is https://repo.manticoresearch.com/repository/sysroots (configured most probably in gitlab variable)
Will use Boost from dir boost_178 on the server; may be set to 'none', or other value with boost=XYZ clause
Will use sysroot from dir roots_nov22 on the server; may be set to other value with sysroot=XYZ clause
Fetching and unpacking boost headers...
Fetching and unpacking boost libraries...
Fetching and unpacking sysroot...
Preparing boost and sysroot done
2. コンパイル
ではSourceファイルを変更後、以下のコマンドでbuildしていきます。
cd /manticore/
mkdir build
cd build
cmake -DPACK=1 ..
-- The C compiler identification is Clang 16.0.6
-- The CXX compiler identification is Clang 16.0.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib/llvm-16/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib/llvm-16/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Automatically set build type to RelWithDebInfo since no other provided
# ~~~~省略~~~~ #
-- Enabled features compiled in:
* Galera, replication of indexes
* re2, a regular expression library
* stemmer, stemming library (Snowball)
* nlohmann_json, JSON for Modern C++ library
* uni-algo, unicode algorithm implementation for C/C++
* icu, International Components for Unicode
* OpenSSL, for encrypted networking
* ZLIB, for compressed data and networking
* ZSTD, for compressed networking, <https://github.com/facebook/zstd>
* CURL, for enhanced network communication
* ODBC, for indexing MSSQL (windows) and generic ODBC sources with indexer
* EXPAT, for indexing xmlpipe sources with indexer
* Iconv, for support different encodings when indexing xmlpipe sources with indexer
* Mysql, for indexing mysql sources with indexer
* PostgreSQL, for indexing postgresql sources with indexer
-- Available runtime features:
* ZSTD, for compressed networking, <https://github.com/facebook/zstd>
-- Configuring done (106.4s)
-- Generating done (0.0s)
-- Build files have been written to: /manticore/build
ではインストール用パッケージを作成します。
cmake --build . --target package
[1/279] Building CXX object src/CMakeFiles/lmanticore_coro.dir/coro_stack.cpp.o
# ~~~~省略~~~~ #
[278/279] Run CPack packaging tool...
-- CHECK_GIT_COMMIT_ID=4bd6b3b52
CPack: Create package using DEB
CPack: Install projects
CPack: - Install project: MANTICORE []
CPack: - Install component: common
CPack: - Install component: converter
CPack: - Install component: devel
CPack: - Install component: icudata
CPack: - Install component: searchd
CPack: - Install component: server
CPack: - Install component: tools
CPack: - Install component: meta
CPack: Create package
-- CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.
-- CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.
-- CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.
CPack: - package: /manticore/build/manticore-common_6.3.7-24081018-4bd6b3b52_all.deb generated.
CPack: - package: /manticore/build/manticore-converter_6.3.7-24081018-4bd6b3b52_amd64.deb generated.
CPack: - package: /manticore/build/manticore-converter-dbgsym_6.3.7-24081018-4bd6b3b52_amd64.ddeb generated.
CPack: - package: /manticore/build/manticore-dev_6.3.7-24081018-4bd6b3b52_all.deb generated.
CPack: - package: /manticore/build/manticore-icudata-65l.deb generated.
CPack: - package: /manticore/build/manticore_6.3.7-24081018-4bd6b3b52_amd64.deb generated.
CPack: - package: /manticore/build/manticore-server-core_6.3.7-24081018-4bd6b3b52_amd64.deb generated.
CPack: - package: /manticore/build/manticore-server-core-dbgsym_6.3.7-24081018-4bd6b3b52_amd64.ddeb generated.
CPack: - package: /manticore/build/manticore-server_6.3.7-24081018-4bd6b3b52_amd64.deb generated.
CPack: - package: /manticore/build/manticore-tools_6.3.7-24081018-4bd6b3b52_amd64.deb generated.
CPack: - package: /manticore/build/manticore-tools-dbgsym_6.3.7-24081018-4bd6b3b52_amd64.ddeb generated.
# 確認
root@d0423f5890ec:/manticore/build [llvm-16 bullseye x86_64]$ ls *.deb
manticore-common_6.3.7-24081018-4bd6b3b52_all.deb manticore-server-core_6.3.7-24081018-4bd6b3b52_amd64.deb
manticore-converter_6.3.7-24081018-4bd6b3b52_amd64.deb manticore-server_6.3.7-24081018-4bd6b3b52_amd64.deb
manticore-dev_6.3.7-24081018-4bd6b3b52_all.deb manticore-tools_6.3.7-24081018-4bd6b3b52_amd64.deb
manticore-icudata-65l.deb manticore_6.3.7-24081018-4bd6b3b52_amd64.deb
正しくpackageが作成されました!
3. その他
manticoresearchのビルドという意味では需要はそこまでないかもしれませんが、ほかOSSでも似たようなものはあるかもしれません。この記事が誰かの役に立てば幸いです。