KAFKA restart issue Unable to restart kafka without deleting /tmp/kafka-logs
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Kafka, widely known for being a robust distributed event streaming platform capable of handling large volumes of data, occasionally presents challenges regarding its management and operation. One common problem users may encounter is the inability to restart Kafka without deleting the /tmp/kafka-logs directory. Understanding why this issue arises and how to address it is crucial for maintaining the integrity and performance of Kafka services.
Understanding Kafka's Behavior
Kafka uses the /tmp/kafka-logs directory as the default location to store its logs unless configured otherwise. This directory contains the actual logs of messages that have been sent to Kafka. Deeper inside these logs are individual files used by Kafka to hold onto the different partitions of data contained within the topics of the broker.
Log Segments and Index Files
When Kafka starts, it reads its configuration and then attempts to load the log segments and their respective index files. Errors during this phase often lead to startup failures. Common reasons include:
- Corruption in Index Files: This can be caused by unexpected shutdowns, hardware failures, or software bugs.
- Misconfiguration: Changes in configurations, especially related to file paths and permissions, can hinder Kafka's ability to access needed files.
Analyzing Common Startup Errors
A typical error that stops Kafka from restarting may look like this:
This indicates a problem with the zookeeper session still thinking the old Kafka process exists because of which the new process cannot take over the broker ID.
Solutions
The primary solution involves examining and potentially modifying the log.dirs property in your Kafka server properties file. You might also need to evaluate the health of your Kafka logs and topics. Below are methods to address issues without having to delete /tmp/kafka-logs.
Configuring Multiple Log Directories
Kafka allows configuration of multiple log directories to spread the I/O and storage load:
This also provides redundancy in scenarios where one path fails.
Cleanup Policies
Adjusting Kafka's log cleanup policy could also help. There are two types: deletion and compaction. These settings control how old data is removed from log files:
Checking for Disk Issues
Ensure that the disk is not full and is functioning correctly. Disk-related issues could prevent Kafka from starting normally.
Proper Shutdown
Ensure that Kafka is shut down gracefully. A forced kill may leave behind corrupt index files or inconsistent broker IDs in ZooKeeper.
Tools and Commands
Use the kafka-topics.sh script to check the consistency and configuration of topics:
Also, inspecting the broker logs found in /log_dir/server.log could provide further insights into what could be preventing the restart.
Summary Table
| Issue | Explanation | Quick Solution |
| Corrupted Index Files | Caused by improper shutdowns or disk issues | Delete specific topic logs, use RAID for disks |
| Misconfiguration | Wrong log.dirs path or permissions | Specify correct paths and ensure permissions |
| Disk Problems | Full or failing disks | Check disk health, ensure sufficient space |
| Kafka/ZooKeeper Sync Issue | Ungraceful shutdown, stale ZooKeeper data | Restart ZooKeeper, then start Kafka |
Conclusion
Problems with restarting Kafka that necessitate deleting /tmp/kafka-logs are generally indicative of deeper issues such as configuration errors or disk problems. Addressing these root causes not only allows Kafka to restart smoothly but also enhances the overall stability and reliability of your Kafka installation. Always consider the implications of using /tmp for critical data and opt for more persistent, reliable storage solutions matched with proper Kafka configurations and regular maintenance protocols.
Related reading
- Kafka retention policies
- kafka retention policy didn't work as expected
- Kafka returns No matching PRIVATE KEY entries in PEM file when attempting to start using PEM certificates
- Kafka rolling restart active controller last performance benefits
- kafka s3 sink connector crashed when It gets NULL data
- Kafka Schema Registry getting error Unexpected character (''<'' (code 60)) expected a valid value (number, String, array, object, ''true'', ''false'')
- Kafka Running Confluent in a Windows environment
- Kafka running on zookeeper subcontext or chroot

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.