os redhat 6.4
zookeeper 由JAVA 开发依赖JAVA 包, os 默认安装了JAVA包
1.确认JAVA 包是否安装
$ java -version
java version "1.7.0_09-icedtea"
OpenJDK Runtime Environment (rhel-2.3.4.1.el6_3-x86_64)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)
2.进行zookeeper安装
cd /app/installtar
zxvf zookeeper-3.4.5-cdh4.3.0.tar.gz
mv zookeeper-3.4.5-cdh4.3.0 /tmp/zookeeper
cd /tmp/zookeeper/
mv conf/zoo_sample.cfg conf/zoo.cfg
mkdir data
echo 1 > data/myid
修改bin/zkEnv.sh脚本:
将ZOO_LOG_DIR="."修改为ZOO_LOG_DIR="/tmp/zookeeper/data"
将ZOO_LOG4J_PROP=”INFO,CONSOLE”修改为ZOO_LOG4J_PROP="INFO,ROLLINGFILE"
修改bin/zkServer.sh脚本:
将ZOOBIN="${BASH_SOURCE-$0}"修改为ZOOBIN=`readlink -f "${BASH_SOURCE-$0}"`
修改bin/zkCli.sh脚本:
将ZOOBIN="${BASH_SOURCE-$0}"修改为ZOOBIN=`readlink -f "${BASH_SOURCE-$0}"`
建立软连接到PATH:
ln -s /tmp/zookeeper/bin/zkServer.sh /usr/local/bin/zk-server
ln -s /tmp/zookeeper/bin/zkCli.sh /usr/local/bin/zk-cli
使用如下命令即可启动zookeeper
zk-server start
#以下输出为运行成功
JMX enabled by default
Using config: /tmp/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
/#将本节点id设定到data/myid文件中