https://github.com/thoainguyen/mtikv
Build a distributed transactional key-value database
https://github.com/thoainguyen/mtikv
distributed-database mvcc raft-consensus-algorithm transaction
Last synced: 11 months ago
JSON representation
Build a distributed transactional key-value database
- Host: GitHub
- URL: https://github.com/thoainguyen/mtikv
- Owner: thoainguyen
- Created: 2019-07-27T12:37:24.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-25T05:05:27.000Z (over 6 years ago)
- Last Synced: 2025-07-01T12:03:27.979Z (11 months ago)
- Topics: distributed-database, mvcc, raft-consensus-algorithm, transaction
- Language: Go
- Homepage:
- Size: 209 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MTiKV
Mini [TiKV](https://github.com/tikv/tikv): A Distributed transactional key-value database
## Architecture
### Overall
### Mtikv instance
### Raft Group
## Flow
### TxnKV
### RawKV
## Getting Started
### Prerequisites
* **Go**: https://golang.org/doc/install
* **RocksDB:**
1. Clone repo `Rocksdb`:
```sh
$ cd /home/$USER/Downloads
$ git clone https://github.com/facebook/rocksdb.git
```
2. Follow [THIS GUIDE](https://github.com/facebook/rocksdb/blob/master/INSTALL.md) to install rocksdb
* **Gorocksdb:**
1. Set CGO variable
```sh
export CGO_CFLAGS="-I/home/$USER/Downloads/rocksdb/include"
export CGO_LDFLAGS="-L/home/$USER/Downloads/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd"
```
2. Get library
```sh
$ go get github.com/tecbot/gorocksdb
```
### Installing
* **Clone mtikv into workspace:**
```sh
$ cd ~/go/src/github.com && mkdir thoainguyen && cd thoainguyen
$ git clone https://github.com/thoainguyen/mtikv
$ cd mtikv
```
## Deployment
### 1. Run PD:
```sh
$ cd cmd/pd
$ go run server.go
```
### 2. Run Mtikv_cli:
```sh
$ cd cmd/mtikv_cli
$ go run server.go
```
### 3. Run Mtikv (4 instance):
#### 3.1 Option 1: Run each instance
```sh
$ cd cmd/mtikv
$ go run server.go --node 1
$ go run server.go --node 2 // in another shell
$ go run server.go --node 3 // in another shell
$ go run server.go --node 4 // in another shell
```
#### 3.2 Option 2: Run via goreman
First install [goreman](https://github.com/mattn/goreman), which manages Procfile-based applications.
The [Procfile](./cmd/mtikv/Procfile) script will set up a local mtikv cluster. Start it with:
```sh
$ goreman start
```
### 4. Run Client (CLI)
```sh
$ cd cmd/client
$ go run client.go
```
## Usage:
```sh
$ go run client.go
$ set
$ get
$ del
$ begin // new transaction
$ commit // commit transaction
$ rollback // rollback transaction
Ctr+C to exit
```
## Authors
* **Nguyen Huynh Thoai** - *Maintainer* - [thoainguyen](https://github.com/thoainguyen)
## License
## Acknowledgments
* Mentor @thuyenpt