标签:lang 查看 arguments www 多参数 一个 serialize bin 默认
今天在开发SparkRDD的过程中出现Buffer Overflow错误,查看具体Yarn日志后发现是因为Kryo序列化缓冲区溢出了,日志建议调大spark.kryoserializer.buffer.max的value,搜索了一下设置keyo序列化缓冲区的方法,特此整理记录下来。
20/01/08 17:12:55 WARN scheduler.TaskSetManager: Lost task 1.0 in stage 1.0 (TID 4, s015.test.com, executor 1): org.apache.spark.SparkException: Kryo serialization failed: Buffer overflow. Available: 0, required: 10300408. To avoid this, increase spark.kryoserializer.buffer.max value.
at org.apache.spark.serializer.KryoSerializerInstance.serialize(KryoSerializer.scala:315)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:367)
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)
spark-submit在提交spark作业时可以带很多参数,其中有一个参数--conf
可以设置spark.kryoserializer.buffer.max的大小,具体如下。
./bin/spark-submit --class <main-class> --master <master-url> --deploy-mode <deploy-mode> --conf spark.kryoserializer.buffer.max=512m ... # other options
<application-jar> [application-arguments]
上面的--conf spark.kryoserializer.buffer.max=512m
即代表把Kryo序列化缓冲区的buffer大小设置为512mb。
//设置Kryo为序列化类(默认为Java序列类)
sparkConf.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer");
//两种设置方法
sparkConf.set("spark.kryoserializer.buffer.max", "128m");
sparkConf.set("spark.kryoserializer.buffer.max.mb", "128");
//打印日志,检查是否成功设置
System.out.println( sparkConf.get("spark.kryoserializer.buffer.max") );
[1]【大数据进击】如何设置spark.kryoserializer.buffer.max value
[2]Spark official docs: Submitting Applications
标签:lang 查看 arguments www 多参数 一个 serialize bin 默认
原文地址:https://www.cnblogs.com/JasonCeng/p/12169233.html