RocksDB provides comprehensive support for Linux distributions, with optimized builds for various package managers and architectures.
Prerequisites
Compiler Requirements
RocksDB requires a modern C++ compiler with C++20 support:
- GCC: Version 11 or higher
- Clang: Version 10 or higher
Recommended Dependencies
While RocksDB can compile without any dependencies, installing compression libraries significantly improves performance:
- zlib: General-purpose compression
- bzip2: High compression ratio
- lz4: Extremely fast compression
- snappy: Fast compression optimized for speed
- zstandard: Fast real-time compression algorithm
Optional dependencies:
- gflags: Required for command-line tools
- clang-format: Required for code formatting checks
Ubuntu / Debian
Update compiler
Ensure you have GCC 11 or higher:sudo apt-get update
sudo apt-get install build-essential
gcc --version # Should show 11 or higher
Install dependencies
Install compression libraries and tools:sudo apt-get install libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
Clone repository
git clone https://github.com/facebook/rocksdb.git
cd rocksdb
Build RocksDB
Don’t use make or make all for production builds. These compile in debug mode, which is significantly slower than release mode.
CentOS / RHEL / Fedora
Update compiler
Ensure you have GCC 11 or higher:sudo yum install gcc gcc-c++
gcc --version # Should show 11 or higher
Install gflags from source
git clone https://github.com/gflags/gflags.git
cd gflags
git checkout v2.2.0
./configure && make && sudo make install
cd ..
After installation, add the include and library paths:export CPATH=/usr/local/include:$CPATH
export LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH
Install compression libraries
sudo yum install snappy snappy-devel
sudo yum install zlib zlib-devel
sudo yum install bzip2 bzip2-devel
sudo yum install lz4-devel
sudo yum install libzstd-devel
Clone and build
git clone https://github.com/facebook/rocksdb.git
cd rocksdb
make static_lib
Installing zstandard on older systems
If zstandard is not available through your package manager:
sudo yum install epel-release
sudo yum install libzstd-devel
Build Options
Portable Build
By default, RocksDB optimizes for your specific CPU (-march=native). To build a binary compatible with different architectures:
PORTABLE=1 make static_lib
For a reasonable compromise between optimization and compatibility on x86_64:
PORTABLE=haswell make static_lib
This supports most processors made since 2013 while maintaining good performance.
Debug vs Release
Production builds: Always use make static_lib or make shared_lib (release mode).Development builds: Use make all or make check (debug mode).
Verification
Verify your installation:
# Check library was built
ls -lh librocksdb.a
# Run a simple test
make check
Next Steps
Getting Started
Learn the basics of using RocksDB
API Reference
Explore the complete API documentation