How to compile rocksdb with lz4 support
2016-09-20 18:21
253 查看
On CentOS 6.x or 7.x, you can do the following to easily install lz4 using the package manager.
As root (
First, enable EPEL, as @Etan Reisner suggested:
Then, to install lz4 binary:
And/or, to install the library:
And, you're done.
There is no document for how to compile rocksdb with lz4 support, I work on it for whole afternoon, failed.
Facebook member
igorcanadi commented on
4 Nov 2015
You just have to install it on your system -- our compile process detects this automatically:https://github.com/facebook/rocksdb/blob/master/build_tools/build_detect_platform#L263
前一段时间准备测试rocksdb,按照帖子和官网的例子,在安装过程中遇到一些问题。这里给出的是在Ubuntu下安装python使用的版本。
首先,要感谢这些帖子对我的帮助:
1:http://tech.uc.cn/?p=2592
2:http://bigkun.me/2014/01/22/rocksdb%E7%AC%AC%E4%B8%80%E7%AF%87%EF%BC%9A%E5%AE%89%E8%A3%85/
3:http://askubuntu.com/questions/312173/installing-gflags-12-04
4:http://blog.itpub.net/16582684/viewspace-1253841/
5:http://pyrocksdb.readthedocs.org/en/latest/installation.html
这里大部分代码来自链接5和链接4
第一步:必须更新Ubuntu的G++和GCC至4.7 以上( 有C++11支持 )
给出一个例子(http://lonelyprogram.blog.51cto.com/6246243/1355259)
a.更新gcc,不必卸掉原先的gcc
b.升级g++
c.查看版本
第二步:安装必要的一些库如(build-essential libsnappy-dev zlib1g-dev libbz2-dev libgflags-dev)
这里需要特别说明一下如何安装gflags
http://askubuntu.com/questions/312173/installing-gflags-12-04 这个帖子里已有详细介绍,可以操作,这里不做重复。
第三步:下载安装rocksDB 这里是从github上复制安装
之后,需要对rocksdb中的一些文件进行修改
指定用户权限,创建数据库(shuren是用户名)
进行接下来三步操作,解决这个问题 “ Fatal error: rocksdb/slice.h: No such file or directory "
上面,数据库安装就成功了
第四步:安装pyrocksdb()
这样pyrocksdb安装成功,对数据库进行一下测试
最后一句是关闭连接。
如此,你就可以基本使用数据库,具体的详细操作参见http://pyrocksdb.readthedocs.org/en/latest/tutorial/index.html
As root (
sudo su -is your friend, or just preface each yum invocation below with
sudo):
First, enable EPEL, as @Etan Reisner suggested:
yum install epel-release
Then, to install lz4 binary:
yum install lz4
And/or, to install the library:
yum install lz4-devel
And, you're done.
There is no document for how to compile rocksdb with lz4 support, I work on it for whole afternoon, failed.
Facebook member
igorcanadi commented on
4 Nov 2015
You just have to install it on your system -- our compile process detects this automatically:https://github.com/facebook/rocksdb/blob/master/build_tools/build_detect_platform#L263
rocksDB 安装问题简单介绍
前一段时间准备测试rocksdb,按照帖子和官网的例子,在安装过程中遇到一些问题。这里给出的是在Ubuntu下安装python使用的版本。首先,要感谢这些帖子对我的帮助:
1:http://tech.uc.cn/?p=2592
2:http://bigkun.me/2014/01/22/rocksdb%E7%AC%AC%E4%B8%80%E7%AF%87%EF%BC%9A%E5%AE%89%E8%A3%85/
3:http://askubuntu.com/questions/312173/installing-gflags-12-04
4:http://blog.itpub.net/16582684/viewspace-1253841/
5:http://pyrocksdb.readthedocs.org/en/latest/installation.html
这里大部分代码来自链接5和链接4
第一步:必须更新Ubuntu的G++和GCC至4.7 以上( 有C++11支持 )
给出一个例子(http://lonelyprogram.blog.51cto.com/6246243/1355259)
a.更新gcc,不必卸掉原先的gcc
sudo add-apt-repository ppa:ubuntu-toolchain-r/testsudo apt-get updatesudo apt-get install gcc-4.8sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
b.升级g++
apt-get install g++-4.8
c.查看版本
gcc --version g++ --version
第二步:安装必要的一些库如(build-essential libsnappy-dev zlib1g-dev libbz2-dev libgflags-dev)
apt-get install build-essential apt-get install libsnappy-dev zlib1g-dev libbz2-dev libgflags-dev
这里需要特别说明一下如何安装gflags
http://askubuntu.com/questions/312173/installing-gflags-12-04 这个帖子里已有详细介绍,可以操作,这里不做重复。
第三步:下载安装rocksDB 这里是从github上复制安装
git clone https://github.com/facebook/rocksdb.git cd rocksdb
之后,需要对rocksdb中的一些文件进行修改
vi Makefile 将这一行 OPT += -O2 -fno-omit-frame-pointer -momit-leaf-frame-pointer 修改为 OPT += -O2 -lrt -fno-omit-frame-pointer -momit-leaf-frame-pointer 在~/.bashrc中增加 export LD_PRELOAD=/lib/x86_64-linux-gnu/librt.so.1,并使变量生效source ~/.bashrc (这两步用于解决这个问题 " undefined symbol: clock_gettime")
sudo git checkout 2.8.fb sudo make shared_lib 修改环境变量,头文件库和链接库以及路径(直接在终端输入即可) $ export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:`pwd`/include $ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:`pwd` $ export LIBRARY_PATH=${LIBRARY_PATH}:`pwd`
指定用户权限,创建数据库(shuren是用户名)
cd .. sudo chown shuren:shuren rocksdb -Rf cd rocksdb
进行接下来三步操作,解决这个问题 “ Fatal error: rocksdb/slice.h: No such file or directory "
sudo cp librocksdb.so /usr/local/lib sudo mkdir -p /usr/local/include/rocksdb/ sudo cp -r ./include/* /usr/local/include/
上面,数据库安装就成功了
第四步:安装pyrocksdb()
$ apt-get install python-virtualenv python-dev $ virtualenv pyrocks_test $ cd pyrocks_test $ . bin/active(这句我好像没有执行,但官网给出,就贴上吧) $ pip install "Cython>=0.20" $ pip install git+git://github.com/stephan-hof/pyrocksdb.git
这样pyrocksdb安装成功,对数据库进行一下测试
shuren@hq:/u01/rocksdb$ python Python 2.7.3 (default, Sep 26 2013, 20:03:06) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import rocksdb >>> db = rocksdb.DB("test.db", rocksdb.Options(create_if_missing=True)) >>> db.put(b"key1", b"v1") >>> db.put(b"key2", b"v2") >>> db.get(b"key1") 'v1' >>>del db
最后一句是关闭连接。
如此,你就可以基本使用数据库,具体的详细操作参见http://pyrocksdb.readthedocs.org/en/latest/tutorial/index.html
相关文章推荐
- How to compile mplayer with vdpau support on Ubuntu
- How to Compile XviD with Microsoft Visual C++ 6.0(zhuan)
- How To Compile Qt with Visual Studio
- GDB compile with arm-none-linux-gnueabi Howto
- How to Compile XviD with Microsoft Visual C++6.0
- How to compile C++ with GCC
- How to deal with "Could not find component on update server. Contact VMware Support or your system administrator." in Vmware.
- How to build cURL static library with SSL support on Windows
- Why and How to Enable rc.local Support with Systemd
- [ZZ]How To Compile Qt 4.7 with Visual Studio 2010
- How to build CP2K with Intel Compiler 12.1, OpenMPI-1.4.3 and Infiniband Support
- How to compile WinPcap with Visual Studio 2010?
- How to Compile XviD with Microsoft Visual C++ 6.0(转)
- how to deal with the situation that the language support option disappears in linux ubuntu
- How to compile Tensorflow with SSE4.2 and AVX instructions?
- How to make a combo box with fulltext search autocomplete support?
- how to compile kinfu_remake with cuda 9.0 opencv2.4.13.4
- How to Compile XviD with Microsoft Visual C++ 6.0
- How to compile TLD with Win7-64bit + matlab2013b-64bit + VS2012 + OpenCV3.0
- How to compile C++ boost library with Intel C++ compiler