hadoop上下架datanode

hadoop中的hdfs文件系统,可以动态的增加、删除节点,增加比较容易,在新的节点上配置好hadoop的各种xml文件后,直接启动即可。为了平衡集群内各个datanode节点平衡,可以执行hdfs中的balancer命令,使用方式如下:

$ hdfs balancer --help
Usage: java Balancer
        [-policy <policy>]      the balancing policy: datanode or blockpool
        [-threshold <threshold>]        Percentage of disk capacity
        [-exclude [-f <hosts-file> | comma-sperated list of hosts]]     Excludes the specified datanodes.
        [-include [-f <hosts-file> | comma-sperated list of hosts]]     Includes only the specified datanodes.

为了防止运行balancer命令时多度占用集群带宽,可以在hdfs-site.xml配置如下参数:

<property>
  <name>dfs.datanode.balance.bandwidthPerSec</name>
  <value>1048576</value>
  <description>
        Specifies the maximum amount of bandwidth that each datanode
        can utilize for the balancing purpose in term of
        the number of bytes per second.
  </description>
</property>

可以看到,在hadoop2.6.0版本中,默认配置为1048576b / 1024 / 1024=1M/s

下线datanode节点则相对较麻烦,因为需要保证要下架的机器中的数据拷贝到集群其他节点中,所以不能够直接关闭节点来达到下线的目标。具体步骤如下:
1. 修过namenode的hdfs-site.xml文件,增加如下配置

<property>
  <name>dfs.hosts.exclude</name>
  <value></value>
  <description>Names a file that contains a list of hosts that are
  not permitted to connect to the namenode.  The full pathname of the
  file must be specified.  If the value is empty, no hosts are
  excluded.</description>
</property> 

这里的value为一个包含要下架机器的文件列表,比如要下架的机器hostname为:foo、bar两台,这个文件的位置为/etc/hadoop/conf/dfs.exclude,那么该文件中的内容则为:

foo
bar

一个hostname占一行。
2. 执行hdfs dfsadmin -refreshNodes,来让namenode重启读取配置文件
3. 执行hdfs dfsadmin -report命令,查看要下架机器的状态
Decommission Status : Decommission in progress 表示正在向集群内其他节点拷贝数据.拷贝完成后,状态变为Decommissioned时,说明要下降机器中的数据已经拷贝到其他机器中
4. 停掉datanode。$HADOOP_HOME/sbin/hadoop-daemon.sh stop datanode
5. 去掉步骤1添加的配置项,再次执行hdfs dfsadmin -refreshNodes

参考:
http://hadoop.apache.org/docs/r2.6.0/hadoop-project-dist/hadoop-hdfs/H...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值