zookeeper的python客户端安装

时间:2022-04-24 21:18:08

由于服务很多都是python写的,这里需要安装python客户端,所以记录下安装过程


1.由于python客户端依赖c的客户端所以要先安装c版本的客户端

cd zookeeper-3.4.5/src/c
./configure
make
make install

2.测试c版本客户端

./cli_mt localhost:2181
Watcher SESSION_EVENT state = CONNECTED_STATE
Got a new session id: 0x23f9d77d3fe0001

3.可以执行以下命令进行测试

Here's a list of command supported by the cli shell:

ls <path> -- list children of a znode identified by <path>. The
command set a children watch on the znode.
get <path> -- get the value of a znode at <path>
set <path> <value> -- set the value of a znode at <path> to <value>
create [+e|+s] <path> -- create a znode as a child of znode <path>;
use +e option to create an ephemeral znode,
use +s option to create a znode with a sequence number
appended to the name. The operation will fail if
the parent znode (the one identified by <path>) doesn't
exist.
delete <path> -- delete the znode at <path>. The command will fail if the znode
has children.
sync <path> -- make sure all pending updates have been applied to znode at <path>
exists <path> -- returns a result code indicating whether the znode at <path>
exists. The command also sets a znode watch.
myid -- prints out the current zookeeper session id.
quit -- exit the shell.

4.看到以上信息说明c版本的客户端已经安装好了,下面安装python版本客户端

5.下载python扩展包,并且解压:

https://pypi.python.org/pypi/zkpython/0.4.2

6.如果找不到Pyhon.h,可能由于没有安装python26-devel

32位直接运行
yum install python26-devel.i386

7.测试是否成功

import zookeeper