Spark Streaming 避坑的注意事项

发布时间:2019-11-19 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了Spark Streaming 避坑的注意事项脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

两个RDD不能嵌套计算:

Caused by: org.apache.spark.SparkException: RDD transformations and actions can only be  invoked by the driver, not inside of other transformations; for example, rdd1.map(x =>  rdd2.values.count() * x) is invalid because the values transformation and count action  cannot be performed inside of the rdd1.map transformation. For more information, see  SPARK-5063.

解决方案:将一个rdd进行action转换后,保存在内存中。

计算中内存溢出

原因
Spark Streaming执行一个流处理的时候,这个流处理还没有处理完成,又接入了下一流;

Exception in thread "JobGenerator" java.lang.OutOfMemoryError: Java heap space     at java.util.Arrays.copyOf(Arrays.java:3236) 

解决方案:加快每个流的处理速率调整流处理的时间间隔,保证在下个流到来之前,当前流就处理完成。

配置不足或者过多