Zookeeper的Python客户端安装

项目中使用了Python,需要使用到Zookeeper的功能,这里记录一下安装过程。

内核版本:2.6.32

发行版:CentOS-6.6 64bit

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

[root@rocket c]# cd /usr/local/zookeeper-3.4.6/src/c

[root@rocket c]# ./configure

[root@rocket c]# make

[root@rocket c]# make install

2、测试c客户端

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

3、下载python扩展包,并且解压

[root@rocket local]wget https://pypi.python.org/pypi/zkpython/0.4.2

[root@rocket local]# tar -zxvf zkpython-0.4.2.tar.gz

如果找不到Python.h,可能由于没有安装python-devel

[root@rocket zkpython-0.4.2]# yum -y install python-devel

4、测试是否成功

[root@rocket zookeeper]# cat zk_test.py

import zookeeper

[root@rocket zookeeper]# python zk_test.py

提示找不到libzookeeper_mt.so.2,将libzookeeper_mt.so.2的路径加入到LD_LIBRARY_PATH中

[root@rocket zookeeper]# python zk_test.py

Traceback (most recent call last):

File “zk_test.py”, line 1, in <module>

import zookeeper

File “build/bdist.linux-x86_64/egg/zookeeper.py”, line 7, in <module>

File “build/bdist.linux-x86_64/egg/zookeeper.py”, line 6, in __bootstrap__

ImportError: libzookeeper_mt.so.2: cannot open shared object file: No such file or directory

[root@rocket zookeeper]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

再次测试

[root@rocket zookeeper]# python zk_test.py

没报错,说明已经成功安装。

————————————–分割线 ————————————–

Ubuntu 14.04安装分布式存储Sheepdog+ZooKeeper http://www.68idc.cn/Linux/2014-12/110352.htm

CentOS 6安装sheepdog 虚拟机分布式储存 http://www.68idc.cn/Linux/2013-08/89109.htm

ZooKeeper集群配置 http://www.68idc.cn/Linux/2013-06/86348.htm

使用ZooKeeper实现分布式共享锁 http://www.68idc.cn/Linux/2013-06/85550.htm

分布式服务框架 ZooKeeper — 管理分布式环境中的数据 http://www.68idc.cn/Linux/2013-06/85549.htm

ZooKeeper集群环境搭建实践 http://www.68idc.cn/Linux/2013-04/83562.htm

ZooKeeper服务器集群环境配置实测 http://www.68idc.cn/Linux/2013-04/83559.htm

ZooKeeper集群安装 http://www.68idc.cn/Linux/2012-10/72906.htm

Zookeeper3.4.6的安装 http://www.68idc.cn/Linux/2015-05/117697.htm

————————————–分割线 ————————————–

唯有讲述此间途经的美景,分享没有男主角的相片。

Zookeeper的Python客户端安装

相关文章:

你感兴趣的文章:

标签云: