Skip to content

Compile From Source

rockeet edited this page Aug 23, 2018 · 25 revisions

Compile from Source

Clone dependent repositories

  • Must use our fork of RocksDB
# install compression libraries (zlib, bzip2, snappy):
sudo apt-get install zlib1g-dev libbz2-dev libsnappy-dev
git clone https://github.com/Terark/terarkmongo.git
cd terarkmongo
git submodule init
git submodule update --recursive

Compile RocksDB

  • Better shared_lib, if static_lib, need -fPIC
cd terarkmongo/rocksdb
make shared_lib DEBUG_LEVEL=0

Download Dependencies

Download dependencies package and unzip it to /path/to/terark-zip-rocksdb

Compile MongoDB with mongo-rocks

cd mongo-on-terark
mkdir -p /path/to/mongo/src/mongo/db/modules/
ln -sf $PWD/mongo-rocks mongo/src/mongo/db/modules/rocks

ROCKSDB_INC=$PWD/rocksdb/include
ROCKSDB_LIB=$PWD/rocksdb

cd mongo

scons \
  "CPPPATH=$ROCKSDB_INC" \
  "LIBPATH=$ROCKSDB_LIB" \
  --disable-warnings-as-errors mongod -j8 -Q VERBOSE=1

export LD_LIBRARY_PATH=/path/to/rocksdb:$LD_LIBRARY_PATH # for librocksdb.so
export LD_LIBRARY_PATH=/path/to/terark-zip-rocksdb/lib:$LD_LIBRARY_PATH

env LD_PRELOAD=libterark-zip-rocksdb-r.so \
	./mongod --storageEngine rocksdb

Compile MongoDB client

In directory /path/to/mongo, run

scons \
  "CPPPATH=$ROCKSDB_INC" \
  "LIBPATH=$ROCKSDB_LIB" \
  --disable-warnings-as-errors mongo -j8 -Q VERBOSE=1

to build MongoDB client

Check whether TerarkDB works

1. Run MongoDB client

In another terminal, execute mongo shell:

cd /path/to/mongo
./mongo

2. Check whether TerarkDB is in using

In mongo shell, execute:

db.serverStatus().rocksdb["table-name"]

If it returns TerarkZipTable, it means TerarkDB is in using.

3. More details

You can view more info about TerarkDB, execute:

db.serverStatus().rocksdb["table-options"]