manasee patra
manasee patra

Reputation: 81

Kafka is failing to start. Getting the below error

ERROR Error while creating ephemeral at /brokers/ids/0, node already exists and owner '72067757872119809' does not match current session '72067836689711106' (kafka.zk.KafkaZkClient$CheckedEphemeral) 2021-05-05 02:19:44.796 [INF] [Kafka] [2021-05-05 02:19:44,786] ERROR [KafkaServer id=0] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)

Upvotes: 8

Views: 8682

Answers (4)

yurifranzoni
yurifranzoni

Reputation: 46

Got the same problem here in a very specific situation: my Kafka brokers were created by restoring an AMI image from AWS EC2 - meaning that Kafka environment was already set up in that image contents beforehand.

However, it seems that the images have been created with Kafka environment still running (i.e. the services were not stopped before triggering creation of the AMI). This caused the Zookeeper service to have a stale session ID:

Error while creating ephemeral at /brokers/ids/1001, node already exists and owner '12342534412345' does not match current session '987797987987' ....

Restarting both ZooKeeper and the affected brokers did not solve the problem. The only solution I have found was to use zookeeper-shell tool (thank you @OneCricketeer for suggesting that first). Here's what I did (replace that silly IP address with your actual ZooKeeper broker IP address):

[root@ip-251-252-253-254 ec2-user]# zookeeper-shell 251.252.253.254:2181
Welcome to ZooKeeper!
JLine support is disabled

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
ls /brokers/ids                           <--------------- first command: list contents under brokers/ids to get the list of existing Kafka broker sessions
[1001]                                    <--------------- this is the stale session, need to get rid of it
delete /brokers/ids/1001                  <--------------- second command: delete the session for broker ID 1001
                                          <--------------- zookeeper-shell does not give any output when a command is successful
quit                                      <--------------- third command: exit zookeeper-shell tool

After doing this, I restarted Kafka service in the failed broker and it started successfully.

Hope it helps!

Upvotes: 0

seyon10
seyon10

Reputation: 11

Restart the zookeeper and the broker is fixed the issue for me. If you using the docker-compose, you can restart simply by using

docker-compose restart

Upvotes: 1

Kavita
Kavita

Reputation: 11

The only solution which works here is restart the broker and then restart the server.

Upvotes: 0

OneCricketeer
OneCricketeer

Reputation: 191963

The error is saying a broker already is running with id=0, or that Zookeeper is corrupt because a broker did not previously cleanly shut down...

In the later case, you can attempt to use zookeeper-shell to rmr /brokers/ids/0, however, this might have more unintended consequences than preforming a restart of Zookeeper as well as the brokers

Upvotes: 6

Related Questions