设为首页 收藏本站
查看: 969|回复: 0

[经验分享] Hadoop学习笔记02--HDFS Federation

[复制链接]
累计签到:4 天
连续签到:1 天
发表于 2015-7-12 12:08:10 | 显示全部楼层 |阅读模式
  原文地址:http://hadoop.apache.org/common/docs/current/hadoop-yarn/hadoop-yarn-site/Federation.html
  这篇文章提供了HDFS Federation特性的概览,以及如何配置和管理联合集群。



背景

  HDFS主要分为以下2层:


  • 命名空间

    • 由目录、文件和块组成
    • 支持与之关联的文件系统操作,例如新建、删除、修改和列出文件/目录


  • 块存储服务分为2部分:

    • 块管理(由Namenode完成)

      • Provides datanode cluster membership by handling registrations, and periodic heart beats.
      • 处理块报告和维护块位置
      • 支持与块相关的操作,例如:创建、删除、修改和取得块的位置。
      • Manages replica placement and replication of a block for under replicated blocks and deletes blocks that are over replicated.


    • 存储 - Datanode提供在本地文件系统存储块,并允许读/写访问。
      早期的HDFS体系结构只允许在整个集群中有一个命名空间。仅有一个Namenode管理这个命名空间。HDFS Federation通过为HDFS文件系统添加支持多Namenodes/namespace的功能解决了早期体系结构对于寻址的局限性。





多Namenodes/Namespaces
  In order to scale the name service horizontally, federation uses multiple independent Namenodes/namespaces. Namenodes是被联合在一起的,也就是说,Namenodes是独立的而且相互之间是不许配合的。对于所有Namenode,Datanode作为通用存储空间用于存储块。每一个Datanode都向集群中所有Namenode登记。Datanode定期发送心跳和块报告,并处理Namenode发送的命令。


Block Pool
  一个Block Pool是一个仅属于一个命名空间的块的集合。集群中Datanode存储所有Block Pool中的块。一个Block Pool是独立于其他块池而管理的。这就允许一个命名空间为新块生成Block ID时不需与其他命名空间协调。一个失效的Namenode不能够阻止服务于集群中其他Namenode的Datanode。
  一个Namespace以及其Block Pool一起被称为Namespace Volume。It is a self-contained unit of management. 当一个Namenode/namespace被删除,Datanode上与其相对应的块池也会被删除。Each namespace volume is upgraded as a unit, during cluster upgrade.

ClusterID
  添加了一个新的标识符ClusterID用于标识集群中所有的节点。当格式化一个Namenode,需要提供这个标识符或者自动生成。这个ID可以被用来格式化加入集群的其他Namenode。



Key Benefits


  • 命名空间的可扩展性 - HDFS cluster storage scales horizontally but the namespace does not. Large deployments or deployments using lot of small files benefit from scaling the namespace by adding more Namenodes to the cluster
  • 性能 - 在早期体系架构中文件系统操作的吞吐量是有限的。集群中添加更多的Namenode会提升文件系统读/写操作的吞吐量。
  • 隔离 - 仅有一个Namenode无法提供多用户环境的隔离。An experimental application can overload the Namenode and slow down production critical applications. With multiple Namenodes, different categories of applications and users can be isolated to different namespaces.



Federation的配置
  Federation configuration is backward compatible and allows existing single Namenode configuration to work without any change. The new configuration is designed such that all the nodes in the cluster have same configuration without the need for deploying different configuration based on the type of the node in the cluster.
  A new abstraction called NameServiceID is added with federation. The Namenode and its corresponding secondary/backup/checkpointer nodes belong to this. To support single configuration file, the Namenode and secondary/backup/checkpointer configuration parameters are suffixed with NameServiceID and are added to the same configuration file.



Configuration
  第一步: 将参数dfs.federation.nameservices添加到配置中。NameServiceID用逗号分隔。这个配置项被Datanode用于确定集群中的所有的Namenode。
  第二步: 对于每一个Namenode和Secondary Namenode/BackupNode/Checkpointer, 在共有配置文件中添加如下配置。这些配置的后缀为其对应的NameServiceID。

守护进程配置参数

Namenode
dfs.namenode.rpc-address dfs.namenode.servicerpc-address dfs.namenode.http-address dfs.namenode.https-address dfs.namenode.keytab.file dfs.namenode.name.dir dfs.namenode.edits.dir dfs.namenode.checkpoint.dir dfs.namenode.checkpoint.edits.dir


Secondary Namenode
dfs.namenode.secondary.http-address dfs.secondary.namenode.keytab.file


BackupNode
dfs.namenode.backup.address dfs.secondary.namenode.keytab.file
  下面的示例是配置2个Namenode:





dfs.federation.nameservices
ns1,ns2


dfs.namenode.rpc-address.ns1
nn-host1:rpc-port


