歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Zookeeper的Python客戶端安裝

Zookeeper的Python客戶端安裝

日期:2017/2/28 13:55:09   编辑:Linux教程

項目中使用了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.linuxidc.com/Linux/2014-12/110352.htm

CentOS 6安裝sheepdog 虛擬機分布式儲存 http://www.linuxidc.com/Linux/2013-08/89109.htm

ZooKeeper集群配置 http://www.linuxidc.com/Linux/2013-06/86348.htm

使用ZooKeeper實現分布式共享鎖 http://www.linuxidc.com/Linux/2013-06/85550.htm

分布式服務框架 ZooKeeper -- 管理分布式環境中的數據 http://www.linuxidc.com/Linux/2013-06/85549.htm

ZooKeeper集群環境搭建實踐 http://www.linuxidc.com/Linux/2013-04/83562.htm

ZooKeeper服務器集群環境配置實測 http://www.linuxidc.com/Linux/2013-04/83559.htm

ZooKeeper集群安裝 http://www.linuxidc.com/Linux/2012-10/72906.htm

Zookeeper3.4.6的安裝 http://www.linuxidc.com/Linux/2015-05/117697.htm

--------------------------------------分割線 --------------------------------------

Copyright © Linux教程網 All Rights Reserved