Zookeeper入门以及安装

1. Zookeeper安装

安装到3台虚拟机上

安装好JDK

tar -zxvf zookeeper-3.4.5.tar.gz(解压)

mv zookeeper-3.4.5 zookeeper(重命名文件夹zookeeper-3.4.5为zookeeper)

vi /etc/profile

添加内容

export ZOOKEEPER_HOME=/home/hadoop/zookeeper

export PATH=$PATH:$ZOOKEEPER_HOME/bin

3台zookeeper都需要修改source /etc/profile

cd zookeeper/conf
cp zoo_sample.cfg zoo.cfg
/etc/profile

添加内容:


dataDir=/home/hadoop/zookeeper/data

dataLogDir=/home/hadoop/zookeeper/log

server.1=slave1:2888:3888 (主机名, 心跳端口、数据端口)

server.2=slave2:2888:3888

server.3=slave3:2888:3888

创建文件夹

cd /home/hadoop/zookeeper

mkdir -m 755 data

mkdir -m 755 log

在data文件夹下新建myid文件,myid的文件内容为:

cd data

vi myid
scp -r /home/hadoop/zookeeper hadoop@slave2:/home/hadoop/

scp -r /home/hadoop/zookeeper hadoop@slave3:/home/hadoop/

到slave2上:修改myid为:2

到slave3上:修改myid为:3

zkServer.sh start

 

课后作业 1. 简述zookeeper在HBase中的作用 2. 如何获取链接zookeeper的客户端的信息 3. 简述如何用zookeeper实现一个普通的一对多fifo队列 4. 使用伪代码简述mapreduce的流程和中间结果 其中input和output都是fileinputformat和fileoutputformat 5. 编写程序实现倒排索引 首先准备数据:1.txt,文件内容如下: The Apache Hadoop software library is a framework that allows for the distributed processing of large data sets across clusters of computers using simple programming models. It is designed to scale up from single servers to thousands of machines, each offering local computation and storage. Rather than rely on hardware to deliver high-availability, the library itself is designed to detect and handle failures at the application layer, so delivering a highly-available service on top of a cluster of computers, each of which may be prone to failures. 文件2.txt的内容如下所示: In order to scale the name service horizontally, federation uses multiple independent Namenodes/Namespaces. The Namenodes are federated, that is, the Namenodes are independent and don’t require coordination with each other. The datanodes are used as common storage for blocks by all the Namenodes. Each datanode registers with all the Namenodes in the cluster. Datanodes send periodic heartbeats and block reports and handles commands from the Namenodes. 建立类似的文件,放入/test1文件夹下 要求处理结果为: The 1.txt n 2.txt n Apache 1.txt n 2.txt n 其中,n为某个单词在某个文件出现的次数,即,格式解释为:单词iterator<所在文件 出现次数>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值