PAWG5/README.md

81 lines
2.2 KiB
Markdown
Raw Normal View History

# bitraft
2017-01-31 13:58:02 +00:00
2022-07-27 09:58:15 +00:00
[![Go Report Card](https://goreportcard.com/badge/yunginnanet/bitraft)](https://goreportcard.com/report/yunginnanet/bitraft)
[![GoDoc](https://godoc.org/git.tcp.direct/kayos/bitraft?status.svg)](https://pkg.go.dev/git.tcp.direct/kayos/bitraft)
2019-03-21 21:56:21 +00:00
2021-07-12 22:53:57 +00:00
A [Bitcask](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 written in [Go](https://golang.org).
2017-01-31 13:58:02 +00:00
Based off of [kvnode](https://github.com/tidwall/kvnode).
(See [LICENSE.old](/LICENSE.old))
- Redis compatible API
- Bitcask disk-based storage
2017-02-18 17:12:54 +00:00
- Raft support with [Finn](https://github.com/tidwall/finn) commands
- Compatible with existing Redis clients
2017-01-31 13:58:02 +00:00
2019-03-30 10:29:14 +00:00
## Usage
```#!bash
2021-07-12 22:53:57 +00:00
$ go get git.mills.io/prologic/bitraft
2019-03-30 10:29:14 +00:00
$ bitraft
```
## Docker
You can also use the [Bitraft Docker Image](https://cloud.docker.com/u/prologic/repository/docker/prologic/bitraft):
```#!bash
$ docker pull prologic/bitraft
$ docker run -d -p 4920:4920 prologic/bitraft
```
## Example session
2017-01-31 13:58:02 +00:00
Commands:
```
SET key value
GET key
DEL key [key ...]
KEYS pattern
2017-01-31 13:58:02 +00:00
FLUSHDB
SHUTDOWN
```
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
- Pipe the commands using the `bitraft --parse-snapshot` and `redis-cli --pipe` commands
2017-02-18 16:52:37 +00:00
Example:
```
bitraft --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
## License
bitraft source code is available under the MIT [License](/LICENSE).
Previously based off of [kvnode](https://github.com/tidwall/kvnode).
(See [LICENSE.old](/LICENSE.old))