FATAL Fatal error during KafkaServerStartable startup. java.lang.OutOfMemoryError: Java heap space

1910 ワード

今日kafkaの単機版を構築してテストに使用して、構成が終わってからkafkaを起動する時メモリがあふれ出す問題が現れて、以下の通りです:
[2016-10-22 10:39:39,112] INFO [Kafka Server 0], shut down completed (kafka.server.KafkaServer)
[2016-10-22 10:39:39,113] FATAL Fatal error during KafkaServerStartable startup. Prepare to shutdown (kafka.server.KafkaServerStartable)
java.lang.OutOfMemoryError: Java heap space
	at java.nio.HeapByteBuffer.(HeapByteBuffer.java:57)
	at java.nio.ByteBuffer.allocate(ByteBuffer.java:335)
	at kafka.log.SkimpyOffsetMap.(OffsetMap.scala:42)
	at kafka.log.LogCleaner$CleanerThread.(LogCleaner.scala:177)
	at kafka.log.LogCleaner$$anonfun$1.apply(LogCleaner.scala:86)
	at kafka.log.LogCleaner$$anonfun$1.apply(LogCleaner.scala:86)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
	at scala.collection.immutable.Range.foreach(Range.scala:141)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
	at scala.collection.AbstractTraversable.map(Traversable.scala:105)
	at kafka.log.LogCleaner.(LogCleaner.scala:86)
	at kafka.log.LogManager.(LogManager.scala:64)
	at kafka.server.KafkaServer.createLogManager(KafkaServer.scala:335)
	at kafka.server.KafkaServer.startup(KafkaServer.scala:85)
	at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:29)
	at kafka.Kafka$.main(Kafka.scala:46)
	at kafka.Kafka.main(Kafka.scala)
[2016-10-22 10:39:39,114] INFO EventThread shut down (org.apache.zookeeper.ClientCnxn)
[2016-10-22 10:39:39,116] INFO [Kafka Server 0], shutting down (kafka.server.KafkaServer)

解決方法:
kafka/kafka-server-startを編集shこの起動ファイル、KAFKA_を修正HEAP_OPTSというパラメータ、デフォルトのパラメータはexport KAFKA_HEAP_OPTS=「-Xmx 512 m-Xms 512 m」、メモリを大きくすれば良い、export KAFKA_HEAP_OPTS=「-Xmx 1 g-Xms 1 g」で、問題解決を再起動します.