http://www.faceye.net/search/80996.html(参考文献)
二、master节点上安装配置
1、下载并解压ZooKeeper-3.4.6.tar.gz放在/opt/hadoop目录
tar -zxvf zookeeper-3.4.6.tar.gz
这里路径为 /opt/hadoop /zookeeper-3.4.6
2、设置the Java heap size (个人感觉一般不需要配置)
保守地use a maximum heap size of 3GB for a 4GB machine
3、$ZOOKEEPER_HOME/conf/zoo.cfg
cp zoo_sample.cfg zoo.cfg
新建此配置文件,并设置内容
# 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 anacknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/opt/hadoop /zookeeper/data/myid
# the port at which the clients will connect
clientPort=2181
server.1=ubuntu2:2888:3888
server.2=ubuntu0:2888:3888
server.3=ubuntu1:2888:3888
server.4=ubuntu4:2888:3888
server.5=ubuntu5:2888:3888
server.6=ubuntu6:2888:3888
server.7=ubuntu7:2888:3888
server.8=ubuntu9:2888:3888
4、/opt/hadoop /zookeeper/data/myid
在节点配置的dataDir指定的目录下面,创建一个myid文件,里面内容为一个数字,用来标识当前主机,$ZOOKEEPER_HOME/conf/zoo.cfg文件中配置的server.X,则myid文件中就输入这个数字X。(即在每个节点上新建并设置文件myid,其内容与zoo.cfg中的id相对应)这里master节点为 1
mkdir -p /opt/hadoop/zookeeper/data
cd /opt/hadoop/zookeeper/data
touch myid
echo"1" >myid
三、从master节点分发文件到其他节点
1、在master节点的/opt/hadoop目录下
scp -r zookeeper-3.4.6 ubuntu0: /opt/hadoop
scp -r zookeeper-3.4.6 ubuntu1: /opt/hadoop
………
2、在ubuntu0节点的/opt/hadoop目录下
vi . /zookeeper-3.4.6 /data /myid
修改为 2
3、在ubuntu3节点的/home/fesh/目录下
vi . /zookeeper-3.4.6 /data /myid
修改为 1
…………….
四、其他配置
1、在每个节点配置/etc/hosts (并保证每个节点/etc/hostname中分别为 主机 -IP地址映射
10.28.23.116 ubuntu0
10.28.23.117 ubuntu1
10.28.23.111 ubuntu3
10.28.23.113 ubuntu4
10.28.23.115 ubuntu2
10.28.23.135 ubuntu5
10.28.23.125 ubuntu6
10.28.23.128 ubuntu7
10.28.23.121 ubuntu9
2、在每个节点配置环境变量/etc/profile
#Set ZOOKEEPER_HOME ENVIRONMENT
export ZOOKEEPER_HOME=/opt/hadoop/zookeeper-3.4.6
export PATH=$PATH:$ZOOKEEPER_HOME/bin
五、启动
在每个节点上$ZOOKEEPER_HOME目录下,运行(这里的启动顺序为 ubntu2 > ubuntu0> ubuntu1…. )
bin/zkServer.sh start
并用命令查看启动状态
bin/zkServer.sh status