Silk0vsky
Silk0vsky

Reputation: 1032

Kafka's log directories should only contain Kafka topic data

I'm trying to run confluent kafka image in kubernetes environment & facing

FATAL [KafkaServer id=0] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
kafka.common.KafkaException: Found directory /var/lib/kafka/data, 'data' is not in the form of topic-partition or topic-partition.uniqueId-delete (if marked for deletion).
Kafka's log directories (and children) should only contain Kafka topic data.

My deployment config:

apiVersion: apps/v1beta2 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: kafka-confluent
  labels:
    app: kafka-confluent
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kafka-confluent
  template:
    metadata:
      labels:
        app: kafka-confluent
    spec:
      containers:
      - name: zookeeper-kafka
        image: zookeeper:3.5
        ports:
        - containerPort: 2181
      - name: kafka-confluent
        image: confluentinc/cp-kafka:4.0.0
        ports:
        - containerPort: 9092
        command:
        - sh
        - -c
        - "exec kafka-server-start /etc/kafka/server.properties \
          --override reserved.broker.max.id=2147483647 \
          --override zookeeper.connect=localhost:2181 \
          --override listeners=PLAINTEXT://:9092 \
          "

To solve this I've tried to mount some ephemeral volume like this.

volumes:
- name: kafka-data
  emptyDir: {}
...
volumeMounts:
- mountPath: /var/lib/kafka/data
  name: kafka-data

And clear the data dir with init container:

containers:
- name: cleaner
  image: busybox
  command: ['rm', '-rf', '/var/lib/kafka/data/*']

Both tries failed with the same result.

Also If I run the image & list the data /var/lib/kafka/data/ Looks like the directory is empty.

docker run --rm -it confluentinc/cp-kafka:4.0.0 bash
root@35087653f43a:/# ls /var/lib/kafka/data/ -al
total 8
drwxrwxrwx 2 root root 4096 Apr 16 09:59 .
drwxr-xr-x 3 root root 4096 Jan  3 19:20 ..

Upvotes: 1

Views: 6374

Answers (3)

asifaftab87
asifaftab87

Reputation: 1433

in my windows system I added this

log.dirs=F:\softwares\kafka_2.12-2.5.1\data

server.properties where

F:\softwares\kafka_2.12-2.5.1
is my kafka directory and issue resolved here I created data folder inside kafka directory, it was not there when I extracted kafka from 7zip tool.

Upvotes: 0

Ronald Cardenas
Ronald Cardenas

Reputation: 146

is it your error? enter image description here

Fix add this:

log.dirs=/var/lib/kafka/data

in server.properties

Upvotes: 3

Nicola Ben
Nicola Ben

Reputation: 11317

I have this working configuration:

volumeMounts:
        - name: data
          mountPath: /var/lib/kafka

and in the command, override the log.dirs

kafka-server-start /etc/kafka/server.properties \
    --override log.dirs=/var/lib/kafka

Upvotes: 1

Related Questions