文章来源:http://blog.csdn.net/u010183402/article/details/72998411
需求:
在 centos 系统中使用Python2.7操控ZooKeeper
pip install zkpython
报异常:
error: command 'gcc' failed with exit status 1
原因:
zookeeper python客户端依赖c客户端,所以要先安装c版本客户端
操作:
1、安装 zookeeper c 客户端
> wget -c http://apache.fayea.com/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
> tar -zxvf zookeeper-3.4.10.tar.gz
> cd zookeeper-3.3.6/src/c
> ./configure
> make
> make install
2、测试 c 客户端
> cli_mt localhost:2181
Watcher -1 state = CONNECTED_STATE
Got a new session id: 0x153efa28d380346
> ls /
time = 0 msec
/: rc = 0
otter
zookeeper
time = 0 msec
3、安装 zkpython
pip install zkpython
4、测试zkpython
> python2.7
>>> import zookeeper
>>> hander = zookeeper.init("localhost:2181")
>>> zookeeper.get_children(hander, "/")
['otter', 'zookeeper']
5、其他 API 自行查文档
> pydoc zookeeper
完成~