1、下载zookeeper
http://mirrors.hust.edu.cn/apache/zookeeper/
2、配置zookeeper
下载完成后,将安装包上传值服务器,解压
tar xvzf zookeeper-3.4.6.tar.gz
进入解压后的目录
cd zookeeper-3.4.6
创建data,logs目录
mkdri data
mkdri logs
找到conf文件夹,进去
cd conf
拷贝一份 zoo_sample.cfg到 zoo.cfg
cp zoo_sample.cfg zoo.cfg
编辑zoo.cfg
扫描二维码关注公众号,回复:
1693838 查看本文章
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/zookeeper-3.4.6/data
dataLogDir=/zookeeper-3.4.6/logs
clientPort=2181
cd /zookeeper-3.4.6/bin
./zkServer.sh start
./zkServer.sh status (查看状态)
./zkServer.sh stop(关闭)
3、开机自启动
3.1、打开环境配置 vim /etc/profile
3.2、添加如下配置:
export ZOOKEEPER_HOME=/opt/zookeeper-3.5.2-alpha
export PATH=$ZOOKEEPER_HOME/bin:$PATH
3.3、使配置生效
source /etc/profile
3.4、
cd /etc/init.d/目录下,创建zookeeper文件
vim zookeeper
- 1
- 脚本内容
#!/bin/bash
export JAVA_HOME=/opt/jdk1.8.0_111
export PATH=$JAVA_HOME/bin:$PATH
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
case $1 in
start) su root /opt/zookeeper-3.5.2-alpha/bin/zkServer.sh start;;
stop) su root /opt/zookeeper-3.5.2-alpha/bin/zkServer.sh stop;;
status) su root /opt/zookeeper-3.5.2-alpha/bin/zkServer.sh status;;
restart) su root /opt/zookeeper-3.5.2-alpha/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 添加权限
chmod +x zookeeper
- 1
- 配置成服务
chkconfig --add zookeeper
- 1
- 开机启动
chkconfig zookeeper on
- 1
- 启动
service zookeeper start
- 1
- 停止
service zookeeper stop
- 1
- 重启
service zookeeper restart
- 1
- 状态
service zookeeper status