Spark对Azure blob存储的读/写-IOException:没有用于方案的文件系统:wasbs



我正在尝试对Azure blob存储进行读/写,但不断收到"方案没有文件系统:wasbs";。这是我的等级文件看起来像

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存储所需的所有依赖项。

这就是我的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 compiled-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"(

最新更新