在hadoop2.0在,datanode数据存储盘选择策略有两种方式复制:

首先是要遵循hadoop1.0磁盘文件夹投票,实现类:RoundRobinVolumeChoosingPolicy.java

另外一种是选择可用空间足够多的磁盘方式存储,实现类:AvailableSpaceVolumeChoosingPolicy.java

选择策略相应的配置项是:

  <property>
<name>dfs.datanode.fsdataset.volume.choosing.policy</name>
<value>org.apache.hadoop.hdfs.server.datanode.fsdataset.AvailableSpaceVolumeChoosingPolicy</value>
</property>

假设不配置。默认使用第一种方式。既轮询选择磁盘来存储数据副本,可是轮询的方式尽管可以保证全部磁盘都可以被使用,可是常常会出现各个磁盘直接数据存储不均衡问题,有的磁盘存储得非常满了,而有的磁盘可能还有非常多存储空间没有得到利用,全部在hadoop2.0集群中。最好将磁盘选择策略配置成另外一种,依据磁盘空间剩余量来选择磁盘存储数据副本,这样一样能保证全部磁盘都能得到利用,还能保证全部磁盘都被利用均衡。

在採用另外一种方式时还有另外两个參数会用到:

dfs.datanode.available-space-volume-choosing-policy.balanced-space-threshold

默认值是10737418240。既10G,一般使用默认值即可,下面是该选项的官方解释:

This setting controls how much DN volumes are allowed to differ in terms of bytes of free disk space before they are considered imbalanced. If the free space of all the
volumes are within this range of each other, the volumes will be considered balanced and block assignments will be done on a pure round robin basis.

意思是首先计算出两个值,一个是全部磁盘中最大可用空间,另外一个值是全部磁盘中最小可用空间,假设这两个值相差小于该配置项指定的阀值时。则就用轮询方式的磁盘选择策略选择磁盘存储数据副本。

源码例如以下:

public boolean areAllVolumesWithinFreeSpaceThreshold() {
long leastAvailable = Long.MAX_VALUE;
long mostAvailable = 0;
for (AvailableSpaceVolumePair volume : volumes) {
leastAvailable = Math.min(leastAvailable, volume.getAvailable());
mostAvailable = Math.max(mostAvailable, volume.getAvailable());
}
return (mostAvailable - leastAvailable) < balancedSpaceThreshold;
}

dfs.datanode.available-space-volume-choosing-policy.balanced-space-preference-fraction

默认值是0.75f。一般使用默认值即可,下面是该选项的官方解释:

This setting controls what percentage of new block allocations will be sent to volumes with more available disk space than others. This setting should be in the range 0.0 - 1.0, though in practice 0.5
- 1.0, since there should be no reason to prefer that volumes with

意思是有多少比例的数据副本应该存储到剩余空间足够多的磁盘上。

该配置项取值范围是0.0-1.0,一般取0.5-1.0,假设配置太小,会导致剩余空间足够的磁盘实际上没分配足够的数据副本,而剩余空间不足的磁盘取须要存储很多其它的数据副本,导致磁盘数据存储不均衡。

參考:

http://www.it165.net/admin/html/201409/3635.html

http://blog.csdn.net/chenpingbupt/article/details/7972589

版权声明:本文博客原创文章。博客,未经同意,不得转载。

最新文章

  1. java servlet+oracle 新手可看
  2. Device ehth0 is not present
  3. 硬盘安装win2003
  4. BestCoder22 1002.NPY and arithmetic progression(hdu 5143) 解题报告
  5. ios WaxPatch热更新原理
  6. NYOJ题目872开会
  7. const 常量数据,只读
  8. Delphi 自带的 Base64 编解码函数
  9. (Struts2)XWork容器的实现机理
  10. pycharm 安装dilb模块
  11. Android App性能测试之一:简介
  12. Codeforces 840D Expected diameter of a tree 分块思想
  13. asp.net MVC jsonp跨域获取数据
  14. SpringBoot笔记十二:缓存
  15. Win10安装CAD2006
  16. Centos下10000次循环测试php对Redis和共享内存(shm)读写效率
  17. Java and C# Comparison
  18. click只能点击一次
  19. 【英宝通Unity4.0公开课学习 】(一)资源管理
  20. linux终端操作快捷键

热门文章

  1. Codeforces Round #198 (Div. 2) C. Tourist Problem (数学+dp)
  2. iOS 获取联系人,并调用系统地址簿UI
  3. Codeforces Round #191 (Div. 2) D. Block Tower
  4. uva 11992 为矩阵更新查询段树
  5. Sliverlight实例之 使用 ControlTemplate 自定义按钮的外观
  6. Swift新手教程3-字符串String
  7. 左右xcode的重构选项的一些理解
  8. ps设计资料整理
  9. 修改字符串中特定的内容,用于OpenRecovery Script
  10. Web Service简单入门示例