zookeeper环境配置(python 客户端)

 通过shell连接ckServer

Once ZooKeeper is running, you have several options for connection to it:

Java: Use

bin/zkCli.sh -server 127.0.0.1:2181

Once you have connected, you should see something like:

Connecting to localhost:2181
log4j:WARN No appenders could be found for logger (org.apache.zookeeper.ZooKeeper).
log4j:WARN Please initialize the log4j system properly.
Welcome to ZooKeeper!
JLine support is enabled
[zkshell: 0]
        

From the shell, type help to get a listing of commands that can be executed from the client, as in:

[zkshell: 0] help
ZooKeeper host:port cmd args
        get path [watch]
        ls path [watch]
        set path data [version]
        delquota [-n|-b] path
        quit
        printwatches on|off
        createpath data acl
        stat path [watch]
        listquota path
        history
        setAcl path acl
        getAcl path
        sync path
        redo cmdno
        addauth scheme auth
        delete path [version]
        setquota -n|-b val path

        

From here, you can try a few simple commands to get a feel for this simple command line interface. First, start by issuing the list command, as in ls, yielding:

 

安装C客户端

zookeeper的客户端就在zk server的包中。/duitang/dist/sys/zookeeper-3.4.5/src/c

执行

./configure --prefix=/home/yunpeng.jiangyp/sys/zk_client
make
make install

  

# 然后下载zkpython
wget http://pypi.python.org/packages/source/z/zkpython/zkpython-0.4.tar.gz#md5=3de220615aaddf57f1462b78d32477f9
tar xzvf zkpython-0.4.tar.gz
cd zkpython-0.4
python setup.py install

或者

 pip install zkpython

参考:http://blog.csdn.net/lengzijian/article/details/9227005

运行cli_mt报错

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

解决:
对zk的src/c三板斧之后, /usr/local/lib下应该有了相应的so
在/etc/profile里塞了以下export:
export LD_LIBRARY_PATH=/usr/local/lib
问题解决。

解决找不到头文件的问题,修改setup.py

zookeepermodule = Extension("zookeeper",
                            sources=["zookeeper.c"],
                            include_dirs=["/usr/include/c-client-src", "/usr/local/include/c-client-src","/home/yunpeng.jiangyp/sys/zk_client/include/zookeeper","/home/yunpeng.jiangyp/sys/zk_client/lib"],
                            libraries=["/home/yunpeng.jiangyp/sys/zk_client/lib/zookeeper_mt"],
                            )

setup( name="zkpython",
       version = "0.4",
       description = "ZooKeeper Python bindings",
       ext_modules=[zookeepermodule] )

猜你喜欢

转载自san-yun.iteye.com/blog/1973553
今日推荐