中文版见 README_CHI
MinerDB is a lightweight, simple, and reliable distributed key-value storage engine based on the Raft consensus algorithm. It supports distributed transactions, containerized deployment, service registry, disk storage, etc.
Currently, MinerDB is recommended for learning and personal projects only and is not recommended for production environments.
MinerDB currently consists of the following main modules: MinerRPC, Min, Raft, and MinerDB.
MinerRPC is a pure GO language RPC framework based on Socket+Zookeeper. MinerRPC supports dynamic proxy, network transmission, serialization, service registration, service discovery, and service invocation.
MinerDB uses MinerRPC as the internal communication framework for the cluster, Zookeeper as the service registry, and supports dynamic vertical scaling of containers.
For more information, see minerrpc
Min is a lightweight, simplified version of the Gin framework. Min focuses on performance and simplicity, implementing most of Gin's basic features including routing, middleware, request/response handling, error handling, and route grouping for quickly building HTTP services.
MinerDB uses Min to provide HTTP services externally.
For more information, see min
MinerDB uses the Raft consensus algorithm for data replication and consistency guarantees. Write requests support linearizability, and read requests support sequential consistency.
- Read requests: Can be sent to any node in the cluster and executed.
- Write requests: Sent to the Leader node, which broadcasts the write request to other nodes in the cluster. Once the majority of nodes have successfully written the data, the Leader node commits the write request.
MinerDB is divided into the Execution layer and the Storage layer.
- The Execution layer provides interfaces for upper-level operators and the local storage engine.
- The Storage layer implements persistent data storage based on WAL (Write-Ahead Logging) and Bitcask, and indexing based on BTree. It supports read-write lock management, ACID transactions, repeatable read isolation level, and high write operation efficiency.
- WAL: Stores log information in WAL during transaction execution and updates to in-memory Bitcask during the commit phase.
- Atomicity: Uses strict two-phase locking protocol, only supports data updates during the commit phase.
- Isolation: Implemented with read-write locks.
- Durability: Achieved by setting the interval for writing Bitcask data from memory to disk.
- Repeatable Read: Write operations of a transaction are only updated to in-memory Bitcask during the commit phase, and no other read operations are affected by write operations.
- GC: Periodically merges disk files and writes index information to Hintfile.
- Deadlock detection
- Improve Raft stability
- Implement more index structures
- Support more transaction isolation levels
- Support SQL, implement database frontend (Parser, Planner, Optimizer)
- Support more operators
- Support forward and backward iterators
Supports containerized deployment with docker-compose
docker-compose up --build -d
This will create 1 ZooKeeper container and 5 MinerDB containers, each providing services on ports 3001 to 3005
It can be accessed through any port
that provides serviceshttp://localhost:<port>/app/store
Execute a Post request to store data, with the request body in JSON format
{
"Key": "key_example",
"Value": "value example"
}
It can also be accessed through any port
that provides serviceshttp://localhost:<port>/app/store
Send a Get request to retrieve data, with the request body in JSON format
{
"Key": "key_example"
}
Image example:
Put data:
Get data:
MinerDB is inspired by etcd, oceanbase, nubedb, rosedb, and waterdb. Many thanks 🙏