Spark/Hadoop Azure FS 驱动程序不会轻易允许 setCheckpointDir for wasbs

问题描述 投票:0回答:1

我在 azure 中使用 blob 存储(org.apache.hadoop.fs.azure 中的 AzureNativeFileSystemStore)。

当我尝试将检查点目录设置为指向它时,失败了:


spark.conf.set(
                      
  "fs.azure.account.key.myaccount.blob.core.windows.net",
  "mykey"
)

spark.sparkContext.setCheckpointDir("wasbs://[email protected]/raw/temp/")

错误消息声称我的存储密钥在spark.conf中丢失:

在配置中找不到帐户 myaccount.blob.core.windows.net 的凭据

来自 pyspark 的完整堆栈:

   
Py4JJavaError: An error occurred while calling o3578.setCheckpointDir.
: org.apache.hadoop.fs.azure.AzureException: org.apache.hadoop.fs.azure.AzureException: No credentials found for account xxx.blob.core.windows.net in the configuration, and its container datalake is not accessible using anonymous credentials. Please check if the container exists first. If it is not publicly available, you have to provide account credentials.
    at org.apache.hadoop.fs.azure.AzureNativeFileSystemStore.createAzureStorageSession(AzureNativeFileSystemStore.java:1123)
    at org.apache.hadoop.fs.azure.AzureNativeFileSystemStore.initialize(AzureNativeFileSystemStore.java:566)
    at org.apache.hadoop.fs.azure.NativeAzureFileSystem.initialize(NativeAzureFileSystem.java:1423)
    at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:3316)
    at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:137)
    at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:3365)
    at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:3333)
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:492)
    at org.apache.hadoop.fs.Path.getFileSystem(Path.java:361)
    at org.apache.spark.SparkContext.$anonfun$setCheckpointDir$2(SparkContext.scala:2595)
    at scala.Option.map(Option.scala:230)
    at org.apache.spark.SparkContext.setCheckpointDir(SparkContext.scala:2593)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
    at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
    at py4j.Gateway.invoke(Gateway.java:282)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:238)
    at java.lang.Thread.run(Thread.java:750)
Caused by: org.apache.hadoop.fs.azure.AzureException: No credentials found for account xxx.blob.core.windows.net in the configuration, and its container datalake is not accessible using anonymous credentials. Please check if the container exists first. If it is not publicly available, you have to provide account credentials.
    at org.apache.hadoop.fs.azure.AzureNativeFileSystemStore.connectUsingAnonymousCredentials(AzureNativeFileSystemStore.java:899)
    at org.apache.hadoop.fs.azure.AzureNativeFileSystemStore.createAzureStorageSession(AzureNativeFileSystemStore.java:1118)
    ... 22 more

这会阻止设置我的检查点目录。

但是,如果我首先使用稍微不同的 API(例如“spark.read”)与帐户进行交互,那么我也将 能够设置检查点目录!:

spark.read.parquet("wasbs://[email protected]/a/b/c/invalid.parquet")

spark.sparkContext.setCheckpointDir("wasbs://[email protected]/raw/temp/")

令人困惑的行为似乎是一个错误,对吧?
azure blob 存储提供程序有问题吗?或者 Spark 本身就是 bug 的根源?对我来说,我们遇到了关于缺少配置密钥的误导性错误(...并且首先需要一个小奇迹来识别正确的密钥:“fs.azure.account.key.myaccount.blob”,这对我来说似乎很麻烦。 core.windows.net”)。

任何指示将不胜感激。如果有更简单的方法来为 HDFS setCheckpointDir,请告诉我。预先感谢。

PS。如果版本很重要,我在我的 synapse-spark 环境中找到了这些罐子:

/usr/hdp/current/hadoop-client/azure-storage-7.0.1.jar
/usr/hdp/current/hadoop-client/hadoop-azure-3.1.1.5.0-97710309.jar
apache-spark hadoop azure-synapse-analytics
1个回答
0
投票

在 Spark 中使用 Azure Blob 存储时,通常使用 Spark.conf 对象配置凭据。但是,在您的情况下,当您直接使用spark.sparkContext.setCheckpointDir()设置检查点目录时,似乎没有正确获取凭据。

为确保凭据正确初始化,您可以尝试以下步骤:

尽早设置配置键: 在设置检查点目录之前,请确保使用 Spark.conf.set() 方法为 Azure 凭据设置必要的配置密钥。

蟒蛇 复制代码 Spark.conf.set("fs.azure.account.key.myaccount.blob.core.windows.net", "mykey") 确保您使用正确的帐户和密钥。

首先与 Azure 交互: 正如您所观察到的,使用 Spark 的读取操作与 Azure Blob 存储交互似乎可以正确初始化 Azure 凭据。如果有效,您可以在设置检查点目录之前执行虚拟读取操作。

蟒蛇 复制代码 Spark.read.parquet(“wasbs://[email protected]/a/b/c/invalid.parquet”) 完成此步骤后,尝试设置检查点目录:

蟒蛇 复制代码 Spark.sparkContext.setCheckpointDir("wasbs://[email protected]/raw/temp/") 版本兼容性: 您提到了 Azure 存储和 Hadoop 库的版本。确保这些版本彼此兼容以及与您正在使用的 Spark 版本兼容非常重要。版本不匹配可能会导致意外行为。如有必要,您可能需要考虑更新到最新的兼容版本。

使用配置文件: 不要以编程方式设置配置密钥,而是考虑使用 core-site.xml 或 Spark-defaults.conf 等配置文件来提供 Azure 凭据。这有助于确保在 Spark 执行之前正确初始化凭证。

调试: 如果仍然遇到问题,请考虑为 Spark 和 Azure 交互启用更详细的日志记录。这可以帮助您跟踪初始化和配置步骤,以确定问题可能发生的位置。

检查更新或修复: 有时,此类问题可能会在较新版本的 Spark 或 Azure 库中得到解决。检查与 Azure 集成相关的更新或错误修复是一个很好的做法。

© www.soinside.com 2019 - 2024. All rights reserved.