来自spark结构化流媒体文档:
“此检查点位置必须是HDFS兼容文件系统中的路径,并且可以在启动查询时设置为DataStreamWriter
中的选项。”
果然,将检查点设置为s3路径会抛出:
17/01/31 21:23:56 ERROR ApplicationMaster: User class threw exception: java.lang.IllegalArgumentException: Wrong FS: s3://xxxx/fact_checkpoints/metadata, expected: hdfs://xxxx:8020
java.lang.IllegalArgumentException: Wrong FS: s3://xxxx/fact_checkpoints/metadata, expected: hdfs://xxxx:8020
at org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:652)
at org.apache.hadoop.hdfs.DistributedFileSystem.getPathName(DistributedFileSystem.java:194)
at org.apache.hadoop.hdfs.DistributedFileSystem.access$000(DistributedFileSystem.java:106)
at org.apache.hadoop.hdfs.DistributedFileSystem$22.doCall(DistributedFileSystem.java:1305)
at org.apache.hadoop.hdfs.DistributedFileSystem$22.doCall(DistributedFileSystem.java:1301)
at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:1301)
at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1430)
at org.apache.spark.sql.execution.streaming.StreamMetadata$.read(StreamMetadata.scala:51)
at org.apache.spark.sql.execution.streaming.StreamExecution.<init>(StreamExecution.scala:100)
at org.apache.spark.sql.streaming.StreamingQueryManager.createQuery(StreamingQueryManager.scala:232)
at org.apache.spark.sql.streaming.StreamingQueryManager.startQuery(StreamingQueryManager.scala:269)
at org.apache.spark.sql.streaming.DataStreamWriter.start(DataStreamWriter.scala:262)
at com.roku.dea.spark.streaming.FactDeviceLogsProcessor$.main(FactDeviceLogsProcessor.scala:133)
at com.roku.dea.spark.streaming.FactDeviceLogsProcessor.main(FactDeviceLogsProcessor.scala)
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 org.apache.spark.deploy.yarn.ApplicationMaster$$anon$2.run(ApplicationMaster.scala:637)
17/01/31 21:23:56 INFO SparkContext: Invoking stop() from shutdown hook
这里有几个问题:
答案 0 :(得分:6)
这是一个众所周知的问题:https://issues.apache.org/jira/browse/SPARK-19407
应该在下一个版本中修复。您可以使用--conf spark.hadoop.fs.defaultFS=s3
将默认文件系统设置为s3作为解决方法。
答案 1 :(得分:6)
什么使FS HDFS符合标准?&#34;它是一个文件系统,具有Hadoop FS specification中指定的行为。这里介绍了对象存储和FS之间的区别,关键点是&#34;最终一致的对象存储没有附加或O(1)原子重命名不符合&#34;
特别是S3
通过将所有内容保存到某个位置然后将其重命名为检查点目录来激活流检查点。这使得检查点的时间与在S3中执行数据复制的时间成比例,即~6-10 MB / s。
流媒体代码的当前位不适合s3
现在,做一个
如果您使用的是EMR,则可以为一致的发电机数据库支持的S3支付额外费用,从而为您提供更好的一致性。但复制时间仍然相同,因此检查点也会一样慢
答案 2 :(得分:2)
https://issues.apache.org/jira/browse/SPARK-19407已解决此问题。
然而,由于S3中缺乏最终的一致性,结构化流式检查点在S3中不能很好地工作。使用S3进行检查点https://issues.apache.org/jira/browse/SPARK-19013并不是一个好主意。
Micheal Armburst已经表示,这不会在Spark中修复,解决方案是等待S3guard实施。 S3Guard有一段时间了。
答案 3 :(得分:1)
是的,如果您使用的是 Spark Structured Streaming 版本 3 或更高版本。首先,创建一个 int _findDataExisting(int row, int col) {
List<MyData>? data = table[row];
if (data == null) return -1;
for (int i = 0; i < data.length; i++) {
if (data[i].column == col) {
return i;
}
}
return -1;
}
并将 S3 配置添加到其上下文中。
SparkSession
稍后,在开始查询之前,使用 S3 存储桶添加 val sparkSession = SparkSession
.builder()
.master(sparkMasterUrl)
.appName(appName)
.getOrCreate()
sparkSession.sparkContext.hadoopConfiguration.set("fs.s3a.access.key", "accessKey")
sparkSession.sparkContext.hadoopConfiguration.set("fs.s3a.secret.key", "secretKey")
sparkSession.sparkContext.hadoopConfiguration.set("fs.s3a.endpoint", "http://s3URL:s3Port")
sparkSession.sparkContext.hadoopConfiguration.set("spark.hadoop.fs.s3a.impl", "org.apache.hadoop.fs.s3a.S3AFileSystem")
配置。例如:
checkpointLocation
答案 4 :(得分:0)
您可以将s3用作检查点,但应启用EMRFS,以便处理s3一致性。