- 下载zookeeper-3.4.9.tar.gz
[root@localhost application]# wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
如果提示未安装wget(-bash: wget: command not found ) ,则运行 yum install wget -y安装wget
- 解压压缩文件
[root@localhost application]# tar -zxvf zookeeper-3.4.9.tar.gz
- copy配置文件&配置环境变量
进入zookeeper 配置文件目录conf,复制或修改zoo_sample.cfg为zoo.cfg,修改用户家目录下的.bash_profile文件添加环境变量
[root@localhost application]# cd zookeeper-3.4.9/conf/
[root@localhost conf]# cp zoo_sample.cfg zoo.cf
[root@localhost conf]# cd
[root@localhost ~]# vi .bash_profileexport ZOOKEEPER_HOME=/application/zookeeper-3.4.9
PATH=$PATH:$ZOOKEEPER_HOME/bin
export PATH然后执行source命令使环境变量生效
[root@localhost ~]# source .bash_profile
- 启动zookeeper并连接
[root@localhost ~]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /application/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost ~]# zkCli.sh
Connecting to localhost:2181
2016-12-18 13:09:33,900 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.9-1757313,built on 08/23/2016 06:50 GMT
2016-12-18 13:09:33,907 [myid:] - INFO [main:Environment@100] - Client environment:host.name=localhost
2016-12-18 13:09:33,907 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.7.0_79
2016-12-18 13:09:33,910 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2016-12-18 13:09:33,911 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/application/jdk1.7.0_79/jre
2016-12-18 13:09:33,911 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/application/zookeeper-3.4.9/bin/../build/classes:/application/zookeeper-3.4.9/bin/../build/lib/*.jar:/application/zookeeper-3.4.9/bin/../lib/slf4j-log4j12-1.6.1.jar:/application/zookeeper-3.4.9/bin/../lib/slf4j-api-1.6.1.jar:/application/zookeeper-3.4.9/bin/../lib/netty-3.10.5.Final.jar:/application/zookeeper-3.4.9/bin/../lib/log4j-1.2.16.jar:/application/zookeeper-3.4.9/bin/../lib/jline-0.9.94.jar:/application/zookeeper-3.4.9/bin/../zookeeper-3.4.9.jar:/application/zookeeper-3.4.9/bin/../src/java/lib/*.jar:/application/zookeeper-3.4.9/bin/../conf:
2016-12-18 13:09:33,911 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2016-12-18 13:09:33,911 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2016-12-18 13:09:33,911 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA>
2016-12-18 13:09:33,911 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
2016-12-18 13:09:33,911 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2016-12-18 13:09:33,912 [myid:] - INFO [main:Environment@100] - Client environment:os.version=2.6.32-431.el6.x86_64
2016-12-18 13:09:33,912 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root
2016-12-18 13:09:33,912 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root
2016-12-18 13:09:33,912 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/root
2016-12-18 13:09:33,914 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection,connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@517f673b
Welcome to ZooKeeper!
2016-12-18 13:09:33,988 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
2016-12-18 13:09:34,007 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181,initiating session
JLine support is enabled
[zk: localhost:2181(CONNECTING) 0] 2016-12-18 13:09:34,153 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181,sessionid = 0x15910553c0b0000,negotiated timeout = 30000WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0]
[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]
至此,单机安装zookeeper 完成。windows安装步骤也一样,下载、解压、copy配置文件为zoo.cfg、配置环境变量(可略,直接进入安装目录bin下面启动)、启动(zkServer.cmd)。
集群安装可参考zookeeper集群安装
配置文件说明可以参考zookeeper配置文件zoo.cfg常用配置说明.
转帖请注明原文地址 http://www.qiusuolu.com/archives/252
原文链接:https://www.f2er.com/centos/379244.html