发布于 2015-11-07 14:51:29 | 292 次阅读 | 评论: 0 | 来源: PHPERZ
Apache ZooKeeper
ZooKeeper是Hadoop的正式子项目,它是一个针对大型分布式系统的可靠协调系统,提供的功能包括:配置维护、名字服务、分布式同步、组服务等。ZooKeeper的目标就是封装好复杂易出错的关键服务,将简单易用的接口和性能高效、功能稳定的系统提供给用户。
下载zookeeper,http://archive.apache.org/dist/zookeeper/
解压到: /opt/zookeeper-3.4.6下载
把conf下的zoo_sample.cfg copy一份后重命名为: zoo.cfg.文件中内容如下:
syncLimit=5
initLimit=10
tickTime=2000
clientPort=2181
dataDir=/opt/zookeeper-3.4.6/data
dataLogDir=/opt/zookeeper-3.4.6/logs
新建zookeeper-3.4.6下的data,log目录,然后
chmod u+x /opt/zookeeper-3.4.6/bin/*
新建shell脚本startZookeeper.sh在/opt/shell文件夹下,
内容:
#!/bin/sh
#to start zookeeper
#set environment
export ZOOKEEPER_INSTALL=/opt/zookeeper-3.4.6
export PATH=$PATH:$ZOOKEEPER_INSTALL/bin
PID_FILE=$ZOOKEEPER_INSTALL/data/zookeeper_server.pid
FLAG=$1
if [ "$FLAG" = "os_start" ] && [ -f "$PID_FILE" ]
then
rm $PID_FILE
fi
chmod u+x /opt/shell/startZookeeper.sh
#start zookeeper
$ZOOKEEPER_INSTALL/bin/zkServer.sh start
设置zookeeper开机启动
vim /etc/rc.local
在最后一行添加如下两句话
#start zookeeper
/opt/shell/startZookeeper.sh