停止服务
代码语言:javascript复制[root@h101 zookeeper-3.4.6]# bin/zkServer.sh stop
JMX enabled by default
Using config: /root/zk/zookeeper-3.4.6/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
[root@h101 zookeeper-3.4.6]# bin/zkServer.sh status
JMX enabled by default
Using config: /root/zk/zookeeper-3.4.6/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
[root@h101 zookeeper-3.4.6]# ps faux | grep zookeeper
root 5853 0.0 0.0 103256 836 pts/2 S 22:11 0:00 _ grep zookeeper
[root@h101 zookeeper-3.4.6]#
客户端连接
使用 bin/zkCli.sh -server 127.0.0.1:2181
进行连接
如果都是默认配置可以不用加
代码语言:javascript复制[root@h101 zookeeper-3.4.6]# bin/zkCli.sh
Connecting to localhost:2181
2015-12-02 22:13:42,629 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2015-12-02 22:13:42,633 [myid:] - INFO [main:Environment@100] - Client environment:host.name=h101.temp
2015-12-02 22:13:42,634 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.7.0_65
2015-12-02 22:13:42,638 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2015-12-02 22:13:42,638 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre
2015-12-02 22:13:42,639 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/root/zk/zookeeper-3.4.6/bin/../build/classes:/root/zk/zookeeper-3.4.6/bin/../build/lib/*.jar:/root/zk/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/root/zk/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/root/zk/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/root/zk/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/root/zk/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/root/zk/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/root/zk/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/root/zk/zookeeper-3.4.6/bin/../conf:
2015-12-02 22:13:42,639 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2015-12-02 22:13:42,639 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2015-12-02 22:13:42,639 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA>
2015-12-02 22:13:42,639 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
2015-12-02 22:13:42,640 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2015-12-02 22:13:42,640 [myid:] - INFO [main:Environment@100] - Client environment:os.version=2.6.32-504.el6.x86_64
2015-12-02 22:13:42,640 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root
2015-12-02 22:13:42,640 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root
2015-12-02 22:13:42,641 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/root/zk/zookeeper-3.4.6
2015-12-02 22:13:42,661 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@7e7f0b4e
Welcome to ZooKeeper!
2015-12-02 22:13:42,713 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
2015-12-02 22:13:42,733 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@852] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
JLine support is enabled
2015-12-02 22:13:42,770 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1235] - Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x151630a4f7e0001, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] help
ZooKeeper -server host:port cmd args
connect host:port
get path [watch]
ls path [watch]
set path data [version]
rmr path
delquota [-n|-b] path
quit
printwatches on|off
create [-s] [-e] path data acl
stat path [watch]
close
ls2 path [watch]
history
listquota path
setAcl path acl
getAcl path
sync path
redo cmdno
addauth scheme auth
delete path [version]
setquota -n|-b val path
[zk: localhost:2181(CONNECTED) 1]