zookeeper提供了一个smoke test的工具:zk-smoketest.(https://github.com/phunt/zk-smoketest)
要使用该工具得先准备环境:
本示例中使用的zookeeper版本是zookeeper-3.4.7。
1.因需要使用gcc进行编译,需安装gcc:
yum install gcc
|
2.使用到ant,安装ant:
yum install ant
|
3.zk-smoketest使用的是python客户端,所以如果当前机器未安装python,需要安装python:
4.同时需要安装python-devel,否则会报错:提示找不到Python.h
yum -y install python-devel
|
5.下载zookeeper-3.4.7.tar.gz,放到/opt目录下;
6.使用tar命令解压zookeeper-3.4.7.tar.gz:
tar -zxvf zookeeper-
3.4
.
7
.tar.gz
|
3.进入目录/opt/zookeeper-3.4.7/src/c:
cd /opt/zookeeper-
3.4
.
7
/src/c
|
4.执行编译:
1
2
3
|
./configure
make
sudo make install
|
5.进入目录/opt/zookeeper-3.4.7/src/contrib/zkpython:
cd /opt/zookeeper-
3.4
.
7
/src/contrib/zkpython
|
6.执行ant脚本:
sudo ant install
|
7.成功编译后,环境就准备完毕了。
8.从https://github.com/phunt/zk-smoketest下载zk-smoketest-master.zip存入到/opt目录下;
9.使用unzip命令解压zk-smoketest-master.zip:
unzip zk-smoketest-master.zip
|
10.进入zk-smoketest-master目录:
cd zk-smoketest-master
|
这时就可以使用zk-smokettest了。
-------------------------------------------------------------------------------------------------------------------------------------
使用zk-smoketest.py:
PYTHONPATH=lib.linux-i686-
2.6
LD_LIBRARY_PATH=lib.linux-i686-
2.6
./zk-smoketest.py --servers
"host:port(,host:port)*"
|
具体参数:
Usage: zk-smoketest.py [options]
Options:
-h, --help show
this
help message and exit
--servers=SERVERS comma separated list of host:port (
default
localhost:
2181
)
--config=CONFIGFILE zookeeper configuration file to lookup servers from
--timeout=TIMEOUT session timeout in milliseconds (
default
5000
)
-v, --verbose verbose output, include more detail
-q, --quiet quiet output, basically just success/failure
|
使用zk-latencies.py:
PYTHONPATH=lib.linux-i686-
2.6
LD_LIBRARY_PATH=lib.linux-i686-
2.6
./zk-latencies.py --servers
"host:port(,host:port)*"
|
具体参数:
Usage: zk-latencies.py [options]
Options:
-h, --help show
this
help message and exit
--servers=SERVERS comma separated list of host:port (
default
localhost:
2181
)
--cluster=CLUSTER comma separated list of host:port, test as a cluster,
alternative to --servers
--config=CONFIGFILE zookeeper configuration file to lookup servers from
--timeout=TIMEOUT session timeout in milliseconds (
default
5000
)
--root_znode=ROOT_ZNODE
root
for
the test, will be created as part of test
(
default
/zk-latencies)
--znode_size=ZNODE_SIZE
data size when creating/setting znodes (
default
25
)
--znode_count=ZNODE_COUNT
the number of znodes to operate on in each performance
section (
default
10000
)
--watch_multiple=WATCH_MULTIPLE
number of watches to put on each znode (
default
1
)
--force force the test to run, even
if
root_znode exists -
WARNING! don
't run this on a real znode or you'
ll lose
it!!!
--synchronous by
default
asynchronous ZK api is used,
this
forces
synchronous calls
-v, --verbose verbose output, include more detail
-q, --quiet quiet output, basically just success/failure
|
具体使用请参考:https://github.com/phunt/zk-smoketest
文章参考:
-
http://johnjianfang.blogspot.kr/2014/11/zookeeper-smoke-test.html;
-
https://github.com/phunt/zk-smoketest;
-
http://www.linuxidc.com/Linux/2016-01/127429.htm;