PrkDB Deployment Guide
This guide reflects the current prkdb-server binary and the current prkdb-cli verification workflow.
Architecture
- Inter-node Raft traffic uses the addresses in
CLUSTER_NODES. - Client gRPC traffic is multiplexed on the same address and port as the local node entry in
CLUSTER_NODES. GRPC_PORTis optional. When set, it must match the local node'sCLUSTER_NODESport.- Use
PRKDB_ADVERTISED_GRPC_ADDRwhen the bind address differs from the dialable client address. - Use
PRKDB_ADVERTISED_NODE_ADDRSwhen peer nodes also need explicit dialable client addresses in metadata, for example2=http://db-2.example.com:8081,3=http://db-3.example.com:8082. - Metrics bind to
127.0.0.1:(9090 + NODE_ID)by default. SetPRKDB_METRICS_ADDRto override orPRKDB_DISABLE_METRICS=1to disable them. - Schema registry data is persisted under
${STORAGE_PATH}/schemas.
Build
bash
cargo build --release --bin prkdb-server --bin prkdb-cli
cp target/release/prkdb-server /usr/local/bin/
cp target/release/prkdb-cli /usr/local/bin/prkdbExample 3-Node Cluster
Node addresses
- Node 1 address:
10.0.0.1:8080 - Node 2 address:
10.0.0.2:8081 - Node 3 address:
10.0.0.3:8082
Systemd unit
Create /etc/systemd/system/prkdb.service on each node.
ini
[Unit]
Description=PrkDB Server
After=network.target
[Service]
Type=simple
User=prkdb
WorkingDirectory=/var/lib/prkdb
Environment=NODE_ID=1
Environment=CLUSTER_NODES=1@10.0.0.1:8080,2@10.0.0.2:8081,3@10.0.0.3:8082
Environment=STORAGE_PATH=/var/lib/prkdb/node1
Environment=PRKDB_ADMIN_TOKEN=change-me
Environment=PRKDB_ADVERTISED_GRPC_ADDR=http://db-1.example.com:8080
Environment=PRKDB_ADVERTISED_NODE_ADDRS=2=http://db-2.example.com:8081,3=http://db-3.example.com:8082
ExecStart=/usr/local/bin/prkdb-server
Restart=always
RestartSec=5
LimitNOFILE=65536
[Install]
WantedBy=multi-user.targetFor node 2 and node 3, change:
NODE_IDSTORAGE_PATH- the local address inside
CLUSTER_NODES
Start the Cluster
bash
sudo systemctl daemon-reload
sudo systemctl enable prkdb
sudo systemctl start prkdbVerify the Deployment
Check metrics
On node 1:
bash
curl http://127.0.0.1:9091/metrics | grep prkdb_upOn node 2:
bash
curl http://127.0.0.1:9092/metrics | grep prkdb_upCheck the gRPC API
bash
export PRKDB_ADMIN_TOKEN=change-me
prkdb --server http://127.0.0.1:8080 collection listCheck schema registry persistence
bash
export PRKDB_ADMIN_TOKEN=change-me
prkdb schema list --server http://127.0.0.1:8080Operational Notes
CLUSTER_NODESshould contain every node in the cluster, including the local node.- Smart clients consume the addresses returned by metadata. Do not advertise
0.0.0.0; setPRKDB_ADVERTISED_GRPC_ADDRif clients connect through DNS or a load balancer. - If peer nodes have different bind and public addresses, configure
PRKDB_ADVERTISED_NODE_ADDRSso metadata never falls back to an internal-only socket. PRKDB_ADMIN_TOKENprotects admin RPCs such as collection management and schema registration.- If you expose the HTTP server from
prkdb-cli serve, restrict CORS origins explicitly withPRKDB_CORS_ORIGINS. - WebSocket auth is header-based. Set
PRKDB_WS_TOKENwhen you want bearer-token enforcement for/ws/collections/:name.
Security Checklist
- Run the cluster behind TLS termination or a private network boundary.
- Keep
PRKDB_ADMIN_TOKENandPRKDB_WS_TOKENout of shell history and process listings where possible. - Persist
STORAGE_PATHon durable local disks. - Scrape metrics from the node-local metrics bind address instead of exposing it publicly.