接着上篇:https://my.oschina.net/u/988386/blog/802045
上篇安装完成了hadoop,接下来安装zookeeper。
安装zookeeper (2台机器配置基本相同)
#!/bin/bash
PATH_FILE="/etc/profile" #安装包路径 ZOOKEEPER_TAR="/home/hdp/Downloads/zookeeper-3.4.9.tar.gz" ZOOKEEPER_INSTALL_HOME="/usr/local"
#安装zookeeper
if [ -d $ZOOKEEPER_INSTALL_HOME/zookeeper ] then sudo rm -rf $ZOOKEEPER_INSTALL_HOME/zookeeper fi
#解压zookeeper sudo tar -zxvf $ZOOKEEPER_TAR -C $ZOOKEEPER_INSTALL_HOME
#修改文件名称 sudo mv $ZOOKEEPER_INSTALL_HOME/zookeeper-3.4.9 $ZOOKEEPER_INSTALL_HOME/zookeeper
#将所有者修改为hadoop sudo chown -R hadoop $ZOOKEEPER_INSTALL_HOME/zookeeper
#设置环境变量 if [ -z $ZOOKEEPER_HOME ]
then sudo echo "export ZOOKEEPER_HOME="$ZOOKEEPER_INSTALL_HOME/zookeeper"" >> $PATH_FILE sudo echo "export PATH="${ZOOKEEPER_HOME}/bin:$PATH"" >> $PATH_FILE #刷新环境变量 source /etc/profile fi配置
修改/conf/zoo_sample.cfg文件名为 zoo.cfg.
dataDir=/usr/local/zookeeper/data
server.0=d155:2888:3888
server.1=d156:2888:3888
在/usr/local/zookeeper/ 目录 建立文件夹data
然后在data文件夹下建立文件 myid
文件内容: d155机器为0,d156机器为 1,分别对应(server.*).
启动、停止
hadoop@d155$/usr/local/zookeeper/bin/zkServer.sh start hadoop@d155$/usr/local/zookeeper/bin/zkServer.sh stop hadoop@d155$/usr/local/zookeeper/bin/zkServer.sh status