[英]Error Processing Large Data With Spark
我正在嘗試在AWS上使用Spark進行字數統計。 我創建了一個火花集群,並且在s3中存儲了大文件。 我總共有100個文件,每個文件50GB。 我可以一次成功地對其中一個文件進行字數統計,但是如果我嘗試全部一起進行字數統計,則會失敗。 另外,如果我嘗試對大於60GB的單個文件進行字數統計,則會失敗。 我得到的錯誤是:
ERROR org.apache.spark.executor.Executor (Executor task launch worker for task 2): Exception in task 2.0 in stage 0.0 (TID 2)
java.lang.NoSuchMethodError: org.roaringbitmap.RoaringBitmap.runOptimize()Z
at org.apache.spark.scheduler.HighlyCompressedMapStatus$.apply(MapStatus.scala:234)
at org.apache.spark.scheduler.MapStatus$.apply(MapStatus.scala:54)
at org.apache.spark.shuffle.sort.SortShuffleWriter.write(SortShuffleWriter.scala:74)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:96)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:53)
at org.apache.spark.scheduler.Task.run(Task.scala:108)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:338)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
這是我的字數代碼
public class WordCount {
public static void main(String[] args) throws Exception {
SparkConf sparkConf = new SparkConf().setAppName("WordCount").setMaster("local[5]").set("spark.executor.memory","32g");
JavaSparkContext spark = new JavaSparkContext(sparkConf);
System.out.println(MessageFormat.format("Starting word count for {0}", args[0]));
JavaRDD<String> textFile = spark.textFile(MessageFormat.format("s3a://my_bucket/{0}*", args[0]));
JavaPairRDD<String, Integer> counts = textFile.flatMap(s -> Arrays.asList(s.split(" ")).iterator())
.mapToPair(word -> new Tuple2<>(word, 1)).reduceByKey((a, b) -> a + b);
counts.saveAsTextFile(MessageFormat.format("{0}_output", args[0]));
spark.close();
System.exit(0);
}
}
我讀到這可能是版本不匹配錯誤,並且我已經確保編譯后的代碼中的spark版本與集群上的spark版本相同。
我的集群有1個主節點和5個核心節點。 每個節點具有8個核心,64GB內存和1690GB存儲空間。
為了運行代碼,我將上面的Java代碼導出到jar文件中。 我將jar文件保存到s3。 然后在AWS控制台中,單擊“添加步驟”,然后選擇上傳到s3的jar文件。 然后運行代碼。
@ErnestKiwele評論對我的幫助最大。 當您在AWS中創建集群時,請選擇高級選項。 默認情況下,選擇Hadoop,Pig,Hive和Hue。 我將所有這些都保留下來並添加到Spark中。 當我僅使用Hadoop和Spark(這是我所需要的)時,我不再收到錯誤。 一定是火花和其他火花之間存在一些沖突。 謝謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.