1.官网下载地址
http://apache.org/dist/zookeeper/
2. 安装
创建数据及日志目录
cd /**/zookeeper-3.4.6
mkdir data
mkdir logs
创建配置文件
cd /**/zookeeper-3.4.6/conf/
#拷贝配置文件并改名为zoo.cfg
cp zoo_sample.cfg zoo.cfg
修改zoo.cfg配置 vim zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/**/zookeeper-3.4.6/data
dataLogDir=/**/zookeeper-3.4.6/logs
clientPort=2181
配置环境变量
# 打开环境配置
vim /etc/profile
# 增加如下配置
export ZOOKEEPER_HOME=/**/zookeeper-3.4.6
PATH=$ZOOKEEPER_HOME/bin:$PATH
# 生效配置source /etc/profile
3.服务配置
cd /etc/init.d/目录下,创建zookeeper文件
vim zookeeper
脚本内容
#!/bin/bash
export JAVA_HOME=/java/jdk1.8
export PATH=$JAVA_HOME/bin:$PATH
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
case $1 in
start) su root /**/zookeeper-3.4.6/bin/zkServer.sh start;;
stop) su root /**/zookeeper-3.4.6/bin/zkServer.sh stop;;
status) su root /**/zookeeper-3.4.6/bin/zkServer.sh status;;
restart) su root /**/zookeeper-3.4.6/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac
添加权限
chmod +x zookeeper
配置成服务
chkconfig --add zookeeper
开机启动
chkconfig zookeeper on
启动
service zookeeper start
停止
service zookeeper stop
重启
service zookeeper restart
状态
service zookeeper status