Linux下Zookeeper安装使用
Posted 冬眠的山谷
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux下Zookeeper安装使用相关的知识,希望对你有一定的参考价值。
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
以上是关于Linux下Zookeeper安装使用的主要内容,如果未能解决你的问题,请参考以下文章