1
0
mirror of https://git.mills.io/kayos/bitraft.git synced 2024-06-25 16:28:53 +00:00
bitraft/README.md

77 lines
1.8 KiB
Markdown
Raw Normal View History

2017-01-31 13:58:02 +00:00
# kvnode
2017-02-18 17:12:54 +00:00
Minimal Key/Value store with basic Redis support.
2017-01-31 13:58:02 +00:00
- Redis API
2017-02-18 17:12:54 +00:00
- LevelDB disk-based storage
- Raft support with [Finn](https://github.com/tidwall/finn) commands
- Compatible with existing Redis clients
2017-01-31 13:58:02 +00:00
Commands:
```
SET key value
GET key
DEL key [key ...]
2017-02-15 01:22:33 +00:00
PDEL pattern
2017-02-17 20:23:49 +00:00
KEYS pattern [PIVOT prefix] [LIMIT count] [DESC] [WITHVALUES]
2017-01-31 20:48:02 +00:00
MSET key value [key value ...]
MGET key [key ...]
2017-01-31 13:58:02 +00:00
FLUSHDB
SHUTDOWN
```
2017-02-18 17:12:54 +00:00
## Key scanning
2017-03-02 19:57:29 +00:00
The `KEYS` command returns keys and values, ordered by keys.
2017-02-18 17:12:54 +00:00
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.
2017-02-18 16:52:37 +00:00
## 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
2017-02-18 16:53:31 +00:00
- Pipe the commands using the `kvnode-server --parse-snapshot` and `redis-cli --pipe` commands
2017-02-18 16:52:37 +00:00
Example:
```
2017-02-18 17:12:54 +00:00
kvnode-server --parse-snapshot state.bin | redis-cli -h 10.0.1.5 -p 4920 --pipe
2017-02-18 16:52:37 +00:00
```
This will execute all of the `state.bin` commands on the leader at `10.0.1.5:4920`
2017-02-18 16:53:31 +00:00
For information on the `redis-cli --pipe` command see [Redis Mass Insert](https://redis.io/topics/mass-insert).
2017-01-31 13:58:02 +00:00
## Contact
Josh Baker [@tidwall](http://twitter.com/tidwall)
## License
kvnode source code is available under the MIT [License](/LICENSE).