基于zeromq和raft一致性算法的分布式协调框架。
chillaxd的Python项目详细描述
chillaxd是一个基于zeromq和raft一致性算法的python分布式协调框架。
关于raft的更多细节,您可以阅读斯坦福大学diego ongaro和john ousterhout的In Search of an Understandable Consensus Algorithm。
实施的状态和优先级
- 领导人选举[完成]
- 内存中日志复制[完成]
- 客户端与状态机的交互[进行中]
- 日志持久性[待办事项]
- 日志压缩[待办事项]
- 群集成员资格更改[待办事项]
安装依赖项
$ sudo apt-get install python-pip python-dev python3.4-dev -y
从pypi安装chillaxd
$ pip install chillaxd
从源安装ChillaxD
$ git clone https://github.com/ylamgarchal/chillaxd.git
$ cd chillaxd
$ sudo python setup.py install
运行测试
$ cd chillaxd
$ tox
在同一台计算机上运行三节点群集
首先,打开四个控制台,三个第一控制台将打印服务器日志 而第四个用于运行客户机命令。
$ chillaxd –config-file ./chillaxd_1.conf
2014-12-28 18:44:19,252 :: INFO :: let’s chillax on ‘127.0.0.1:27001’…
$ chillaxd –config-file ./chillaxd_2.conf
2014-12-28 18:44:19,252 :: INFO :: let’s chillax on ‘127.0.0.1:27002’…
$ chillaxd –config-file ./chillaxd_3.conf
2014-12-28 18:44:19,252 :: INFO :: let’s chillax on ‘127.0.0.1:27003’…
现在集群已经启动并运行。日志显示当前的 领袖。让我们试着发送一些命令。
例如,如果当前的leader是监听端口27001的leader。
警告:目前,它是演示复制机制的最低限度客户机。
$ export CHILLAXD_SERVER=127.0.0.1:27001
$ chillax create_node /node_1 data_1
ACK command ‘c154482f-1ba7-4d0c-b8a4-b54d3807e2a2’
我们在根“/”命名“node_1”上创建了一个与数据“data_1”关联的节点,我们 然后可以验证是否在每个服务器上复制了此命令。
$ export CHILLAXD_SERVER=127.0.0.1:27001
$ chillax 127.0.0.1:27001 get_children /
[‘node_1’]
$ export CHILLAXD_SERVER=127.0.0.1:27002
$ chillax 127.0.0.1:27002 get_children /
[‘node_1’]
$ export CHILLAXD_SERVER=127.0.0.1:27003
$ chillax 127.0.0.1:27003 get_children /
[‘node_1’]