Scripts Overview
NoKV now groups shell entrypoints by role instead of keeping every helper flat under scripts/.
Layout
| Path | Role |
|---|---|
scripts/dev | Local development and bootstrap helpers for running a cluster from raft_config*.json. |
scripts/ops | Operator-style workflows that drive the formal migration CLI. |
scripts/lib | Shared shell helpers for config lookup, workdir hygiene, and build/bootstrap rules. |
scripts/*.sh | Tooling or benchmark entrypoints that are still intentionally top-level. |
This split is deliberate:
devscripts are allowed to help with local experiments and smoke tests.opsscripts must treat the migration CLI as source of truth and stay stricter.libis where shared rules live, so shell semantics do not drift across scripts.
Bootstrap & Local Launch
scripts/dev/cluster.sh
- Purpose: build
nokvandnokv-config, start the canonical 333 separated dev cluster, seed fresh store workdirs, then start stores fromraft_config.json. - Starts:
- three
nokv meta-rootprocesses (Truth plane; replicated is the only mode) - one
nokv coordinatorprocess (Service plane; always remote-rooted) - all configured stores (Execution plane)
- three
- Uses shared rules from:
scripts/lib/common.shscripts/lib/config.shscripts/lib/workdir.sh
- Example:
./scripts/dev/cluster.sh --config ./raft_config.example.json --workdir ./artifacts/cluster - Notes:
--configdefaults to./raft_config.example.json--workdirdefaults to./artifacts/cluster- uses fixed local metadata-root gRPC endpoints
127.0.0.1:2380/2381/2382 - uses fixed local metadata-root raft transport endpoints
127.0.0.1:3380/3381/3382 - store workdirs are rejected if they contain unexpected files
- logs stream with
[meta-root-<id>]/[coordinator]/[store-<id>]prefixes and are still written toroot.log/coordinator.log/server.log - this is a bootstrap/dev launcher, not a restart command
- production-style restarts should run
scripts/ops/serve-meta-root.sh,scripts/ops/serve-coordinator.sh, andscripts/ops/serve-store.shdirectly against the same durable workdirs
scripts/ops/bootstrap.sh
- Purpose: seed local peer catalog metadata into a set of store directories derived from a path template.
- Intended for:
- Docker Compose bootstrap
- local static-topology experiments
- Example:
./scripts/ops/bootstrap.sh --config /etc/nokv/raft_config.json --path-template /data/store-{id} - Notes:
- skips stores that already contain
CURRENT - refuses to seed into dirty directories
- this is bootstrap-only; it does not recover runtime topology
- use
nokv serve/scripts/ops/serve-store.shto restart an existing store from the same workdir
- skips stores that already contain
scripts/ops/serve-store.sh
- Purpose: thin wrapper around
nokv servefor one store. - Example:
./scripts/ops/serve-store.sh \ --config ./raft_config.example.json \ --store-id 1 \ --workdir ./artifacts/cluster/store-1 \ --scope local - Notes:
- resolves store listen/workdir/Coordinator defaults through
nokv serve --config - remote peer recovery comes from
raftstore/localmeta; configstoresonly providestoreID -> addr - no longer treats
config.regionsas restart-time topology truth - if a static transport override is needed, use
--store-addr <store-id>=<addr>rather than a peer-id keyed mapping --scope dockerselects container-friendly addresses
- resolves store listen/workdir/Coordinator defaults through
scripts/ops/serve-meta-root.sh
- Purpose: thin wrapper around
nokv meta-rootfor one replicated metadata-root peer. - Example:
./scripts/ops/serve-meta-root.sh \ --addr 127.0.0.1:2380 \ --workdir ./artifacts/cluster/meta-root-1 \ --node-id 1 \ --transport-addr 127.0.0.1:3380 \ --peer 1=127.0.0.1:3380 \ --peer 2=127.0.0.1:3381 \ --peer 3=127.0.0.1:3382 - Notes:
--peervalues are metadata-root raft transport addresses, not gRPC service addresses--workdir,--node-id,--transport-addr, and exactly 3--peervalues are required; there is no single-process local mode- forwards shutdown signals to
nokv meta-root
scripts/ops/serve-coordinator.sh
- Purpose: thin wrapper around
nokv coordinatorfor one coordinator process wired to an external 3-peer meta-root cluster. - Example:
./scripts/ops/serve-coordinator.sh \ --addr 127.0.0.1:2379 \ --coordinator-id c1 \ --root-peer 1=127.0.0.1:2380 \ --root-peer 2=127.0.0.1:2381 \ --root-peer 3=127.0.0.1:2382 - Notes:
--root-peervalues are metadata-root gRPC service addresses, not raft transport- exactly 3
--root-peervalues are required (mirrors the Truth-plane quorum) --coordinator-idis required (stable lease owner id)- forwards shutdown signals to
nokv coordinator
Migration Workflow
scripts/ops/migrate-cluster.sh
- Purpose: one-shot local operator wrapper for the standalone-to-cluster migration path.
- Drives:
nokv migrate plannokv migrate initnokv migrate expand- optional
transfer-leader - optional
remove-peer
- Example:
./scripts/ops/migrate-cluster.sh \ --config ./raft_config.example.json \ --workdir ./artifacts/standalone \ --seed-store 1 \ --seed-region 1 \ --seed-peer 101 \ --target 2:201 \ --target 3:301 \ --transfer-leader 201 \ --remove-peer 101 - Notes:
- seed workdir must already contain standalone data
- target store workdirs must be fresh
- uses the migration CLI as the only source of truth
Shared Shell Rules
scripts/lib/common.sh
- shared repo-root detection
- shared build helpers for
nokvandnokv-config - shared TCP readiness helper
scripts/lib/config.sh
- shared
nokv-configlookups for:- store lines
- region lines
- Coordinator address
- Coordinator workdir
scripts/lib/workdir.sh
- shared workdir hygiene rules:
- remove stale
LOCK - reject unexpected directory contents
- assert a directory is fresh before seeding or bootstrap
- remove stale
This is where shell-level correctness rules should keep living. New scripts should reuse these helpers instead of open-coding workdir or config parsing logic again.
Tooling & Benchmarks
| Script | Purpose |
|---|---|
scripts/run_benchmarks.sh | Execute YCSB benchmarks (default engines: NoKV/Badger/Pebble, optional RocksDB). |
scripts/build_rocksdb.sh | Build local RocksDB artifacts used by benchmark comparisons. |
scripts/debug.sh | Wrap dlv test for focused debugging. |
scripts/gen.sh | Format protobufs and regenerate Go bindings through Buf. |
For recovery and transport fault validation, use direct Go tests instead of shell wrappers:
RECOVERY_TRACE_METRICS=1 \
go test ./... -run 'TestRecovery(RemovesStaleValueLogSegment|FailsOnMissingSST|FailsOnCorruptSST|ManifestRewriteCrash|SlowFollowerSnapshotBacklog|SnapshotExportRoundTrip|WALReplayRestoresData)' -count=1 -v
CHAOS_TRACE_METRICS=1 \
go test -run 'TestGRPCTransport(HandlesPartition|MetricsWatchdog|MetricsBlockedPeers)' -count=1 -v ./raftstore/transport
Relationship with nokv-config
nokv-config stores/regions/coordinatorremain the structured topology source for shell scripts.config.regionsremain bootstrap/deployment metadata, not restart-time peer truth.nokv-config catalogwrites Region metadata into the local peer catalog.- Go tools can import
github.com/feichai0017/NoKV/configand callconfig.LoadFile/Validatedirectly.
Maintaining a single raft_config.json still keeps development scripts, Docker Compose, and automated tests aligned. The difference now is that shell behavior is shared and explicit instead of repeated across four separate entrypoints.