Zookeeper的安装配置

参考:

 
直接上命令吧

# cd /usr/local/src
# wget http://mirrors.cnnic.cn/apache/zookeeper/stable/zookeeper-3.4.6.tar.gz
# tar -zxvf zookeeper-3.4.6.tar.gz -C /usr/local/
# cd ../zookeeper-3.4.6/
# mkdir data&&mkdir logs
# cd conf
# sed -e "s/#.*//g" zoo_sample.cfg | awk '{if (length !=0) print $0}' > ./zoo.cfg
# vi zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper-3.4.6/data
dataLogDir=/usr/local/zookeeper-3.4.6/logs
clientPort=2181
server.1=172.16.18.146:2888:3888
server.2=172.16.18.181:2888:3888
server.3=172.16.18.227:2888:3888

cd ../data&&vi myid 键入zoo.cfg配置文件server.X里的X,如上,三个节点分别为1,2,3

修改日志路径
# vi conf/log4j.properties
zookeeper.root.logger=INFO, CONSOLE     >>>     zookeeper.root.logger=INFO,ROLLINGFILE
zookeeper.log.file=zookeeper.log     >>>     zookeeper.log.file=../logs/zookeeper.log
# vi bin/zkEnv.sh
ZOO_LOG4J_PROP="INFO,CONSOLE”     >>>     ZOO_LOG4J_PROP="INFO,ROLLINGFILE"
启动zookeeper
# /usr/local/zookeeper-3.4.6/bin/zkServer.sh start

一个简单的启动脚本,可以软链到/etc/init.d/下

#/bin/sh
#chkconfig: 2345 20 80
# description:  zookeeper
case $1 in
          start)  /usr/local/zookeeper-3.4.6/bin/zkServer.sh start   ;;
          stop)  /usr/local/zookeeper-3.4.6/bin/zkServer.sh stop;;
          status)  /usr/local/zookeeper-3.4.6/bin/zkServer.sh status;;
          restart)  /usr/local/zookeeper-3.4.6/bin/zkServer.sh restart;;
              *)  echo "require start|stop|status|restart"  ;;
esac

另外两个节点大同小异,可以直接拷安装目录过去,再修改myid就行了