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

标签 hadoop hdfs replication

我已按照 Apache“单节点设置”说明在单节点上设置 dfs.replication

但是后来我按照“Cluster Setup”进行操作,但它没有提到这个属性,所以我不知道这是要在 Namenode 上设置的属性,还是也/仅在 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.

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

问:影响哪些节点?:

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

从“功能”的角度来看它主要影响名称节点,因为它们决定将这些 block 存储在何处。一般的 - 默认 - 策略是:

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.

single-modepseudo-distributed 模式下,此选项设置为 1 的原因很明显,你只有一台机器。在多机 - 集群 设置中,建议默认值为 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 并不意味着会有更多的 block 复制。它只是在运行数据节点实例的机器上指定目录,您要在其中存储 block 。


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

关于hadoop - "dfs.replication"和 "dfs.datanode.data.dir"配置如何在集群中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32730948/

相关文章:

postgresql - 一致地在两个 PostgreSQL 数据库之间同步表

r - 具有多个组件的RHadoop key

python - MapReduce Python - 太多值无法解包

scala - 如何列出 Spark Scala shell 中 HDFS 位置中的所有 csv 文件?

hadoop - 来自 Kafka 的 Spark 流式传输在本地返回结果但不适用于 Yarn

redis - 直接从 Redis 集群中的副本读取

azure - 将存储数据从一个 Azure 帐户复制到另一个 Azure 帐户

hadoop - 步骤因 exitCode、Amazon Emr Hadoop、S3DistCp 而失败

mysql - 如何将HDFS数据导出到mysql?

Hadoop HDFS - 缺少副本和复制 block 不足之间的区别