linux 安装Zookeeper

1、安装JDK 

  参考JDK安装及环境变量配置:https://www.cnblogs.com/xiaoliangup/p/9617206.html

2、安装Zookeeper

2.1、下载zookeeper

网址 https://archive.apache.org/dist/zookeeper/zookeeper-3.4.11/ 

wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz

   2.2、解压

   2.3、移动到指定位置并改名为zookeeper

  

  

  2.4 开机启动zookeeper
#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
ZK_PATH=/usr/local/zookeeper
export JAVA_HOME=/usr/local/java/jdk1.8.0_171
case $1 in
         start) sh  $ZK_PATH/bin/zkServer.sh start;;
         stop)  sh  $ZK_PATH/bin/zkServer.sh stop;;
         status) sh  $ZK_PATH/bin/zkServer.sh status;;
         restart) sh $ZK_PATH/bin/zkServer.sh restart;;
         *)  echo "require start|stop|status|restart"  ;;
esac

把脚本注册为Service

  增加权限

  

  2.5 配置zookeeper

  拷贝/usr/local/zookeeper/conf/zoo_sample.cfg   到同一个目录下改个名字叫zoo.cfg

  

  修改zoo.cfg,并创建data、datalog文件夹

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/opt/module/zookeeper-3.4.11/data
dataLogDir=/opt/module/zookeeper-3.4.11/datalog
# the port at which the clients will connect
clientPort=2181

# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
2.6 启动zookeeper

  启动指令:service zookeeper start

  查看指令:service zookeeper status

 

posted @ 2019-03-23 03:53  小亮的BLOG  阅读(200)  评论(0编辑  收藏  举报