1. 下載 下載地址,選擇穩定的版本,比如3.4.13,beta為在測版本 2. 複製到任意的目錄,解壓 3. 修改配置文件 配置文件位於conf目錄下,原配置文件為zoo_sample.cfg,更改為zoo.cfg才能被識別。 在配置文件末尾加上 : server.1=bogon:2888:388 ...
1. 下載
下載地址,選擇穩定的版本,比如3.4.13,beta為在測版本
2. 複製到任意的目錄,解壓
3. 修改配置文件
配置文件位於conf目錄下,原配置文件為zoo_sample.cfg,更改為zoo.cfg才能被識別。
在配置文件末尾加上 : server.1=bogon:2888:3888
4.啟動
在bin目錄下可以看到多個腳本
啟動Server :
./zkServer.sh start
lgj@lgj-Lenovo-G470:~/java/zookeeper-3.4.13/bin$ ./zkServer.sh start ZooKeeper JMX enabled by default Using config: /home/lgj/java/zookeeper-3.4.13/bin/../conf/zoo.cfg Starting zookeeper ... STARTED
啟動客戶端 :
./zkCli.sh
lgj@lgj-Lenovo-G470:~/java/zookeeper-3.4.13/bin$ ./zkCli.sh
Connecting to localhost:2181
2019-01-05 17:35:52,021 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.13-2d71af4dbe22557fda74f9a9b4309b15a7487f03, built on 06/29/2018 04:05 GMT
2019-01-05 17:35:52,026 [myid:] - INFO [main:Environment@100] - Client environment:host.name=lgj-Lenovo-G470
2019-01-05 17:35:52,026 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_191
2019-01-05 17:35:52,028 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2019-01-05 17:35:52,028 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/home/lgj/java/jdk1.8.0_191/jre
2019-01-05 17:35:52,028 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/home/lgj/java/zookeeper-3.4.13/bin/../build/classes:/home/lgj/java/zookeeper-3.4.13/bin/../build/lib/*.jar:/home/lgj/java/zookeeper-3.4.13/bin/../lib/slf4j-log4j12-1.7.25.jar:/home/lgj/java/zookeeper-3.4.13/bin/../lib/slf4j-api-1.7.25.jar:/home/lgj/java/zookeeper-3.4.13/bin/../lib/netty-3.10.6.Final.jar:/home/lgj/java/zookeeper-3.4.13/bin/../lib/log4j-1.2.17.jar:/home/lgj/java/zookeeper-3.4.13/bin/../lib/jline-0.9.94.jar:/home/lgj/java/zookeeper-3.4.13/bin/../lib/audience-annotations-0.5.0.jar:/home/lgj/java/zookeeper-3.4.13/bin/../zookeeper-3.4.13.jar:/home/lgj/java/zookeeper-3.4.13/bin/../src/java/lib/*.jar:/home/lgj/java/zookeeper-3.4.13/bin/../conf:.:/home/lgj/java/jdk1.8.0_191/lib:/home/lgj/java/jdk1.8.0_191/jre/lib
2019-01-05 17:35:52,028 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2019-01-05 17:35:52,028 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2019-01-05 17:35:52,028 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA>
2019-01-05 17:35:52,028 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
2019-01-05 17:35:52,029 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2019-01-05 17:35:52,029 [myid:] - INFO [main:Environment@100] - Client environment:os.version=4.15.0-43-generic
2019-01-05 17:35:52,029 [myid:] - INFO [main:Environment@100] - Client environment:user.name=lgj
2019-01-05 17:35:52,029 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/home/lgj
2019-01-05 17:35:52,029 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/home/lgj/java/zookeeper-3.4.13/bin
2019-01-05 17:35:52,030 [myid:] - INFO [main:ZooKeeper@442] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@25f38edc
Welcome to ZooKeeper!
2019-01-05 17:35:52,075 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1029] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2019-01-05 17:35:52,156 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2019-01-05 17:35:52,177 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1303] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x10004543b410002, negotiated timeout = 30000
WATCHER::
5. 查看命令
help
[zk: localhost:2181(CONNECTED) 2] help
ZooKeeper -server host:port cmd args stat path [watch] set path data [version] ls path [watch] delquota [-n|-b] path ls2 path [watch] setAcl path acl setquota -n|-b val path history redo cmdno printwatches on|off delete path [version] sync path listquota path rmr path get path [watch] create [-s] [-e] path data acl addauth scheme auth quit getAcl path close connect host:port