dfs.namenode.http-address.ns1
nn-host1:http-port


dfs.namenode.secondaryhttp-address.ns1
snn-host1:http-port


dfs.namenode.rpc-address.ns2
nn-host2:rpc-port


dfs.namenode.http-address.ns2
nn-host2:http-port


dfs.namenode.secondaryhttp-address.ns2
snn-host2:http-port

.... Other common configuration ...



格式化Namenodes
  第一步: 使用如下命令格式化一个Namenode:



> $HADOOP_PREFIX_HOME/bin/hdfs namenode -format [-clusterId ]
  选择一个唯一的cluster_id,并且这个cluster_id不能与环境中其他集群有冲突。如果没有提供cluster_id,则会自动生成一个唯一的ClusterID。
  第二步: 使用如下命令格式化其他Namenode:



> $HADOOP_PREFIX_HOME/bin/hdfs namenode -format -clusterId
  注意:步骤2中的cluster_id必须与步骤1中的cluster_id一致。如果它们是不同的,则剩余的Namenode将不会成为联合集群的一部分。



升级到0.23版本并配置federation
  旧版本支持单个Namenode。通过下面的操作启用federation:
  第一步: 升级集群至最新版本。在升级过程中需要提供一个ClusterID,例如:



> $HADOOP_PREFIX_HOME/bin/hdfs start namenode --config $HADOOP_CONF_DIR  -upgrade -clusterId
  如果没有提供ClusterID,则会自动生成一个ClusterID。



为已存在的HDFS集群添加一个新的Namenode
  步骤如下:


  • 配置参数dfs.federation.nameservices。
  • NameServiceID后缀更新配置。在0.20版本之后配置项的名称已经更改。对于federation,必须使用新的配置参数。
  • 将与配置相关的新的Namenode添加到配置文件中。
  • 将配置文件传播的集群中所有的节点上。
  • 启动新的Namenode、Secondary/Backup。
  • 刷新Datanode收集新添加的Namenode,执行命令如下:


    > $HADOOP_PREFIX_HOME/bin/hdfs dfadmin -refreshNameNode :
  • 上述命令必须在集群中所有的Datanode上运行。



管理集群



启动和停止集群
  运行如下命令启动集群:



> $HADOOP_PREFIX_HOME/bin/start-dfs.sh
  运行如下命令停止集群:



> $HADOOP_PREFIX_HOME/bin/stop-dfs.sh
  These commands can be run from any node where the HDFS configuration is available. The command uses configuration to determine the Namenodes in the cluster and starts the Namenode process on those nodes. The datanodes are started on nodes specified in the slaves file. The script can be used as reference for building your own scripts for starting and stopping the cluster.



Balancer
  Balancer has been changed to work with multiple Namenodes in the cluster to balance the cluster. 使用如下命令执行Balancer:



"$HADOOP_PREFIX"/bin/hadoop-daemon.sh --config $HADOOP_CONF_DIR --script "$bin"/hdfs start balancer [-policy ]
  策略如下:


  • node - 这是默认的策略。这个是在Datanode级的均衡存储空间策略。这与之前版本的均衡策略类似。
  • blockpool- 这个是在Block Pool级的均衡存储空间策略。Balancing at block pool level balances storage at the datanode level also.  注意Balancer仅仅是均衡数据而不是均衡命名空间。




Decommissioning
  Decommissioning is similar to prior releases. The nodes that need to be decomissioned are added to the exclude file at all the Namenode. Each Namenode decommissions its Block Pool. When all the Namenodes finish decommissioning a datanode, the datanode is considered to be decommissioned.
  第一步: To distributed an exclude file to all the Namenodes, use the following command:



"$HADOOP_PREFIX"/bin/distributed-exclude.sh
  第二步: Refresh all the Namenodes to pick up the new exclude file.



"$HADOOP_PREFIX"/bin/refresh-namenodes.sh
  The above command uses HDFS configuration to determine the Namenodes configured in the cluster and refreshes all the Namenodes to pick up the new exclude file.



Cluster Web Console
  与Namenode状态页面类似,federation中添加了一个用于监控联合集群的Web控制台,访问地址为:http:///dfsclusterhealth.jsp。可以用任何一个集群中的Namenode来访问这个页面。
  页面提供如下信息:


  • 集群的概要信息,包括文件的数量、块的数量、整个集群中可配置的存储容量、可用的和已用的存储空间信息。
  • 提供Namenode列表,以及每一个Namenode的概况,包括:文件、块、故障块的数量,以及live和dead的Datanode。它还提供一个方便访问Namenode web UI的链接。
  • 提供处于decommissioning状态的Datanode。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-85808-1-1.html 上篇帖子: Hadoop琐记 下篇帖子: Hadoop,MapReduce,参数
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表