1
0
mirror of https://git.mills.io/kayos/bitraft.git synced 2024-06-26 00:38:51 +00:00
A Bitcask Distributed Key/Value store using Raft for consensus with a Redis compatible API written in Go. Personal fork.
Go to file
Josh Baker a9ab8591d7 typo
2017-03-02 12:57:29 -07:00
cmd/kvnode-server backup and restore 2017-02-18 09:52:37 -07:00
vendor added glide and gitignore 2017-02-18 08:45:23 -07:00
.gitignore added glide and gitignore 2017-02-18 08:45:23 -07:00
glide.lock added glide and gitignore 2017-02-18 08:45:23 -07:00
glide.yaml added glide and gitignore 2017-02-18 08:45:23 -07:00
LICENSE renamed 2017-01-31 06:58:02 -07:00
Makefile renamed 2017-01-31 06:58:02 -07:00
README.md typo 2017-03-02 12:57:29 -07:00
server.go added ECHO command 2017-03-01 16:21:55 -07:00

kvnode

Minimal Key/Value store with basic Redis support.

  • Redis API
  • LevelDB disk-based storage
  • Raft support with Finn commands
  • Compatible with existing Redis clients

Commands:

SET key value
GET key
DEL key [key ...]
PDEL pattern
KEYS pattern [PIVOT prefix] [LIMIT count] [DESC] [WITHVALUES]
MSET key value [key value ...]
MGET key [key ...]
FLUSHDB
SHUTDOWN

Key scanning

The KEYS command returns keys and values, ordered by keys. The PIVOT keyword allows for efficient paging. For example:

redis> MSET key1 1 key2 2 key3 3 key4 4
OK
redis> KEYS * LIMIT 2
1) "key1"
2) "key2"
redis> KEYS * PIVOT key2 LIMIT 2
1) "key3"
2) "key4"

The PDEL commands will delete all items matching the specified pattern.

Backup and Restore

To backup data:

RAFTSNAPSHOT

This will creates a new snapshot in the data/snapshots directory. Each snapshot contains two files, meta.json and state.bin. The state file is the database in a compressed format. The meta file is details about the state including the term, index, crc, and size.

Ideally you call RAFTSNAPSHOT and then store the state.bin on some other server like S3.

To restore:

  • Create a new raft cluster
  • Download the state.bin snapshot
  • Pipe the commands using the kvnode-server --parse-snapshot and redis-cli --pipe commands

Example:

kvnode-server --parse-snapshot state.bin | redis-cli -h 10.0.1.5 -p 4920 --pipe

This will execute all of the state.bin commands on the leader at 10.0.1.5:4920

For information on the redis-cli --pipe command see Redis Mass Insert.

Contact

Josh Baker @tidwall

License

kvnode source code is available under the MIT License.