环境
基础篇需要4台机器(一台namenode,三台datanode);
HA篇需要8台机器:两台namenode(一台作active nn,另一台作standby nn),三台datanode,三台zookeeper(也可以省去这三台,把zookeeper daemon部署在其他机器上)。实际上还需要3台journalnode,但因为它比较轻量级,所以这里就把它部署在datanode上了。
三台zookeeper机器上配置以下信息:
1 创建hadoop用户
2 做好ssh免密码登陆
3 修改主机名
4 安装JDK
5 下载zookeeper安装包
下载地址:http://mirror.nus.edu.sg/apache/zookeeper
下载zookeeper-3.4.6到/opt/目录下,解压
6 修改/etc/profile
export ZOO_HOME=/opt/zookeeper-3.4.6
export ZOO_LOG_DIR=/opt/zookeeper-3.4.6/logs
使之生效:
source /etc/profile
7 建立zookeeper数据存放目录:
mkdir /opt/zookeeper-3.4.6/data
8 在$ZOO_HOME/conf下创建配置文件:
vi 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 an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/opt/zookeeper-3.4.6/data
# the port at which the clients will connect
clientPort=2181
server.1=10.9.214.167:31316:31317
server.2=10.9.214.18:31316:31317
server.3=10.9.214.211:31316:31317
9 在/opt/zookeeper-3.4.6/data/目录下创建文件myid,并写入内容,zookeeper1写1,zookeeper2写2,zookeeper3写3 ,如:
echo 1 >/opt/zookeeper-3.4.6/data/myid
10 启动zookeeper 服务:
cd $ZOO_HOME
./bin/zkServer.sh start
11 验证
测试zookeeper集群是否建立成功,在$ZOO_HOME目录下执行以下命令即可,如无报错表示集群创建成功:
./bin/zkCli.sh -server localhost:31315
hadoop配置文件只需要修改core-site.xml和hdfs-site.xml 配置core-site.xml