Oracle ACE

StoneDB

三天三夜的三更半夜! StoneDB on Rocky 9

stonedb-logo.gif

TL;DR

之前体验过如何安装 StoneDB,并发文演示了几个新特性。关于什么是 StoneDB,请先参阅前文。

本文记录了这几天在 Rocky Linux 9.2 上编译安装 StoneDB 5.7 最新源码的“扎心”经历。
对 StoneDB、MySQL、RocksDB 或 Rocky 9 感兴趣的同学请继续往下阅读。

环境信息

操作系统为 Rocky Linux 9.2,编译过程中没有出现特别消耗资源的情况,这点不错,我的 VM 是 2c4g,可以编译成功。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[shawnyan@rocky9 ~]$ cat /etc/redhat-release
Rocky Linux release 9.2 (Blue Onyx)
[shawnyan@rocky9 ~]$ uname -a
Linux rocky9.shawnyan.cn 5.14.0-284.30.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Sep 16 09:55:41 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
[shawnyan@rocky9 ~]$
[shawnyan@rocky9 ~]$ gcc --version
gcc (GCC) 11.3.1 20221121 (Red Hat 11.3.1-4)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[shawnyan@rocky9 ~]$ cmake --version
cmake version 3.20.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
[shawnyan@rocky9 ~]$ top
top - 15:28:57 up 12 days, 1:23, 2 users, load average: 0.01, 0.03, 0.00
Tasks: 272 total, 1 running, 271 sleeping, 0 stopped, 0 zombie
%Cpu0 : 0.0 us, 0.3 sy, 0.0 ni, 99.0 id, 0.0 wa, 0.3 hi, 0.3 si, 0.0 st
%Cpu1 : 0.0 us, 0.3 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 3623.0 total, 818.1 free, 947.4 used, 2131.4 buff/cache
MiB Swap: 4020.0 total, 3158.1 free, 861.9 used. 2675.6 avail Mem

查看 StoneDB 的安装路径和版本号

先上成果物,看看编译安装后的 StoneDB 目录下都有哪些文件。

img1-mysqld-version.png

安装路径是默认值,安装在了 /usr/local/mysql 目录下,查看版本号为 StoneDB-5.7.36

本地环境的 ntpd 没有同步,所以编译时间有点错乱,快了 8 小时。

创建 Tianmu 测试表

StoneDB 启动后,通过客户端进行连接,\s 查看状态,服务器版本看着有点“凌乱”,不用在意这种细节。

img2-mysql-version.png

查看默认数据库,与前文描述一致。创建一个测试库,并创建引擎为 TIANMU 的测试表,功能使用正常。

img3-tianmu-table.png

编译配置

相对于前文的丝滑安装,这里的编译过程极其痛苦,犹如工兵步步排雷,好在最终扛到军旗。

源码仓库

StoneDB 提供了 GitHub 和 Gitee 两个代码仓,只是并不同步,如果网路条件允许,还是从 GH 下载比较好。

官网地址解析

官网只能识别 https,无法识别 http,好在vx群里有好人帮忙确认官网状态正常,感谢。

img4-http-ngx.png

Rocksdb 下载链接

Tianmu 引擎依赖 Rocksdb,如果配置时没有指定包,则会自动下载,只是下载的版本有些“老舅”,且“门牌号”不对。

img5-git-rocksdb.png

RocksDB 6.12.6 发行于 2020-10-13,目前,最新版本为 RocksDB 8.6.7 发行于 09/26/2023。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-- Could not find (the correct version of) rocksdb.
-- MySQL currently requires vrocksdb-6.12.6

CMake Error at cmake/rocksdb.cmake:81 (MESSAGE):
You can download it with -DDOWNLOAD_ROCKSDB=1 -DWITH_ROCKSDB=<directory>

This CMake script will look for rocksdb in <directory>. If it is not
there, it will download and unpack it (in that directory) for you.

If you are inside a firewall, you may need to use an http proxy:

export http_proxy=http://example.com:80

Call Stack (most recent call first):
cmake/rocksdb.cmake:239 (COULD_NOT_FIND_ROCKSDB)
CMakeLists.txt:315 (INCLUDE)

下载 rocksdb 源码包后,配置正常。

1
2
3
4
5
6
-- Local rocksdb dir /data/stonedb-stonedb-5.7-dev/release/rocksdb-6.12.6
found ROCKSDB_INCLUDE_DIR:/data/stonedb-stonedb-5.7-dev/release/rocksdb-6.12.6
-- Found /data/stonedb-stonedb-5.7-dev/release/rocksdb-6.12.6/include/rocksdb/version.h
-- current ROCKSDB_VERSION_NUMBER is #define ROCKSDB_MAJOR 6.#define ROCKSDB_MINOR 12
-- current ROCKSDB_MAJOR_VERSION is: 6, ROCKSDB_MAJOR_VERSION:12
-- ROCKSDB_INCLUDE_DIR /data/stonedb-stonedb-5.7-dev/release/rocksdb-6.12.6

