On CentOS 6.x or 7.x, you can do the following to easily install lz4 using the package manager.
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.
![@igorcanadi](https://i-blog.csdnimg.cn/blog_migrate/9ebf79a67fb575c695f13c8c30da3239.jpeg)
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使用的版本。
首先,要感谢这些帖子对我的帮助:
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
There is no document for how to compile rocksdb with lz4 support, I work on it for whole afternoon, failed.