There are several methods to find the Kafka version in a Linux environment:
1. Using Kafka Command-Line Tools
Kafka includes several command-line utilities. You can use kafka-topics.sh to view the version information. Here are the steps:
- Open a terminal.
- Run the following command:
bash
kafka-topics.sh --version
This command displays the Kafka version.
2. Checking Kafka JAR Files
In the Kafka installation directory, there is typically a libs directory containing all the JAR files. The Kafka version is often indicated in the JAR file names. Steps:
- Navigate to the Kafka installation directory.
- Change to the
libsdirectory:bashcd /path/to/kafka/libs - Use the
lscommand to list the JAR files; you will see names like:bashls kafka_2.12-2.3.0.jar
The 2.3.0 in the filename is the Kafka version.
3. Checking Log Files
If Kafka is running, you can check its startup logs, which typically print the version information. Steps:
- Locate the Kafka log file; the path is typically
/var/log/kafka/kafka-server-start.log. - Use the
grepcommand to search for version information:bashgrep "Kafka version" /path/to/kafka/log/file.log
4. Using Kafka API
As a developer, you can write a simple Java program to retrieve the version information:
javaimport org.apache.kafka.common.utils.AppInfoParser; public class KafkaVersion { public static void main(String[] args) { System.out.println("Kafka version is: " + AppInfoParser.getVersion()); } }
This code outputs the Kafka version.
Summary
These are several methods to check the Kafka version in a Linux environment. In practice, the choice of method depends on your specific requirements and circumstances, such as whether you have the necessary permissions or if Kafka is running.