1、下载地址
https://zookeeper.apache.org/releases.html
http://archive.apache.org/dist/zookeeper/
2、安装前准备
(1)安装jdk,并且是Java6以上版本
(2)通过filezilla工具拷贝Zookeeper到linux系统下
(3)修改tar包权限
[victor@node1 software]$ chmod u+x zookeeper-3.4.10.tar.gz
(4)解压到指定目录
[victor@node1 software]$ tar -xzvf zookeeper-3.4.10.tar.gz -C /opt/module/
(5)配置环境变量
[victor@node1 software]$ sudo vim /etc/profile
##ZOOKEEPER_HOME
export ZOOKEEPER_HOME=/opt/module/zookeeper-3.4.10
export PATH=$PATH:$ZOOKEEPER_HOME/bin
export PATH=$PATH:$ZOOKEEPER_HOME/conf
3、配置修改
(1)进入/opt/module/zookeeper-3.4.10/conf这个路径,将zoo_sample.cfg修改为zoo.cfg;
[victor@node1 ~]$ cd /opt/module/zookeeper-3.4.10/conf/
[victor@node1 conf]$ pwd
/opt/module/zookeeper-3.4.10/conf
[victor@node1 conf]$ mv zoo_sample.cfg zoo.cfg
(2)编辑zoo.cfg文件
[victor@node1 conf]$ vim zoo.cfg
tickTime=2000
dataDir=/opt/module/zookeeper-3.4.10/zkdata
clientPort=2181
(3)在/opt/module/zookeeper-3.4.10/这个目录上创建zkdata文件夹
[victor@node1 conf]$ cd /opt/module/zookeeper-3.4.10/
[victor@node1 zookeeper-3.4.10]$ pwd
/opt/module/zookeeper-3.4.10
[victor@node1 zookeeper-3.4.10]$ mkdir zkdata/
4、操作zookeeper
(1)启动zookeeper
[victor@node1 zookeeper-3.4.10]$ bin/zkServer.sh start
(2)查看进程是否启动
[victor@node1 zookeeper-3.4.10]$ jps
4022 Jps
4034 QuorumPeerMain
(3)查看状态
[victor@node1 zookeeper-3.4.10]$ bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: standalone
(4)启动客户端
[victor@node1 zookeeper-3.4.10]$ bin/zkCli.sh
(5)退出客户端
[zk: localhost:2181(CONNECTED) 0] quit
(6)停止zookeeper
[victor@node1 zookeeper-3.4.10]$ bin/zkServer.sh stop