一.HDFS Replica Placement policy
如果副本摆放的机制不好的话,在计算的过程当中,很大可能会数据的传输,这样对于带宽,磁盘的IO影响是很大的。
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, another replica on a node in a different (remote) rack, and the last on a different node in the same remote rack.
HDFS的放置策略是,如果写入器位于datanode上,则将一个副本放在本地机器上,否则将放在随机datanode上,另一个副本放在不同(远程)机架上的节点上,最后一个副本放在相同远程机架上的不同节点上。
###副本摆放策略
1-本rack的一个节点上
2-本rack的另外一个节点上
3-不同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
这个策略减少了机架间的写流量,这通常可以提高写性能。齿条失效的概率远小于节点失效的概率;此策略不影响数据可靠性和可用性保证。但是,它确实减少了读取数据时使用的聚合网络带宽,因为一个块只放在两个而不是三个惟一的机架中。使用此策略,文件的副本不会均匀地分布在机架上。
二.HDFS的元数据管理checkpoint机制
元数据:HDFS的目录结构以及每个文件的BLOCK信息(ID,副本系数,block存放在哪个DN上)
存在什么地方:对应配置 ${hadoop.tmp.dir}/name/…
*元数据存放在文件中:
比如:
/test1 X
/test1/a.txt X
/test2
/test2/1.txt X
/test2/2.txt
/test2/xxx添加
/test2/3.txt
命令:
hadoop fs -put xxx /test2/
hadoop fs -rmr /test1 对应/test1删除
hadoop fs -mv /test2/1.txt /test2/3.txt 重命名 原来的/test2/1.txt X
这样在HDFS上操作起来是非常不方便的,所以就有了checkpoint机制(secondary NN概念)
三.Safemode:safemode开启的时候是无法进行数据的读写操作的
On startup, the NameNode enters a special state called Safemode. Replication of data blocks does not occur when the NameNode is in the Safemode state. The NameNode receives Heartbeat and Blockreport messages from the DataNodes. A Blockreport contains the list of data blocks that a DataNode is hosting. Each block has a specified minimum number of replicas. A block is considered safely replicated when the minimum number of replicas of that data block has checked in with the NameNode. After a configurable percentage of safely replicated data blocks checks in with the NameNode (plus an additional 30 seconds), the NameNode exits the Safemode state. It then determines the list of data blocks (if any) that still have fewer than the specified number of replicas. The NameNode then replicates these blocks to other DataNodes.
在启动时,NameNode进入一个名为Safemode的特殊状态。当NameNode处于Safemode状态时,不会发生数据块的复制。NameNode从DataNode接收Heartbeat和Blockreport消息。Blockreport包含DataNode托管的数据块列表。每个块都有指定的最小副本数。当使用NameNode检入该数据块的最小副本数时,会认为该块是安全复制的。在可配置百分比的安全复制数据块使用NameNode检入(再加上30秒)后,NameNode退出Safemode状态。然后,它确定仍然具有少于指定数量的副本的数据块列表(如果有)。然后,NameNode将这些块复制到其他DataNode。