确保已安装java环境
java -version
显示如下
[root@VM-12-15-centos ~]# java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
下载zookeeper安装包
wget http://archive.apache.org/dist/zookeeper/apache-zookeeper-3.6.3-bin.tar.gz
解压安装包
tar zxf apache-zookeeper-3.6.3-bin.tar.gz -C /usr/local/
重命名安装包
cd /usr/local
mv apache-zookeeper-3.6.3-bin/ zookeeper
进入配置文件(刚开始没有zoo.cfg文件,请忽略)
[root@VM-12-15-centos zookeeper]# ls
bin conf docs lib LICENSE.txt logs NOTICE.txt README.md README_packaging.md
[root@VM-12-15-centos zookeeper]# cd conf
[root@VM-12-15-centos conf]# ls
configuration.xsl log4j.properties zoo.cfg zoo_sample.cfg
复制配置文件
cp zoo_sample.cfg zoo.cfg
打开配置文件zoo.cfg
vim zoo.cfg
修改dataDir=/var/lib/zookeeper,并保存退出
dataDir=/var/lib/zookeeper
启动zookeeper
查看启动zookeeper的命令有哪些:zkServer.sh
[root@VM-12-15-centos bin]# zkServer.sh
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Usage: ./zkServer.sh [--config <conf-dir>] {start|start-foreground|stop|version|restart|status|print
-cmd}
采用start-foreground启动
zkServer.sh start-foreground