HDFS副本存放策略(官方文档)

HDFS副本存放策略(官方文档)

关于HDFS的副本位置默认存放策略(以3个副本为例),网络上一直流传着两种说法;

第一种说法:

副本1:在client端所处的节点(就近),若客户端在集群外则随机选一个;
副本2:和第一个副本位于相同机架的不同节点上;
副本3:跨机架随机挑选一个节点,增加副本的可靠性;

第二种说法:

副本1:在client端所处的节点(就近),若客户端在集群外则随机选一个DataNode;
副本2:和第一个副本位于不同机架的一个节点上;
副本3:和第二个副本相同机架的不同节点上;

看起来这两种说法好像都有道理(都保证了数据的可靠性和带宽的利用率),不知道应该以哪个为准,为了得到更加准确的答案,我查阅了一下Hadoop领域比较经典的书籍《Hadooop权威指南第4版》,原文如下:
在这里插入图片描述
在这里插入图片描述
但是书中的内容可能并不是最新的内容,很有可能Hadoop官方更新了一部分内容,但是书籍还没来得及更新,所以我又在Hadoop的官网上找了一下,以下是官网原文(https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html):

For the common case, when the replication factor is three, HDFS’s placement policy is to put one replica on the local machine if the writer is on a datanode, otherwise on a random datanode in the same rack as that of the writer, another replica on a node in a different (remote) rack, and the last on a different node in the same remote rack. This policy cuts the inter-rack write traffic which generally improves write performance. The chance of rack failure is far less than that of node failure; this policy does not impact data reliability and availability guarantees. However, it does reduce the aggregate network bandwidth used when reading data since a block is placed in only two unique racks rather than three. With this policy, the replicas of a file do not evenly distribute across the racks. One third of replicas are on one node, two thirds of replicas are on one rack, and the other third are evenly distributed across the remaining racks. This policy improves write performance without compromising data reliability or read performance.

《Hadooop权威指南第4版》和官网原文相互印证,至此,我们基本可以得出结论,关于副本存放策略的说法,第一种是错误的,第二种是正确的。

(至于为什么会有第一种说法的存在,一些网友给出的理由是版本问题,不同的Hadoop版本的副本分配策略也不同,但是我在官网上没有找到之前版本的分配策略,如果有哪位朋友知道为什么会有第一种说法的存在,欢迎留言讨论。)

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值