首页 > 其他分享 >RocksDB and Zenfs Install and emulated by null_blk

RocksDB and Zenfs Install and emulated by null_blk

时间:2022-08-22 09:24:12浏览次数:95  
标签:status emulated RocksDB rocksdb db value Install zenfs sudo

RocksDB

GithubRepo

https://github.com/facebook/rocksdb

InstallGuide

https://github.com/facebook/rocksdb/blob/main/INSTALL.md

then execute

make shared_lib && sudo make install-shared

test code


#include <cstdio>
#include <string>

#include "rocksdb/db.h"
#include "rocksdb/slice.h"
#include "rocksdb/options.h"

using namespace std;
using namespace rocksdb;

const std::string PATH = "/home/parallels/Desktop/rocksdb"; //rocksDB的数据存储目录绝对路径

int main(){
    DB* db;
    Options options;
    options.create_if_missing = true;
    Status status = DB::Open(options, PATH, &db);
    assert(status.ok());
    Slice key("test01");
    Slice value("success");

    std::string get_value;
    status = db->Put(WriteOptions(), key, value);
    if(status.ok()){
        status = db->Get(ReadOptions(), key, &get_value);
        if(status.ok()){
            printf("value is %s\n", get_value.c_str());
        }else{
            printf("get failed\n");
        }
    }else{
        printf("put failed\n");
    }

    delete db;
}

compile command

g++ -std=c++17 -o test test.cpp  -lrocksdb  -lpthread

success if print is "value is success"

ZenFS

git clone https://github.com/facebook/rocksdb.git
cd rocksdb
git clone https://github.com/westerndigitalcorporation/zenfs plugin/zenfs
sudo DEBUG_LEVEL=0 ROCKSDB_PLUGINS=zenfs make db_bench install//如果报错的话把libgflags删掉(sudo apt remove libgflags-dev)试试
cd plugin/zenfs/util
make
//报错的话把gflags改为google

1. 创建ZenFs File System

sudo ./plugin/zenfs/util/zenfs mkfs --zbd=nullb0 --aux_path=/home/parallels/Desktop/zenfs/log

>ZenFS file system created. Free space: 255232 MB

2. 设置IO Scheduler deadline

sudo echo deadline > sudo /sys/class/block/nullb0/queue/scheduler

3. use db_bench to benchmark

sudo ./db_bench --fs_uri=zenfs://dev:nullb0 --benchmarks=fillrandom --use_direct_io_for_flush_and_compaction

null_blk

 sudo modprobe null_blk nr_devices=1 zoned=1 //创建null_blk
 sudo blkzone report /dev/nullb0  //查看zone信息

标签:status,emulated,RocksDB,rocksdb,db,value,Install,zenfs,sudo
From: https://www.cnblogs.com/attack204/p/16611672.html

相关文章