近期需要为异构引擎做准备, wiredtiger 以其优异的性能(B-tree和LSM-tree都支持)和稳定性(Mongodb的默认存储引擎) 被我们备选为异构引擎里的一个子引擎,后续将深入wiredtiger 引擎原理。这里简单记录一下Wiredtiger 存储引擎的编译记录。
Environment
CPU:Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz 56core
内存: 256G
操作系统:CentOS Linux release 7.4.1708 (Core)
文件系统:XFS
CC: gcc-5.3/bin/gcc
CXX: gcc-5.3/bin/g++
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/gcc-5.3/lib64
编译
- 获取源码
git clone https://github.com/wiredtiger/wiredtiger.git
我使用的是mongodb-4.4版本的引擎:
git checkout mongodb-4.4
- 生成编译配置
mkdir build
./configure --prefix=/home/zhg/wiredtiger/build
这里可以通过prefix指定编译后的成果物路径,需要指定绝对路径;如果这里不指定的话就会默认放在/usr/local
里面。
当然wiredtiger的configure还有更多的配置,如下,一般不需要指定:
–enable-attach
Configure WiredTiger to sleep and wait for a debugger to attach on failure. DO NOT configure this option in production environments.
–enable-diagnostic
Configure WiredTiger to perform various run-time diagnostic tests. DO NOT configure this option in production environments.
–enable-java
Build the WiredTiger Java API; requires SWIG and Java JDK.
–enable-lz4
Configure WiredTiger for LZ4 compression; see Compressors for more information.
–enable-python
Build the WiredTiger Python API; requires SWIG.
–enable-snappy
Configure WiredTiger for snappy compression; see Compressors for more information.
–enable-zlib
Configure WiredTiger for zlib compression; see Compressors for more information.
–enable-zstd
Configure WiredTiger for Zstd compression; see Compressors for more information.
这一步如果执行失败,并且报出如下错误:
./configure: line 4619: syntax error near unexpected token `2.2.6'
./configure: line 4619: `LT_PREREQ(2.2.6)'
说明当前系统libtool
工具版本比较低,wiredtiger通过configure安装过程中需要借用libtool生成一些后续make 需要的makefile配置文件(gcc/g++/lib64 等相关的binary和库的信息更新)。
通过安装更高版本的libtool即可解决:
sudo yum install libtool -y # centos7.4 默认会安装2.4.2版本
autoreconf -i # 更新新版本libtool 生成的对应版本的conf
- 编译和安装
make -j && make install
最后编译成功可以在build目录下看到如下内容:
$ tree
.
├── bin
│ └── wt # wiredtiger的binary文件,类似于rocksdb的ldb命令,可以单独创建wiredtiger的db目录
├── include
│ ├── wiredtiger_ext.h
│ └── wiredtiger.h
└── lib # wiredtiger的静态库和动态库
├── libwiredtiger-10.0.0.so
├── libwiredtiger.a
├── libwiredtiger.la
├── libwiredtiger.so -> libwiredtiger-10.0.0.so
└── pkgconfig
└── wiredtiger.pc