"dfs.replication" 和 "dfs.datanode.data.dir" 配置如何在集群中工作?

How do the "dfs.replication" and "dfs.datanode.data.dir" configurations work in a cluster?

我已按照 Apache "Single Node Setup" 说明在单个节点上设置 dfs.replication

但是后来我按照"Cluster Setup"但是它没有提到这个属性,所以我不知道这是不是在Namenode上设置的属性 , 或 also/only 在 Datanodes ..

我还读到在数据节点的 dfs.datanode.data.dir 中设置多个(逗号分隔)路径将在所有路径上复制数据。

所以我的问题是:dfs.replication 将对哪个节点产生影响,如果设置了 dfs.datanode.data.dir 的多个路径,这些额外的独立复制是否仅针对每个数据节点,或者这些是否也以某种方式与 dfs.replication 因素有关?

另外,当数据已经复制到其他节点时,在 Datanode 上使用这个额外的本地复制有什么用?

对了,首先让我们看看docs:

中对这些配置标志的描述

配置选项:dfs.replication

Default block replication. The actual number of replications can be specified when the file is created. The default is used if replication is not specified in create time.

直觉上,这告诉我们可以使用此选项来指定要存储的数据块的复制因子。此 属性 预先配置为等于 3。

问:影响哪些节点?:

回答: 从存储的角度,它影响datanodes,主要是因为它们是存储块的那些。当然,技术上,它确实会影响 Namenode,特别是 FsImage(文件系统映像)文件包含数据节点的所有映射 - 存储块。

从“'functionality'”的角度来看它主要影响名称节点,因为它们是决定将这些存储在哪里的节点块。一般的 - 默认 - 策略是:

Hadoop’s default strategy is to place the first replica on the same node as the client (for clients running outside the cluster, a node is chosen at random, although the system tries not to pick nodes that are too full or too busy). The second replica is placed on a different rack from the first (off-rack), chosen at random. The third replica is placed on the same rack as the second, but on a different node chosen at random. Further replicas are placed on random nodes in the cluster, although the system tries to avoid placing too many replicas on the same rack.

单模伪分布式 mode 这个选项设置为等于1 原因很明显,你只有一台机器。在多机 - cluster 设置中,建议默认值为 3。

配置选项:datanode.data.dir

Determines where on the local filesystem an DFS data node should store its blocks. If this is a comma-delimited list of directories, then data will be stored in all named directories, typically on different devices. Directories that do not exist are ignored.

问:这些额外的独立复制仅针对每个 Datanode,还是它们也以某种方式与 dfs.replication 因子?

答案: 根据我的阅读,指定 datanode.data.dir 并不意味着将有更多的块复制。它只是指定目录,在机器上运行数据节点实例,你想在其中存储块。


看看这个PDF on HDFS Design。这比我能给出的任何答案都要好,它应该可以帮助您更好地理解这些概念。