1.hadoop安装如下文:
http://blog.csdn.net/haoxiaoyan/article/details/52523749
2.下载地址:
http://mirror.bjtu.edu.cn/apache/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz
3.zookeepe 安装
① 上传软件并解压
把zookeeper-3.4.8.tar.gz文件存放在/opt/hadoop目录下,进行解压:
[root@masternode hadoop]# tar -zxvf zookeeper-3.4.8.tar.gz
mv zookeeper-3.4.8 zookeeper
---要是单独有自己的用户名则执行下面命令
hadoop@ubuntu:~$ sudo tar -zxvf zookeeper-3.4.8.tar.gz
hadoop@ubuntu:~$ chown -R hadoop:hadoop zookeeper-3.4.8
mv zookeeper-3.4.8 zookeeper
② 设置环境变量 vi /etc/profile
#set zookeeper
export ZOOKEEPER_HOME=/opt/hadoop/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
Vi ~/.bash_profile
#set zookeeper
export ZOOKEEPER_HOME=/opt/hadoop/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
[root@masternode hadoop]# source /etc/profile
[root@masternode hadoop]# cd zookeeper/conf/
[root@masternode conf]# pwd
/opt/hadoop/zookeeper/conf
③ 配置zoo.cfg文件
配置文件存放在$ZOOKEEPER_HOME/conf/目录下,将zoo_sample.cfd文件名称改为zoo.cfg, 缺省的配置内容如下:
[root@masternode conf]# mv zoo_sample.cfg zoo.cfg
vi zoo.cfg
clientPort=2181
dataDir=/opt/hadoop/zookeeper/data/
dataLogDir=/opt/hadoop/zookeeper/log/
server.1=slavenode1:2888:3888
server.2=masternode:2888:3888
server.3=slavenode2:2888:3888
server.4=slavenode3:2888:3888
配置说明:
tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。
④ 新建两个目录
mkdir /opt/hadoop/zookeeper/data/
mkdir /opt/hadoop/zookeeper/log/
在 /opt/hadoop/zookeeper/data/目录下创建一个文件:myid
touch /opt/hadoop/zookeeper/data/myid
[root@masternode data]# echo ‘1’> myid
1
⑤ 将zookeeper目录 和环境变量设置文件拷贝到其他机器上
[root@masternode hadoop]# scp -r zookeeper root@slavenode1:/opt/hadoop/
[root@masternode hadoop]# scp -r zookeeper root@slavenode3:/opt/hadoop/
[root@masternode hadoop]# scp -r zookeeper root@slavenode2:/opt/hadoop/
[root@masternode conf]# scp ~/.bash_profile root@slavenode2:~/.bash_profile
[root@masternode conf]# scp ~/.bash_profile root@slavenode3:~/.bash_profile
[root@masternode conf]# scp ~/.bash_profile root@slavenode1:~/.bash_profile
⑥ 修改其他机器该文件
[root@masternode centos]# cat /opt/hadoop/zookeeper/data/myid
2
[root@slavenode3 centos]# cat /opt/hadoop/zookeeper/data/myid
4
[root@slavenode3 centos]# cat /opt/hadoop/zookeeper/data/myid
3
⑦ 启动zookeeper
cd /opt/hadoop/zookeeper/bin
./zkServer.sh start
⑧ 验证
[root@masternode zookeeper]# jps
16159 HQuorumPeer
14438 DataNode
16397 Jps
14549 NodeManager