首页 > 数据库技术 > 详细

RocksDB安装与使用

时间:2021-07-22 10:57:15      阅读:15      评论:0      收藏:0      [点我收藏+]

安装

系统为:Ubuntu18.04

Dependencies:

sudo apt-get install libgflags-dev 		     libsnappy-dev 		     zlib1g-dev 	             libbz2-dev 	             liblz4-dev 		     libzstd-dev

参考文档

使用

create_db.cpp

#include <assert.h>
#include "rocksdb/db.h"
int main()
{
  rocksdb::DB* db;
  rocksdb::Options options;
  options.create_if_missing = true;
  rocksdb::Status status = rocksdb::DB::Open(options, "/home/ubuntu/rocksdb_test/testdb", &db);
  assert(status.ok());
  return 0;
}

CMakeLists.txt

# Passed
# PROJECT(CREATEDB)
# LINK_LIBRARIES("/home/ubuntu/3rd/rocksdb/librocksdb.a")
# INCLUDE_DIRECTORIES(/home/ubuntu/3rd/rocksdb/include)

# find_library(LZ4_LIB lz4)
# message(STATUS "finding ${LZ4_LIB}")

# ADD_EXECUTABLE(create_db create_db.cpp)
# TARGET_LINK_LIBRARIES(create_db ${LZ4_LIB} -lpthread -lsnappy -lz -lbz2 -lzstd -ldl)

PROJECT(CREATEDB)
LINK_LIBRARIES("/home/ubuntu/3rd/rocksdb/librocksdb.a")
INCLUDE_DIRECTORIES(/home/ubuntu/3rd/rocksdb/include)

ADD_EXECUTABLE(create_db create_db.cpp)
TARGET_LINK_LIBRARIES(create_db z4 pthread snappy z bz2 zstd dl)

运行create_db创建数据库

(base) ubuntu@VM-8-7-ubuntu:~/rocksdb_test$ tree  testdb/
testdb/
├── 000005.log
├── CURRENT
├── IDENTITY
├── LOCK
├── LOG
├── MANIFEST-000004
└── OPTIONS-000007

0 directories, 7 files

RocksDB安装与使用

原文:https://www.cnblogs.com/ctrlplayer/p/15042268.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!