SSDB 数据库使用的是 Google 的 leveldb 作为存储引擎, Facebook 基于 leveldb 改造的 rocksdb 据说在某些场景中更好, 所以, 有不少朋友考虑把 SSDB 中的 leveldb 引擎换成 rocksdb. 这是可以的, 而且改动比较小.
1. 首先, 你需要修改 build.sh 文件, 修改
LEVELDB_PATH="$BASE_DIR/deps/leveldb-1.14.0"
指向 rocksdb 的目录.
2. 然后修改 src/include.h 文件, 增加
#define leveldb rocksdb
3. 注释掉 Makefile 文件中的这一行
# chmod u+x "${LEVELDB_PATH}/build_detect_platform"
然后就可以编译了. 不过, 你需要注意的是, 虽然 rocksdb 是基于 leveldb 改造的, 但两者的数据文件格式不兼容, 不知道 Facebook 为什么要做这样的决定, 这确实不好. 这也是 SSDB 为什么不同时支持两个引擎的原因.
可以简单的重命名,将ldb改为sst,就可以使用rocksdb启动了。 Reply
/opt/ssdb-rocks-master/deps/rocksdb-master/librocksdb.a(block_based_table_builder.o): In function `Snappy_Compress':
/opt/ssdb-rocks-master/deps/rocksdb-master/./port/port_posix.h:156: undefined reference to `snappy::MaxCompressedLength(unsigned long)’
/opt/ssdb-rocks-master/deps/rocksdb-master/./port/port_posix.h:158: undefined reference to `snappy::RawCompress(char const*, unsigned long, char*, unsigned long*)’
collect2: error: ld returned 1 exit status
源码里我未找到snappy。另外,gcc版本是4.7.2
请问如何修改,谢谢! Reply
更新后编译:
/opt/centos/devtoolset-1.1/root/usr/bin/c++ -o ../ssdb-server ssdb-server.o ssdb.o t_kv.o t_hash.o t_zset.o t_queue.o link.o backend_dump.o backend_sync.o slave.o binlog.o serv.o iterator.o ttl.o util/log.o util/fde.o util/config.o util/bytes.o util/sorted_set.o -pthread -lbz2 -lz "/opt/ssdb-rocks-master/deps/rocksdb-master/librocksdb.a" "/opt/ssdb-rocks-master/deps/snappy-1.1.0/.libs/libsnappy.a" "/opt/ssdb-rocks-master/deps/jemalloc-3.3.1/lib/libjemalloc.a"
/opt/ssdb-rocks-master/deps/rocksdb-master/librocksdb.a(env_posix.o): In function `rocksdb::(anonymous namespace)::PosixEnv::NowNanos()':
/opt/ssdb-rocks-master/deps/rocksdb-master/util/env_posix.cc:1342: undefined reference to `clock_gettime’
collect2: error: ld returned 1 exit status
请问如何修改,谢谢! Reply
g++ -o ../ssdb-server ssdb-server.o ssdb.o t_kv.o t_hash.o t_zset.o link.o backend_dump.o backend_sync.o slave.o binlog.o serv.o iterator.o util/log.o util/fde.o util/config.o util/bytes.o -pthread "/opt/ssdb-rocks-master/deps/rocksdb-master/librocksdb.a" "/opt/ssdb-rocks-master/deps/jemalloc-3.3.1/lib/libjemalloc.a" -lz -lbz2
/opt/ssdb-rocks-master/deps/rocksdb-master/librocksdb.a(env_posix.o): In function `rocksdb::(anonymous namespace)::PosixEnv::NowNanos()':
/opt/ssdb-rocks-master/deps/rocksdb-master/util/env_posix.cc:1342: undefined reference to `clock_gettime’
/opt/ssdb-rocks-master/deps/rocksdb-master/librocksdb.a(format.o): In function `Snappy_GetUncompressedLength':
/opt/ssdb-rocks-master/deps/rocksdb-master/./port/port_posix.h:169: undefined reference to `snappy::GetUncompressedLength(char const*, unsigned long, unsigned long*)’
/opt/ssdb-rocks-master/deps/rocksdb-master/librocksdb.a(format.o): In function `Snappy_Uncompress':
/opt/ssdb-rocks-master/deps/rocksdb-master/./port/port_posix.h:178: undefined reference to `snappy::RawUncompress(char const*, unsigned long, char*)’
/opt/ssdb-rocks-master/deps/rocksdb-master/librocksdb.a(block_based_table_builder.o): In function `Snappy_Compress':
/opt/ssdb-rocks-master/deps/rocksdb-master/./port/port_posix.h:156: undefined reference to `snappy::MaxCompressedLength(unsigned long)’
/opt/ssdb-rocks-master/deps/rocksdb-master/./port/port_posix.h:158: undefined reference to `snappy::RawCompress(char const*, unsigned long, char*, unsigned long*)’
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
请问什么原因?谢谢! Reply