spark実行時のJava heap spaceの問題の解決
8269 ワード
問題の説明:
sparkプログラムを実行する場合は、200 wのデータをキャッシュとして読み出す必要があります.利用中broadcastがこれらのデータをブロードキャストすると、Exception in thread"main"javaに遭遇する.lang.OutOfMemoryError:Java heap space問題.
エラーメッセージは次のとおりです.
解決策:
sparkはjava-Xms 32 m-Xmx 800 m classNameからメモリを追加できません.sparkはこのフォーマットをサポートしていません../bin/spark-submit--helpにもこのフォーマットは表示されません.だからspark自体からしか手に入らない.
表示./bin/spark-submit--help,発見
executor-memoryの場合、yarnベースのsparkで実行しているので、これはyarn自身が制御している可能性があります.ここで設定した場合、無効です.localモードで設定できる場合があります.具体的な詳細は実験研究を待つ.
【添付】
./bin/spark-submit--helpの詳細は次のとおりです.
sparkプログラムを実行する場合は、200 wのデータをキャッシュとして読み出す必要があります.利用中broadcastがこれらのデータをブロードキャストすると、Exception in thread"main"javaに遭遇する.lang.OutOfMemoryError:Java heap space問題.
エラーメッセージは次のとおりです.
15/09/15 05:26:09 INFO storage.BlockManagerInfo: Removed broadcast_3_piece0 on ip-172-31-10-136.ec2.internal:34472 in memory (size: 2.0 KB, free: 397.3 MB)
15/09/15 05:26:09 INFO spark.ContextCleaner: Cleaned broadcast 3
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.io.ObjectOutputStream$HandleTable.growEntries(ObjectOutputStream.java:2351)
at java.io.ObjectOutputStream$HandleTable.assign(ObjectOutputStream.java:2276)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1428)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at java.util.ArrayList.writeObject(ArrayList.java:762)
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:497)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at org.apache.spark.serializer.JavaSerializationStream.writeObject(JavaSerializer.scala:44)
at org.apache.spark.broadcast.TorrentBroadcast$.blockifyObject(TorrentBroadcast.scala:202)
at org.apache.spark.broadcast.TorrentBroadcast.writeBlocks(TorrentBroadcast.scala:101)
at org.apache.spark.broadcast.TorrentBroadcast.(TorrentBroadcast.scala:84)
at org.apache.spark.broadcast.TorrentBroadcastFactory.newBroadcast(TorrentBroadcastFactory.scala:34)
at org.apache.spark.broadcast.TorrentBroadcastFactory.newBroadcast(TorrentBroadcastFactory.scala:29)
at org.apache.spark.broadcast.BroadcastManager.newBroadcast(BroadcastManager.scala:62)
at org.apache.spark.SparkContext.broadcast(SparkContext.scala:1051)
at org.apache.spark.api.java.JavaSparkContext.broadcast(JavaSparkContext.scala:648)
at com.myspark.spark.task.Spark_task.main(Spark_task.java:77)
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:497)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:569)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:166)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:189)
さらに、エラーが報告された位置の前のいくつかのメッセージを表示する.15/09/15 05:26:09 INFO storage.MemoryStore: Block broadcast_3 of size 3488 dropped from memory (free 280236528)
15/09/15 05:26:09 INFO storage.BlockManagerInfo: Removed broadcast_3_piece0 on ip-172-31-10-135.ec2.internal:51942 in memory (size: 2.0 KB, free: 398.1 MB)
15/09/15 05:26:09 INFO storage.BlockManagerInfo: Removed broadcast_3_piece0 on ip-172-31-10-136.ec2.internal:34472 in memory (size: 2.0 KB, free: 397.3 MB)
15/09/15 05:26:09 INFO spark.ContextCleaner: Cleaned broadcast 3
はメモリが足りないことを示しています.解決策:
sparkはjava-Xms 32 m-Xmx 800 m classNameからメモリを追加できません.sparkはこのフォーマットをサポートしていません../bin/spark-submit--helpにもこのフォーマットは表示されません.だからspark自体からしか手に入らない.
表示./bin/spark-submit--help,発見
--driver-memory MEM Memory for driver (e.g. 1000M, 2G) (Default: 512M).
すると、実行コミット文を変更し、実行に成功しました../bin/spark-submit
--class com.myspark.spark.task.Spark_task
--master yarn-client --driver-memory 1g
/home/hadoop/myspark/spark-example-test-0.0.1-SNAPSHOT.jar
s3://**********
s3://***********
/test/myspark/spark35
executor-memoryの場合、yarnベースのsparkで実行しているので、これはyarn自身が制御している可能性があります.ここで設定した場合、無効です.localモードで設定できる場合があります.具体的な詳細は実験研究を待つ.
--executor-memory MEM Memory per executor (e.g. 1000M, 2G) (Default: 1G)
【添付】
./bin/spark-submit--helpの詳細は次のとおりです.
Options:
--master MASTER_URL spark://host:port, mesos://host:port, yarn, or local.
--deploy-mode DEPLOY_MODE Whether to launch the driver program locally ("client") or
on one of the worker machines inside the cluster ("cluster")
(Default: client).
--class CLASS_NAME Your application's main class (for Java / Scala apps).
--name NAME A name of your application.
--jars JARS Comma-separated list of local jars to include on the driver
and executor classpaths.
--packages Comma-separated list of maven coordinates of jars to include
on the driver and executor classpaths. Will search the local
maven repo, then maven central and any additional remote
repositories given by --repositories. The format for the
coordinates should be groupId:artifactId:version.
--repositories Comma-separated list of additional remote repositories to
search for the maven coordinates given with --packages.
--py-files PY_FILES Comma-separated list of .zip, .egg, or .py files to place
on the PYTHONPATH for Python apps.
--files FILES Comma-separated list of files to be placed in the working
directory of each executor.
--conf PROP=VALUE Arbitrary Spark configuration property.
--properties-file FILE Path to a file from which to load extra properties. If not
specified, this will look for conf/spark-defaults.conf.
--driver-memory MEM Memory for driver (e.g. 1000M, 2G) (Default: 512M).
--driver-java-options Extra Java options to pass to the driver.
--driver-library-path Extra library path entries to pass to the driver.
--driver-class-path Extra class path entries to pass to the driver. Note that
jars added with --jars are automatically included in the
classpath.
--executor-memory MEM Memory per executor (e.g. 1000M, 2G) (Default: 1G).
--proxy-user NAME User to impersonate when submitting the application.
--help, -h Show this help message and exit
--verbose, -v Print additional debug output
--version, Print the version of current Spark
Spark standalone with cluster deploy mode only:
--driver-cores NUM Cores for driver (Default: 1).
--supervise If given, restarts the driver on failure.
--kill SUBMISSION_ID If given, kills the driver specified.
--status SUBMISSION_ID If given, requests the status of the driver specified.
Spark standalone and Mesos only:
--total-executor-cores NUM Total cores for all executors.
YARN-only:
--driver-cores NUM Number of cores used by the driver, only in cluster mode
(Default: 1).
--executor-cores NUM Number of cores per executor (Default: 1).
--queue QUEUE_NAME The YARN queue to submit to (Default: "default").
--num-executors NUM Number of executors to launch (Default: 2).
--archives ARCHIVES Comma separated list of archives to be extracted into the
working directory of each executor.