gpt4 book ai didi

scala - Spark 在 hdfs 上写入 Parquet

转载 作者:可可西里 更新时间:2023-11-01 14:30:36 27 4
gpt4 key购买 nike

我安装了 3 个节点 hadoop 和 spark。我想从 rdbms 中获取数据到数据帧中,并将这些数据写入 HDFS 上的 Parquet 。 “dfs.replication”值为 1 。

当我使用以下命令尝试此操作时,我看到所有 HDFS block 都位于我执行 spark-shell 的节点上。

scala> xfact.write.parquet("hdfs://sparknode01.localdomain:9000/xfact")

这是预期的行为还是应该将所有 block 分布在整个集群中?

谢谢

最佳答案

由于您正在将数据写入 HDFS,因此这不依赖于 spark,而是依赖于 HDFS。来自 Hadoop : Definitive Guide

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).

所以是的,这是预期的行为。

关于scala - Spark 在 hdfs 上写入 Parquet ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40417442/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com