远程 HDFS 文件从安全集群移动到非安全集群不起作用

Remote HDFS File Move from Secured Cluster to Non-Secured Cluster Not Working

尝试将文件从一个 hdfs 文件夹移动到非安全集群中的另一个 hdfs 文件夹,从安全(kerborized)集群。源和目标都在非安全集群上。下面的代码在安全集群中执行,将文件从源 hdfs 文件夹移动到非安全集群中的目标 hdfs 文件夹。

import org.apache.hadoop.fs.{FileSystem, FileUtil, Path}
import org.apache.hadoop.conf.Configuration
import org.apache.spark.sql.SparkSession

val sparkSession = SparkSession.builder().getOrCreate()
import sparkSession.implicits._

val conf = new Configuration
conf.set("fs.defaultFS", "hdfs://host:8020"); // This is non-secured cluster
conf.set("ipc.client.fallback-to-simple-auth-allowed", "true")
val fs = FileSystem.get(conf)

val source = new Path("/ABC/test.log")
val destination = new Path("/ABC/test")

val isMoved = FileUtil.copy(fs, source, fs, destination, true, true, conf)

以上代码抛出错误

"java.io.IOException: Server asks us to fall back to SIMPLE auth, but this client is configured to only allow secure connections"

我已经设置了配置 conf.set("ipc.client.fallback-to-simple-auth-allowed", "true") 但它不起作用。我希望在代码级别拥有此配置,而不是在 core-default.xml 或 core-site.xml 文件中添加此配置。

请注意以下命令在从安全集群中触发并且文件在非安全集群中移动时有效。

hdfs dfs -Dipc.client.fallback-to-simple-auth-allowed=true -mv hdfs://host:8020/ABC/test.log hdfs://host:8020/ABC/test

我更改了如下命令,它起作用了。

hdfs dfs -Dipc.client.fallback-to-simple-auth-allowed=true -mv webhdfs://host:50070/ABC/test.log webhdfs://host:50070/ABC/test

我们还向非安全集群 hdfs 中的安全集群用户授予了写入权限。