GithubHelp home page GithubHelp logo

wysagx / raftcore Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zxjcarrot/raftcore

0.0 0.0 0.0 105 KB

A raft consensus protocol implementation in C++.

C++ 96.10% Python 2.14% C 0.02% Makefile 1.75%

raftcore's Introduction

Overview

A library implements raft consensus protocol core functionalities, intended to be used as a building block for distributed systems.

Features supported

Leader election.
Log replication.
Leadership transfer.
Membership changes.

Features in development

Log compaction.

Prerequsites

protobuf 2.6.0
boost.asio boost.log
carrot-rpc

Installation

git clone https://github.com/zxjcarrot/raftcore
cd raftcore/src
make

Configuration

see exemplary conf file for reference. ####Bootstrap the cluster Say we have a cluster of 3 servers(A 192.168.1.1, B 192.168.1.2, C 192.168.1.3), in order to bootstrap the cluster, we have to choose one of the three servers as the initiating server, say server A. In the configuration file of A, set the @servers attribute to the address of server A itself, that is:
servers=192.168.1.1

After that, run the binary raftc on the server A, this will create a cluster consists of only one server(also a leader), namely server A.
./raftc
From now on, raftcore will maintain the server addresses in its replicated log.

Now in the configuration file of B and C, comment out the @servers attribute to state this server is a subsequently-added server or non-voting server, and run the binary on both servers. #server=
Then use the script reconfigure.py to add the two servers to the cluster.
./reconfigure.py --leader_address=192.168.1.1 --add_servers=192.168.1.2,192.168.1.3
This completes the startup of the cluster.

Cluster reconfiguration

If we want to remove one of the server out of the cluster, say server B, run following:
./reconfigure.py --leader_address=192.168.1.1 --del_servers=192.168.1.2
This will remove the server B out of the cluster safely.

If for some reason, we want to transfer the leadership to other server in the cluster, say transfer current leader A's leadership to server B, we run following:
./reconfigure.py --leader_address=192.168.1.1 --target_server=192.168.1.2
This will make leader A transfer its leadership to server B stably, A will become a follower once the transfer is complete.

Examples

A trivial key-value replicated store can be easily implemented on top of raftcore, see carrot-kv.

raftcore's People

Contributors

zxjcarrot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.