Linux Installation and Embedded / Standalone Modes

Updated:
Author: Erkin Khidirov

Slyber DB can run as an isolated Linux system daemon (ModeStandalone) or embedded directly inside a Go application's process memory (ModeEmbedded) without network sockets. Both modes share the same storage and sharding architecture.

1. One-Line Linux Installation

The official installer detects the host CPU architecture (x86_64 / arm64), verifies SHA256SUMS, enables NTP time synchronization, creates a dedicated slyber_db system user, generates unique 48-character secrets in /opt/slyber_db/.env, and starts the systemd unit:

Bash
curl -fsSL https://raw.githubusercontent.com/slyber-app/slyber-db/main/install.sh | sudo bash

To enable transparent AES-256-GCM encryption at rest immediately (creating a key at /opt/slyber_db/secrets/aes256.key bound to IDENTITY), pass ENABLE_ENCRYPTION=true:

Bash
curl -fsSL https://raw.githubusercontent.com/slyber-app/slyber-db/main/install.sh | sudo env ENABLE_ENCRYPTION=true bash

Verify the service status and built-in readiness probes:

Bash
sudo systemctl status slyber_db
slyber_db --healthcheck=http://127.0.0.1:9110/healthz
slyber_db --healthcheck=https://127.0.0.1:9095/healthz

2. Manual Build and Configuration (ModeStandalone)

When deploying manually, client, admin, and cluster secrets must be distinct and at least 32 bytes long with high entropy.

Step 1. Build the binary and generate secret files

Go
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /usr/local/bin/slyber_db ./cmd/dbd

mkdir -p /etc/sldb /var/lib/sldb
chmod 700 /etc/sldb /var/lib/sldb

openssl rand -hex 24 > /etc/sldb/client.secret
openssl rand -hex 24 > /etc/sldb/admin.secret
openssl rand -hex 32 > /etc/sldb/aes256.key
chmod 600 /etc/sldb/*

Step 2. Start the server in standalone mode

Config
slyber_db \
  --mode=standalone \
  --node-id=1 \
  --data-dir=/var/lib/sldb \
  --addr=0.0.0.0:9110 \
  --admin-addr=0.0.0.0:9095 \
  --sync-mode=full \
  --shards=16 \
  --groups=64 \
  --wal-segment-mb=64 \
  --memtable-mb=32 \
  --block-cache-mb=512 \
  --ballast-mb=64 \
  --allowlist="127.0.0.0/8,10.0.0.0/8,192.168.0.0/16" \
  --client-secret-file=/etc/sldb/client.secret \
  --admin-secret-file=/etc/sldb/admin.secret \
  --encryption-key-file=/etc/sldb/aes256.key

See the Limits, Configuration, and CLI Reference for the complete list of flags and environment variables.

3. Node Readiness Probe (Healthcheck)

Using a two-tier Peek(1) dispatcher, client port :9110 responds to GET /healthz over both plain HTTP (for lightweight L7/TCP load balancers, bypassing the TLS semaphore) and HTTPS TLS 1.3:

Bash
slyber_db --healthcheck=http://127.0.0.1:9110/healthz
curl -s http://127.0.0.1:9110/healthz

Healthy nodes return 200 OK with {"ok":true}, while nodes entering maintenance mode (Draining) return 503 with {"ok":false}.

4. Embedded Engine (ModeEmbedded)

In ModeEmbedded, the database runs directly inside your Go service with zero network hops or frame serialization overhead:

Go
package main

import (
	"context"
	"crypto/rand"
	"log"
	"time"

	"slyber.com/db/pkg/db"
)

func main() {
	ctx := context.Background()

	encKey := make([]byte, db.EncryptionKeyBytes)
	if _, err := rand.Read(encKey); err != nil {
		log.Fatal(err)
	}

	cfg := db.DefaultConfig("./sldb_embedded_data")
	cfg.Mode = db.ModeEmbedded
	cfg.SyncMode = db.SyncFull
	cfg.NumLocalShards = 16
	cfg.BlockCacheBytes = 512 << 20
	cfg.EncryptionKey = encKey

	engine, err := db.Open(cfg)
	if err != nil {
		log.Fatalf("failed to open db: %v", err)
	}
	defer func() {
		shutCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
		defer cancel()
		_ = engine.Close(shutCtx)
	}()

	ver, err := engine.Put(ctx, 10, []byte("user:42"), []byte("profile"), []byte(`{"name":"Alex"}`), 0)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Committed HLC version: %d", ver)
}

If you require low-level engine administration methods (CheckpointAll, CompactAll, or direct shard access), call db.OpenEmbedded(cfg) instead of db.Open(cfg).

5. Uninstalling on Linux

Stop the service and remove binaries while preserving /opt/slyber_db/.env, secrets, and database shards:

Bash
curl -fsSL https://raw.githubusercontent.com/slyber-app/slyber-db/main/uninstall.sh | sudo bash

Completely purge all data shards, secrets, configuration, and the slyber_db system user:

Bash
curl -fsSL https://raw.githubusercontent.com/slyber-app/slyber-db/main/uninstall.sh | sudo env PURGE_DATA=true bash