Install
Getting Started
Prerequisites
- Rust (latest stable version)
- Cargo (latest stable version)
- RocksDB libraries
Installation
From Source
Clone the repository:
git clone https://github.com/your-repo/rocksdb-server.git cd rocksdb-server
Build the project:
cargo build --release
Homebrew Tap for RocksDBFusion Server
This repository contains the Homebrew formula for installing RocksDBFusion Server.
How to Use
First, you need to tap this repository:
brew tap s00d/rocksdbserver
Once the repository is tapped, you can install RocksDBFusion Server with the following command:
brew install rocksdb_server
After installation, you can start the server with:
rocksdb_server --dbpath ./db_test --address 127.0.0.1:12345 --host 127.0.0.1 --log-level info
Or start it as a service with:
export ROCKSDB_PATH="$(brew --prefix)/var/rocksdb/db"
export ROCKSDB_ADDRESS=127.0.0.1:12345
export ROCKSDB_LOCK_FILE="$(brew --prefix)/var/rocksdb/rocksdb.lock"
brew services start rocksdb_server
Using Snap (Linux)
RocksDB Server is available as a Snap package for easy installation on Linux systems.
Install Snapd (if not already installed):
sudo apt update sudo apt install snapd
Install RocksDB Server:
sudo snap install rocksdb-server
Start the server:
rocksdb-server.rocksdb-server --dbpath ./db_test --address 127.0.0.1:12345 --host 127.0.0.1 --log-level info
Enable and start as a service:
sudo snap start rocksdb-server
Finding Logs
To find the logs for the RocksDB server, use the following command:
tail -f $(brew --prefix)/var/log/rocksdb_server.log
Finding the Database Directory
The RocksDB server stores its data in the var/rocksdb/db
directory under the Homebrew prefix. To find and navigate to this directory, use the following commands:
Find the Homebrew prefix:
brew --prefix
This will output the Homebrew prefix, for example,
/usr/local
.Navigate to the
rocksdb
data directory:cd $(brew --prefix)/var/rocksdb
macOS Sign
If you are on macOS, you may need to sign the application before running it. Here are the steps:
Make the binary executable:
chmod +x ./server-0.1.2-aarch64-apple-darwin
Clear extended attributes and sign the binary:
xattr -cr ./server-0.1.2-aarch64-apple-darwin && codesign --force --deep --sign - ./server-0.1.2-aarch64-apple-darwin
Using systemd on Linux
Create a systemd service file:
sudo nano /etc/systemd/system/rocksdb_server.service
Add the following content to the service file:
[Unit] Description=RocksDB Server After=network.target [Service] Environment="ROCKSDB_PATH=${ROCKSDB_PATH:-/var/rocksdb/db}" Environment="ROCKSDB_PORT=${ROCKSDB_ADDRESS:-127.0.0.1:12345}" Environment="ROCKSDB_LOCK_FILE=${ROCKSDB_LOCK_FILE:-/var/rocksdb/rocksdb.lock}" ExecStart=/usr/local/bin/rocksdb_server --dbpath $ROCKSDB_PATH --address $ROCKSDB_PORT --lock-file $ROCKSDB_LOCK_FILE --host 127.0.0.1 --log-level info Restart=always User=nobody Group=nogroup [Install] WantedBy=multi-user.target
Reload systemd to apply the new service:
sudo systemctl daemon-reload
Enable and start the RocksDB server service:
sudo systemctl enable rocksdb_server sudo systemctl start rocksdb_server
Running the Server
To start the RocksDB server, use the following command:
rocksdb_server --dbpath ./db_test --address 127.0.0.1:12345 --host 127.0.0.1 --log-level info
Command-Line Options and Environment Variables
--dbpath <PATH>
: Path to the RocksDB database (default:./db_test
, env:ROCKSDB_PATH
)--address <HOST:PORT>
: Host and Port to listen on (default:127.0.0.1:12345
, env:ROCKSDB_ADDRESS
)--ttl <TTL>
: Time-to-live (TTL) for database entries in seconds (env:ROCKSDB_TTL
)--token <TOKEN>
: Authentication token for server access (env:ROCKSDB_TOKEN
)--log-level <LEVEL>
: Logging level (debug, info, warn, error) (default:info
, env:ROCKSDB_LOG_LEVEL
)--lock-file <FILE>
: Path to the lock file (env:ROCKSDB_LOCK_FILE
)--cache
: Enable cache layer (default:false
, env:ROCKSDB_CACHE
)--cache-ttl <TTL>
: Cache time-to-live in seconds (default:1800
, env:ROCKSDB_CACHE_TTL
)--metrics
: Enable metrics server (default:false
, env:ROCKSDB_METRICS
)--health-check
: Enable health check endpoint (default:false
, env:ROCKSDB_HEALTH_CHECK
)
see rocksdb-server -h
Logging
The server uses the env_logger
crate for logging. The logging level can be set via the command-line argument --log-level
. Available levels are: debug
, info
, warn
, error
.
Authentication
If the server is started with an authentication token (--token <TOKEN>
), clients must include this token in their requests to access the server. Example request with token: