Under-replicated partitions alerts fire, but every broker is still up. One broker's log shows KafkaStorageException or IOExceptions for a single path. That is a JBOD log directory failure. The broker has taken that directory offline and keeps serving partitions from its other disks. Replicas on the failed disk are gone from that broker, and leadership for those partitions has moved elsewhere where an in-sync replica existed. This runbook shows how to find what is affected, deal with partitions that have no healthy copy, replace the disk and bring the replicas back.
Confirm it is a log directory failure
Check the broker log for the failed path:
grep -iE "KafkaStorageException|log dir|Stopp(ed|ing) serving" /var/log/kafka/server.log | tail -50
Ask the broker which directories it considers healthy. kafka-log-dirs.sh returns JSON. A failed directory has a non-null error, usually KafkaStorageException:
kafka-log-dirs.sh --bootstrap-server kafka1:9092 --describe --broker-list 2 \
| grep '^{' | jq '.brokers[].logDirs[] | {logDir, error, partitions: (.partitions | length)}'
On the host, confirm the OS sees the disk problem:
dmesg -T | grep -iE "i/o error|xfs|ext4" | tail -20
df -h /data2; mount | grep /data2
The JMX metric kafka.log:type=LogManager,name=OfflineLogDirectoryCount is above 0 on the affected broker. If you don't alert on it yet, add it after the incident.
Caution
Don't restart the broker yet. If the disk is still attached but faulty, a restart can fail during log recovery. In KRaft mode it can also fail to start if the failed directory is unformatted or unreadable. Find out what is at risk first.
Find the partitions at risk
# partitions with fewer in-sync replicas than replicas
kafka-topics.sh --bootstrap-server kafka1:9092 --describe --under-replicated-partitions
# partitions below min.insync.replicas: acks=all producers fail for these
kafka-topics.sh --bootstrap-server kafka1:9092 --describe --under-min-isr-partitions
# partitions with no leader: no reads or writes at all
kafka-topics.sh --bootstrap-server kafka1:9092 --describe --unavailable-partitions
| What you see | Impact | Action |
|---|---|---|
| Under-replicated only, ISR >= min.insync.replicas | No client impact; less redundancy | Replace the disk as planned |
| Under min ISR | acks=all producers get NOT_ENOUGH_REPLICAS | Urgent; see the next section |
Unavailable (leader none) | Partition is offline | The only in-sync copy was on the failed disk |
| RF=1 topics on the failed disk | Data is on that disk only | Recover the disk or accept the loss |
Partitions with no healthy replica
If a partition is offline and its only in-sync replica was on the failed disk, you have two choices.
- Get the disk back. If the failure was a controller, cable, or a filesystem that will mount after
fsck, the data may still be intact. Fix it, remount it at the same path and restart the broker. It recovers the logs and takes leadership back. - Unclean election. If an out-of-sync replica is still alive on another broker, you can make it leader:
kafka-leader-election.sh --bootstrap-server kafka1:9092 \
--election-type unclean --topic payments --partition 7
Caution
Unclean election loses every message the old leader had that the new leader didn't. Consumers may also see offsets go backwards. Agree on it with the data owner, record the offsets, and only do it when the disk can't be recovered.
Replace the disk
- Stop the broker in a controlled way. Its remaining partitions move to other brokers first. Make sure no other broker is down at the same time.
systemctl stop kafka
- Replace the disk. Create the filesystem, mount it at the same path listed in
log.dirs, and set ownership:
mkfs.xfs /dev/nvme2n1
mount /dev/nvme2n1 /data2 && grep /data2 /etc/fstab # check fstab uses the new UUID if you mount by UUID
chown -R kafka:kafka /data2
- KRaft only: every log directory needs a
meta.properties. Format only the new, empty directory.--ignore-formattedskips the directories that already have one. Take the cluster ID from a healthy directory:
grep cluster.id /data1/meta.properties
kafka-storage.sh format --config /etc/kafka/server.properties \
--cluster-id <cluster-id-from-above> --ignore-formatted
Check this against the kafka-storage.sh documentation for your exact version before you run it. Never format a directory that still holds data you need. In ZooKeeper mode you don't need to format. The broker writes meta.properties when it starts.
Warning
In KRaft mode, if the disk also held
metadata.log.dir, the broker shuts down instead of carrying on. Replace the disk the same way. The broker then fetches the metadata log again from the controllers.
Throttle the resync, then restart
When the broker starts with an empty directory, it refetches every replica that belonged on that disk from the current leaders. That can saturate the network and leader disks. Set a throttle before you start it:
# throttle rate on all brokers (bytes/sec); pick a value your network can spare
for b in 1 2 3; do
kafka-configs.sh --bootstrap-server kafka1:9092 --alter --entity-type brokers --entity-name $b \
--add-config leader.replication.throttled.rate=50000000,follower.replication.throttled.rate=50000000
done
# apply the throttle to every replica of the affected topics
kafka-configs.sh --bootstrap-server kafka1:9092 --alter --entity-type topics --entity-name payments \
--add-config 'leader.replication.throttled.replicas=*,follower.replication.throttled.replicas=*'
systemctl start kafka
Watch the under-replicated list shrink:
watch -n 30 "kafka-topics.sh --bootstrap-server kafka1:9092 --describe --under-replicated-partitions | wc -l"
When it reaches 0, remove the throttles. Then move leadership back to the preferred replicas so load is even again:
for b in 1 2 3; do
kafka-configs.sh --bootstrap-server kafka1:9092 --alter --entity-type brokers --entity-name $b \
--delete-config leader.replication.throttled.rate,follower.replication.throttled.rate
done
kafka-configs.sh --bootstrap-server kafka1:9092 --alter --entity-type topics --entity-name payments \
--delete-config leader.replication.throttled.replicas,follower.replication.throttled.replicas
kafka-leader-election.sh --bootstrap-server kafka1:9092 --election-type preferred --all-topic-partitions
Tip
Leftover throttles slow replication quietly for months. Check with
kafka-configs.sh --describe --entity-type brokers --alland--entity-type topics --all, and look forthrottledbefore you close the incident.
If you can't replace the disk soon
Run the broker without the disk until a replacement arrives:
- Leave it as it is. The broker keeps serving from its healthy disks. Affected partitions stay under-replicated, so one more failure can take them offline.
- Move the replicas to other brokers. Use
kafka-reassign-partitions.shwith a plan that moves each affected partition's replica from this broker to a healthy one. Throttle it the same way. This restores full redundancy without the disk. - Remove the path from
log.dirsand restart. The broker then recreates the affected replicas on its remaining disks. How this works differs between ZooKeeper mode and KRaft mode, which tracks directory assignments. Test it on your version before you rely on it, and make sure the remaining disks have room.
Prevent it next time
- Alert on
OfflineLogDirectoryCount > 0, under-min-ISR partitions and disk SMART/NVMe health, not only under-replicated partitions. - Use replication factor 3 and
min.insync.replicas=2for anything you can't lose. Find RF=1 topics withkafka-topics.sh --describeand fix them. - Keep data spread evenly across directories. Brokers place new partitions by partition count, not size, so check
kafka-log-dirs.shsizes and move large replicas between directories with a reassignment that setslog_dirs. - Leave enough free space on the other disks and brokers to absorb one failed disk.
- Write down the disk-replacement steps for your Kafka mode, including the KRaft format step, and rehearse them on a non-production cluster.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get