1、将按安装包传入/usr/local/目录下并解压
#或者直接在线下载
wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
tar -zxvf zookeeper-3.4.6.tar.gz
2、进入zookeeper-3.4.6目录,创建logs,data目录并赋权
mkdir logs
mkdir data
chmod -R 777 logs
chmod -R 777 data
3、修改启动配置文件
#将zoo***.cfg改名为zoo.cfg
mv zoo***.cfg zoo.cfg
#修改配置文件
vim zoo.cfg
#修改数据存储位置
dataDir=/usr/local/zookeeper-3.4.6/data
#修改log存储位置
datalogDir=/usr/local/zookeeper-3.4.6/logs
4、启动
#在bin目录下
zkServer.sh start
5、配置开机自启
#1、在、etc/init.d目录下新建启动脚本
vim /etv/init.d/zookeeper
#2、写入如下内容
#########################################################
#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
export JAVA_HOME=/home/java/jdk1.8.0_161
case $1 in
start) su root /usr/local/zookeeper-3.4.6/bin/zkServer.sh start;;
stop) su root /usr/local/zookeeper-3.4.6/bin/zkServer.sh stop;;
status) su root /usr/local/zookeeper-3.4.6/bin/zkServer.sh status;;
restart) su root /usr/local/zookeeper-3.4.6/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac
########################################################
#3、赋权
chmod -R 777 /etv/init.d/zookeeper
#4、测试
service zookeeper stop
service zookeeper start
#5、添加开机自启
chkconfig --add zookeeper