marisa-trie 下载链接

StoneDB 依赖“玛丽莎”,同上,需要提前下载源码包。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
found MARISA_INCLUDE_DIR:MARISA_INCLUDE_DIR-NOTFOUND
-- Looked for include/marisa.h in and
-- MARISA_INCLUDE_DIR MARISA_INCLUDE_DIR-NOTFOUND
-- LOCAL_MARISA_DIR
-- Could not find (the correct version of) marisa.
-- MySQL currently requires marisa-trie

CMake Error at cmake/marisa.cmake:59 (MESSAGE):
You can download it, install it, then specify the marisa path with
-DWITH_MARISA=<director>

This CMake script will look for marisa in <directory>.
Call Stack (most recent call first):
cmake/marisa.cmake:123 (COULD_NOT_FIND_MARISA)
CMakeLists.txt:323 (INCLUDE)

也可以编译时自动下载,只是这里还有个小包袱,git变成了gi。

img6-git-marisa.png

完整地址为:

https://github.com/s-yata/marisa-trie/archive/refs/tags/v0.2.6.tar.gz

boost 版本升级

StoneDB 5.7 依赖 boost 1.66.0,但编译时报错。

1
2
3
4
5
6
7
8
9
[shawnyan@rocky9 boost_1_66_0]$ ./bootstrap.sh
[shawnyan@rocky9 boost_1_66_0]$ ./b2

...failed gcc.compile.c++ bin.v2/libs/python/build/gcc-gnu-11/release/link-static/threadapi-pthread/threading-multi/converter/builtin_converters.o...
...skipped <pbin.v2/libs/python/build/gcc-gnu-11/release/link-static/threadapi-pthread/threading-multi>libboost_python3.a(clean) for lack of <pbin.v2/libs/python/build/gcc-gnu-11/release/link-static/threadapi-pthread/threading-multi>converter/builtin_converters.o...
...skipped <pbin.v2/libs/python/build/gcc-gnu-11/release/link-static/threadapi-pthread/threading-multi>libboost_python3.a for lack of <pbin.v2/libs/python/build/gcc-gnu-11/release/link-static/threadapi-pthread/threading-multi>converter/builtin_converters.o...
...skipped <pstage/lib>libboost_python3.a for lack of <pbin.v2/libs/python/build/gcc-gnu-11/release/link-static/threadapi-pthread/threading-multi>libboost_python3.a...
...failed updating 2 targets...
...skipped 6 targets...

所以,我就升级到了 boost 1.77.0,并修改了基础标识。

1
2
3
4
./cmake/boost.cmake:SET(BOOST_PACKAGE_NAME "boost_1_66_0")
./cmake/boost.cmake:SET(BOOST_PATCHES_DIR "${CMAKE_SOURCE_DIR}/include/boost_1_66_0/patches")
./cmake/boost.cmake:SET(BOOST_SOURCES_DIR "${CMAKE_SOURCE_DIR}/include/boost_1_66_0")
./codecov.yml:- "include/boost_1_66_0"

升级后,可以正常进行编译。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
...updated 1745 targets...


The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

/data/stonedb-stonedb-5.7-dev/release/boost_1_77_0

The following directory should be added to linker library paths:

/data/stonedb-stonedb-5.7-dev/release/boost_1_77_0/stage/lib

[shawnyan@rocky9 boost_1_77_0]$

openssl 1.1.1

Rocky 9 中通过 dnf 安装的 openssl 为 3.x 版本,版本太新,配置无法识别,而且和 1.1.1 系列代码差异很大,这里下载了 openssl 1.1.1 系列的最新版本 openssl-1.1.1w

1
2
3
4
5
6
7
8
9
10
11
12
13
Cannot find appropriate system libraries for WITH_SSL=system.
Make sure you have specified a supported SSL version.
Valid options are :
system (use the OS openssl library),
yes (synonym for system),
</path/to/custom/openssl/installation>

CMake Error at cmake/ssl.cmake:63 (MESSAGE):
Please install the appropriate openssl developer package.

Call Stack (most recent call first):
cmake/ssl.cmake:280 (FATAL_SSL_NOT_FOUND_ERROR)
CMakeLists.txt:630 (MYSQL_CHECK_SSL)

下载后,配置安装 openssl。

1
2
3
./config
make
make install