2023-09-01 05:34:37 +00:00
|
|
|
# pawg5
|
2017-01-31 13:58:02 +00:00
|
|
|
|
2023-09-01 05:34:37 +00:00
|
|
|
[![Go Report Card](https://goreportcard.com/badge/yunginnanet/pawg5)](https://goreportcard.com/report/yunginnanet/pawg5)
|
|
|
|
[![GoDoc](https://godoc.org/git.tcp.direct/kayos/pawg5?status.svg)](https://pkg.go.dev/git.tcp.direct/kayos/pawg5)
|
2019-03-21 21:56:21 +00:00
|
|
|
|
2023-09-01 05:34:37 +00:00
|
|
|
a ~~P.A.W.G rub~~ [pogreb](https://git.mills.io/prologic/bitcask) distributed key/value store
|
|
|
|
using [raft](https://github.com/hashicorp/raft) for concensus with a
|
|
|
|
[redis](https://redis.org) compatible API
|
2017-01-31 13:58:02 +00:00
|
|
|
|
2023-09-01 05:34:37 +00:00
|
|
|
based off of [kvnode](https://github.com/tidwall/kvnode) and [bitraft](https://git.mills.io/prologic/bitraft)
|
|
|
|
(See [LICENSE.old](/LICENSE.old) and [LICENSE.prologic](/LICENSE.prologic))
|
2019-03-19 08:27:06 +00:00
|
|
|
|
2023-09-01 05:34:37 +00:00
|
|
|
- redis compatible API
|
|
|
|
- pogreb disk-based storage
|
|
|
|
- Raft support with [finn](https://github.com/tidwall/finn) commands
|
|
|
|
- compatible with existing Redis clients (probably?)
|
2017-01-31 13:58:02 +00:00
|
|
|
|
2023-09-01 05:34:37 +00:00
|
|
|
### works like you'd expect prolly
|
2017-01-31 13:58:02 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
SET key value
|
|
|
|
GET key
|
|
|
|
DEL key [key ...]
|
2021-02-17 06:57:12 +00:00
|
|
|
KEYS pattern
|
2017-01-31 13:58:02 +00:00
|
|
|
FLUSHDB
|
|
|
|
SHUTDOWN
|
|
|
|
```
|
|
|
|
|
2023-09-01 05:34:37 +00:00
|
|
|
### back that (*p*)hat (*a*)ss \[up\] (*w*)hite (*g*)irl, \[on\] (5)
|
2017-02-18 16:52:37 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
RAFTSNAPSHOT
|
|
|
|
```
|
2023-09-01 05:34:37 +00:00
|
|
|
this will creates a new snapshot in the `data/snapshots` directory.
|
2017-02-18 16:52:37 +00:00
|
|
|
Each snapshot contains two files, `meta.json` and `state.bin`.
|
2023-09-01 05:34:37 +00:00
|
|
|
the state file is the database in a compressed format.
|
2017-02-18 16:52:37 +00:00
|
|
|
The meta file is details about the state including the term, index, crc, and size.
|
|
|
|
|
2023-09-01 05:34:37 +00:00
|
|
|
ideally you call `RAFTSNAPSHOT` and then store the state.bin on some other server like S3.
|
2017-02-18 16:52:37 +00:00
|
|
|
|
|
|
|
To restore:
|
2023-09-01 05:34:37 +00:00
|
|
|
- create a new raft cluster
|
|
|
|
- download the state.bin snapshot
|
|
|
|
- pipe the commands using the `pawg5 --parse-snapshot` and `redis-cli --pipe` commands
|
2017-02-18 16:52:37 +00:00
|
|
|
|
2023-09-01 05:34:37 +00:00
|
|
|
#### Example:
|
2017-02-18 16:52:37 +00:00
|
|
|
```
|
2023-09-01 05:34:37 +00:00
|
|
|
pawg5 --parse-snapshot state.bin | redis-cli -h 10.0.1.5 -p 4920 --pipe
|
2017-02-18 16:52:37 +00:00
|
|
|
```
|
|
|
|
|
2023-09-01 05:34:37 +00:00
|
|
|
this will execute all of the `state.bin` commands on the leader at `10.0.1.5:4920`
|
2017-01-31 13:58:02 +00:00
|
|
|
|
2019-03-19 08:27:06 +00:00
|
|
|
|
2023-09-01 05:34:37 +00:00
|
|
|
for information on the `redis-cli --pipe` command see [Redis Mass Insert](https://redis.io/topics/mass-insert).
|