kafka服务无法启动的原因
kafka集群中一台服务器kill掉后再启动时报错。
java.io.IOException: Map failed
Caused by: java.lang.OutOfMemoryError: Map failed
[2017-06-01 23:13:20,254] ERROR There was an error in one of the threads during logs loading: java.io.IOException: Map failed (kafka.log.LogManager) [2017-06-01 23:13:20,264] FATAL [Kafka Server 0], Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer) java.io.IOException: Map failed at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:940) at kafka.log.AbstractIndex.$anonfun$resize$1(AbstractIndex.scala:111) at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:213) at kafka.log.AbstractIndex.resize(AbstractIndex.scala:101) at kafka.log.Log.loadSegments(Log.scala:281) at kafka.log.Log.<init>(Log.scala:116) at kafka.log.LogManager.$anonfun$loadLogs$10(LogManager.scala:157) at kafka.utils.CoreUtils$$anon$1.run(CoreUtils.scala:57) 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:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.OutOfMemoryError: Map failed at sun.nio.ch.FileChannelImpl.map0(Native Method) at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:937) ... 12 more [2017-06-01 23:13:20,289] INFO [Kafka Server 0], shutting down (kafka.server.KafkaServer) [2017-06-01 23:13:20,478] INFO [Kafka Server 0], shut down completed (kafka.server.KafkaServer) [2017-06-01 23:13:20,480] FATAL Fatal error during KafkaServerStartable startup. Prepare to shutdown (kafka.server.KafkaServerStartable) java.io.IOException: Map failed at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:940) at kafka.log.AbstractIndex.$anonfun$resize$1(AbstractIndex.scala:111) at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:213) at kafka.log.AbstractIndex.resize(AbstractIndex.scala:101) at kafka.log.Log.loadSegments(Log.scala:281) at kafka.log.Log.<init>(Log.scala:116) at kafka.log.LogManager.$anonfun$loadLogs$10(LogManager.scala:157) at kafka.utils.CoreUtils$$anon$1.run(CoreUtils.scala:57) 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:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.OutOfMemoryError: Map failed at sun.nio.ch.FileChannelImpl.map0(Native Method) at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:937) ... 12 more [2017-06-01 23:13:20,494] INFO [Kafka Server 0], shutting down (kafka.server.KafkaServer)
通过https://stackoverflow.com/questions/43042144/kafka-server-failed-to-start-java-io-ioexception-map-failed得知需要64位JVM。
现环境是centos6.8 32位+jvm 32位,升级为centos6.8 64位+jvm 64位后成功解决。