关于文章 rocksdb

java leveldb linux nosql rocksdb

leveldb-rocksdb java使用

rocksdb是在leveldb上开发来的

leveldb-rocksdb在java中的demo

(arangodb储存引擎用的rocksdb,然而rocksdb是在leveldb上开发来的)

rocksdb

package net.oschina.itags.gateway.service;
import org.rocksdb.Options;
import org.rocksdb.RocksDB;
import org.rocksdb.RocksDBException;

public class BaseRocksDb {
    public final static RocksDB rocksDB() throws RocksDBException {

        Options options = new Options().setCreateIfMissing(true);
        RocksDB.loadLibrary();
        RocksDB db=RocksDB.open(options,"./rock");
        return db;
    }
}

leveldb

package net.oschina.itags.gateway.service;
import org.iq80.leveldb.*;
import org.iq80.leveldb.impl.Iq80DBFactory;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;

public class BaseLevelDb {

public static final DB db() throws IOException {
    boolean cleanup = true;
    Charset charset = Charset.forName("utf-8");
    String path = "./level";

//init
    DBFactory factory = Iq80DBFactory.factory;
    File dir = new File(path);
//如果数据不需要reload则每次重启尝试清理磁盘中path下的旧数据
    if(cleanup) {
        factory.destroy(dir,null);//清除文件夹内的所有文件
    }
    Options options = new Options().createIfMissing(true);
//重新open新的db
    DB db = factory.open(dir,options);
  return db;
}
}
linux mysql nosql rocksdb

myrocks编译

myrocks编译

先准备编译环境(其实gayhub上都有wiki可是就是英文的。。)

deb系的系统

sudo apt-get update
sudo apt-get -y install g++ cmake libbz2-dev libaio-dev bison \
zlib1g-dev libsnappy-dev libboost-all-dev
sudo apt-get -y install libgflags-dev libreadline6-dev libncurses5-dev \
libssl-dev liblz4-dev gdb git

rpm系的系统

sudo yum install cmake gcc-c++ bzip2-devel libaio-devel bison \
zlib-devel snappy-devel boost-devel
sudo yum install gflags-devel readline-devel ncurses-devel \
openssl-devel lz4-devel gdb git

简单粗暴的下载和编译过程

git clone https://github.com/facebook/mysql-5.6.git
cd mysql-5.6
git submodule init
git submodule update
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SSL=system \
-DWITH_ZLIB=bundled -DMYSQL_MAINTAINER_MODE=0 -DENABLED_LOCAL_INFILE=1 \
-DENABLE_DTRACE=0 -DCMAKE_CXX_FLAGS="-march=native"
make -j8

make package

。=。不出意外的话 轻松写意的就编译完了。。。但是出了一大堆意外。。。随后我会放出已编译好的包