gpt4 book ai didi

azure - Spark 读/写 Azure blob 存储 - IOException : No FileSystem for scheme: wasbs

转载 作者:行者123 更新时间:2023-12-02 23:56:35 27 4
gpt4 key购买 nike

我正在尝试读取/写入 Azure blob 存储,但不断收到“方案没有文件系统:wasbs”。这是我的 gradle 文件的样子

plugins {
// Apply the scala plugin to add support for Scala
id 'scala'
id 'idea'
id 'application'
}

repositories {
mavenLocal()
jcenter()

maven {
url "https://repository.mulesoft.org/nexus/content/repositories/public"
}
}

dependencies {
// Spark SQL subsumes Spark Core
compileOnly 'org.apache.spark:spark-sql_2.12:3.0.3'
implementation group: 'org.scala-lang', name: 'scala-library', version: '2.12.1'

implementation group: 'com.typesafe', name: 'config', version: '1.4.1'
implementation group: 'com.microsoft.azure', name: 'azure-storage', version: '8.6.6'
implementation group: 'org.apache.hadoop', name: 'hadoop-azure', version: '3.3.1'
}


jar {
manifest {
attributes('Main-Class': 'AppRunner')
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
exclude 'META-INF/*.RSA'
exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA'

duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}

我正在创建一个 jar 文件,其中包含 hadoop-azure 和 azure-storage 所需的所有依赖项。

这就是我的 Scala 文件主要做的事情。

spark.conf.set("fs.azure.account.key.<blob-name>.blob.core.windows.net", "<blob-key>")
spark.sparkContext.hadoopConfiguration.set("fs.azure", "org.apache.hadoop.fs.azure.NativeAzureFileSystem")

val df = spark.read.parquet("wasbs://<container-name>@<blob-name>.blob.core.windows.net/data/")

我的 Spark 设置当前位于 Azure 环境中的虚拟机上,我在其中以独立模式运行 Spark 3.1.2。

我的 Spark-submit 命令看起来像

./spark-3.1.2-bin-hadoop2.7/bin/spark-submit --master "local[*]"--jars jars/hadoop-azure-3.3.1.jar,jars/azure-storage-8.6.6.jar 编译-job.jar

我不需要将 jar 作为参数包含在内,但我将其包含在内是为了进行测试,因为 Spark 作业似乎无法主要找到 wasbs 文件系统。

这是我运行 jar 文件时收到的异常

Exception in thread "main" java.io.IOException: No FileSystem for scheme: wasbs
at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2660)
at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2667)
at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:94)
at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2703)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2685)

知道我在这里做错了什么吗?

最佳答案

只需添加以下配置:spark.conf.set("fs.wasbs.impl", "org.apache.hadoop.fs.azure.NativeAzureFileSystem")

关于azure - Spark 读/写 Azure blob 存储 - IOException : No FileSystem for scheme: wasbs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71305849/

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