如果只有3台主机,可以按照如下规划来部署安装
weekend01 zookeeper journalnode namenode zkfc resourcemanager datanode
weekend02 zookeeper journalnode namenode zkfc resourcemanager datanode
hadoop2.0已经发布了稳定版本了,增加了很多特性,比如HDFS HA、YARN等。最新的hadoop-2.4.1又增加了YARN HA
注意:apache提供的hadoop-2.4.1的安装包是在32位操作系统编译的,因为hadoop依赖一些C++的本地库,所以如果在64位的操作上安装hadoop-2.4.1就需要重新在64操作系统上重新编译,建议第一次安装用32位的系统,我将编译好的64位的也上传到群共享里了,如果有兴趣的可以自己编译一下)
1.在hadoop2.0中通常由两个NameNode组成,一个处于active状态,另一个处于standby状态。Active NameNode对外提供服务,而Standby NameNode则不对外提供服务,仅同步active namenode的状态,以便能够在它失败时快速进行切换。
hadoop2.0官方提供了两种HDFS HA的解决方案,一种是NFS,另一种是QJM。这里我们使用简单的QJM。在该方案中,主备NameNode之间通过一组JournalNode同步元数据信息,一条数据只要成功写入多数JournalNode即认为写入成功。通常配置奇数个JournalNode
这里还配置了一个zookeeper集群,用于ZKFC(DFSZKFailoverController)故障转移,当Active NameNode挂掉了,会自动切换Standby NameNode为standby状态
2.hadoop-2.2.0中依然存在一个问题,就是ResourceManager只有一个,存在单点故障,hadoop-2.4.1解决了这个问题,有两个ResourceManager,一个是Active,一个是Standby,状态由zookeeper进行协调
首先要准备好三台服务器,安装和配置好所有需要的软件和配置
前期准备就不详细说了
######注意######如果你们公司是租用的服务器或是使用的云主机(如华为用主机、阿里云主机等)
/etc/hosts里面要配置的是内网IP地址和主机名的映射关系
接着我们配置ssh免密登录,我们要怎么配置免密登录呢?
1)我们在一个namenode启动start脚本的时候,会ssh启动standby的namenode,然后读取一个文件查看slave的位置是哪里,然后一个一个去ssh启动datanode
2)我们启动yarn的一个resourcemanage的start脚本的时候,会ssh启动standby的resourcemanage,然后读取一个文件查看,然后一个一个去ssh'启动nodemanage
集群的安装步骤:
1.安装配置zooekeeper集群 --weekend01
tar -zxvf zookeeper-3.4.5.tar.gz -C /weekend/
cd /weekend/zookeeper-3.4.5/conf/
# 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=/rootzookeeper/data
dataLogDir=/root/zookeeper/logs
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
说明:
- dataDir 和 dataLogDir 需要在启动前创建完成
- clientPort 为 zookeeper的服务端口
- server.0、server.1、server.2 为 zk 集群中三个 node 的信息,定义格式为 hostname:port1:port2,其中 port1 是 node 间通信使用的端