Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka server failed to start - java.io.IOException: Map failed

I am not able to start Kafka Server because of the error below.

java.io.IOException: Map failed
    at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:940)
    at kafka.log.AbstractIndex.<init>(AbstractIndex.scala:61)
    at kafka.log.TimeIndex.<init>(TimeIndex.scala:55)
    at kafka.log.LogSegment.<init>(LogSegment.scala:73)
    at kafka.log.Log.loadSegments(Log.scala:267)
    at kafka.log.Log.<init>(Log.scala:116)
    at kafka.log.LogManager$$anonfun$createLog$1.apply(LogManager.scala:365)
    at kafka.log.LogManager$$anonfun$createLog$1.apply(LogManager.scala:361)
    at scala.Option.getOrElse(Option.scala:121)
    at kafka.log.LogManager.createLog(LogManager.scala:361)
    at kafka.cluster.Partition$$anonfun$getOrCreateReplica$1.apply(Partition.scala:109)
    at kafka.cluster.Partition$$anonfun$getOrCreateReplica$1.apply(Partition.scala:106)
    at kafka.utils.Pool.getAndMaybePut(Pool.scala:70)
    at kafka.cluster.Partition.getOrCreateReplica(Partition.scala:105)
    at kafka.cluster.Partition$$anonfun$4$$anonfun$apply$3.apply(Partition.scala:166)
    at kafka.cluster.Partition$$anonfun$4$$anonfun$apply$3.apply(Partition.scala:166)
    at scala.collection.mutable.HashSet.foreach(HashSet.scala:78)
    at kafka.cluster.Partition$$anonfun$4.apply(Partition.scala:166)
    at kafka.cluster.Partition$$anonfun$4.apply(Partition.scala:160)
    at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:213)
    at kafka.utils.CoreUtils$.inWriteLock(CoreUtils.scala:221)
    at kafka.cluster.Partition.makeLeader(Partition.scala:160)
    at kafka.server.ReplicaManager$$anonfun$makeLeaders$4.apply(ReplicaManager.scala:754)
    at kafka.server.ReplicaManager$$anonfun$makeLeaders$4.apply(ReplicaManager.scala:753)
    at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:99)
    at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:99)
    at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:230)
    at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
    at scala.collection.mutable.HashMap.foreach(HashMap.scala:99)
    at kafka.server.ReplicaManager.makeLeaders(ReplicaManager.scala:753)
    at kafka.server.ReplicaManager.becomeLeaderOrFollower(ReplicaManager.scala:698)
    at kafka.server.KafkaApis.handleLeaderAndIsrRequest(KafkaApis.scala:148)
    at kafka.server.KafkaApis.handle(KafkaApis.scala:84)
    at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:62)
    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)
    ... 34 more

Tried the below options . but of no use . please help

Upgraded OS from 32 to 64 Bit.
Increased java heap size to 1 GB.
Uninstalled and installed Apache Kafka

like image 908
Gopi Avatar asked Mar 27 '17 09:03

Gopi


4 Answers

When this doesn't resolve the problem you could try to increase vm.max_map_count. The default value is 65536 (check this with sysctl vm.max_map_count)

With cat /proc/[kafka-pid]/maps | wc -l you can see how many maps are used.

Increase the setting with :

sysctl -w vm.max_map_count=262144
like image 141
jvwilge Avatar answered Nov 15 '22 05:11

jvwilge


Upgrading the JVM to 64 bit resolved the issue

like image 20
Gopi Avatar answered Nov 15 '22 05:11

Gopi


This helped me : Changing KAFKA_HEAP_OPTS="-Xmx256M -Xms256M" (Originally 512m)

change this to : kafka-server-start script

Thanks !

like image 24
GAURAV PATEL Avatar answered Nov 15 '22 04:11

GAURAV PATEL


this helped me: change : export KAFKA_HEAP_OPTS="-Xmx512M -Xms512M" (originally 1G)

in kafka-server-start script

like image 2
Dina Goldebrg Avatar answered Nov 15 '22 06:11

Dina Goldebrg