欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【Kafka启动报错】Caused by: java.lang.OutOfMemoryError: Map failed

程序员文章站 2022-03-01 12:39:12
...

参考:https://*.com/questions/43042144/kafka-server-failed-to-start-java-io-ioexception-map-failed

报错日志

[2022-02-15 16:50:40,558] ERROR Error while deleting the clean shutdown file in dir /home/es/kafka_2.11-2.2.1/logs (kafka.server.LogDirFailureChannel)
java.io.IOException: Map failed
	at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:938)
	at kafka.log.AbstractIndex.<init>(AbstractIndex.scala:126)
	at kafka.log.OffsetIndex.<init>(OffsetIndex.scala:53)
	at kafka.log.LogSegment$.open(LogSegment.scala:633)
	at kafka.log.Log$$anonfun$kafka$log$Log$$loadSegmentFiles$3.apply(Log.scala:467)
	at kafka.log.Log$$anonfun$kafka$log$Log$$loadSegmentFiles$3.apply(Log.scala:454)
	at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:733)
	at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
	at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:732)
	at kafka.log.Log.kafka$log$Log$$loadSegmentFiles(Log.scala:454)
	at kafka.log.Log$$anonfun$loadSegments$1.apply$mcV$sp(Log.scala:565)
	at kafka.log.Log$$anonfun$loadSegments$1.apply(Log.scala:559)
	at kafka.log.Log$$anonfun$loadSegments$1.apply(Log.scala:559)
	at kafka.log.Log.retryOnOffsetOverflow(Log.scala:2060)
	at kafka.log.Log.loadSegments(Log.scala:559)
	at kafka.log.Log.<init>(Log.scala:292)
	at kafka.log.Log$.apply(Log.scala:2193)
	at kafka.log.LogManager.kafka$log$LogManager$$loadLog(LogManager.scala:265)
	at kafka.log.LogManager$$anonfun$loadLogs$2$$anonfun$11$$anonfun$apply$15$$anonfun$apply$2.apply$mcV$sp(LogManager.scala:345)
	at kafka.utils.CoreUtils$$anon$1.run(CoreUtils.scala:63)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	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)
Caused by: java.lang.OutOfMemoryError: Map failed
	at sun.nio.ch.FileChannelImpl.map0(Native Method)
	at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:935)
	... 25 more

原因JVM是32位的,Linxu系统是64位的

查看JVM位数

[[email protected] bin]# java -d64 -version
Error: This Java instance does not support a 64-bit JVM.
Please install the desired version.
[[email protected] bin]# 
[[email protected] bin]# java -d32 -version
java version "1.8.0_311"
Java(TM) SE Runtime Environment (build 1.8.0_311-b11)
Java HotSpot(TM) Server VM (build 25.311-b11, mixed mode)

安装64位JDK后查看

[[email protected] ~]#  java -d64 -version
java version "1.8.0_321"
Java(TM) SE Runtime Environment (build 1.8.0_321-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.321-b07, mixed mode)
[[email protected] ~]# java -d32 -version
Error: This Java instance does not support a 32-bit JVM.
Please install the desired version.

重新启动Kafka,发现正常