178

How to find the kafka version in linux? whether there is a way to find the installed kafka version other than mentioning the version while downloading it?

kumar
  • 2,905
  • 5
  • 22
  • 26

16 Answers16

130

Not sure if there's a convenient way, but you can just inspect your kafka/libs folder. You should see files like kafka_2.10-0.8.2-beta.jar, where 2.10 is Scala version and 0.8.2-beta is Kafka version.

serejja
  • 22,901
  • 6
  • 64
  • 72
122

Kafka 2.0 have the fix(KIP-278) for it:

kafka-topics.sh --version 

Or

kafka-topics --version

Using confluent utility:

Kafka version check can be done with confluent utility which comes by default with Confluent platform(confluent utility can be added to cluster separately as well - credits cricket_007).

${confluent.home}/bin/confluent version kafka

Checking the version of other Confluent platform components like ksql schema-registry and connect

[confluent-4.1.0]$ ./bin/confluent version kafka
1.1.0-cp1

[confluent-4.1.0]$ ./bin/confluent version connect
4.1.0

[confluent-4.1.0]$ ./bin/confluent version schema-registry
4.1.0

[confluent-4.1.0]$ ./bin/confluent version ksql-server
4.1.0
mrsrinivas
  • 34,112
  • 13
  • 125
  • 125
  • 4
    That is still wrong, sorry (and it works for Kafka 2.0+ as well (confluent 5.x +). You have a **remotely running** Kafka cluster with **any version**, then `confluent version` does you no good. – OneCricketeer Jan 08 '19 at 18:30
  • When I use Confluent utility as you mentioned, I'm getting this error. Error: unknown command "kafka" for "confluent version" – i.am.jabi Dec 21 '20 at 10:30
  • what is the `confluent version`? – mrsrinivas Dec 22 '20 at 05:31
  • 1
    This gives the version of the "kafka-topics.sh" so you can not identify the version of Kafka actually running this way :-( – Samuel Åslund May 26 '21 at 08:23
53

There is nothing like kafka --version at this point. So you should either check the version from your kafka/libs/ folder or you can run

find ./libs/ -name \*kafka_\* | head -1 | grep -o '\kafka[^\n]*'

from your kafka folder (and it will do the same for you). It will return you something like kafka_2.9.2-0.8.1.1.jar.asc where 0.8.1.1 is your kafka version.

Salvador Dali
  • 214,103
  • 147
  • 703
  • 753
38

There are several methods to find kafka version

Method 1 simple:-

ps -ef|grep kafka

it will displays all running kafka clients in the console... Ex:- /usr/hdp/current/kafka-broker/bin/../libs/kafka-clients-0.10.0.2.5.3.0-37.jar we are using 0.10.0.2.5.3.0-37 version of kafka

Method 2:- go to

cd /usr/hdp/current/kafka-broker/libs
ll |grep kafka

Ex:- kafka_2.10-0.10.0.2.5.3.0-37.jar kafka-clients-0.10.0.2.5.3.0-37.jar

same result as method 1 we can find the version of kafka using in kafka libs.

notNull
  • 30,258
  • 4
  • 35
  • 50
28

You can grep the logs to see the version. Let's say kafka is installed under /usr/local/kafka, then:

$ grep "Kafka version" /usr/local/kafka/logs/*

/usr/local/kafka/logs/kafkaServer.out: INFO Kafka version : 0.9.0.1 (org.apache.kafka.common.utils.AppInfoParser)

will reveal the version

tolitius
  • 22,149
  • 6
  • 70
  • 81
10

If you want to check the version of a specific Kafka broker, run this CLI on the broker*

kafka-broker-api-versions.sh --bootstrap-server localhost:9092 --version

where localhost:9092 is the accessible <hostname|IP Address>:<port> this API will check (localhost can be used if it's the same host you're running this command on). Example of output:

2.4.0 (Commit:77a89fcf8d7fa018)

* Apache Kafka comes with a variety of console tools in the ./bin sub-directory of your Kafka download; e.g. ~/kafka/bin/

Ricardo
  • 3,696
  • 5
  • 36
  • 50
  • 3
    This seems to give the version of the "kafka-broker-api-versions.sh" so you can not identify the version of Kafka actually running this way :-( (Or at least when I run the same command with different versions of Kafka against the same running instance on localhost I gett different versions returned. – Samuel Åslund May 26 '21 at 08:29
  • Useful link: [KAFKA-4457. Add BrokerVersionCommand PR#2184](https://github.com/apache/kafka/pull/2184) – Ricardo May 28 '21 at 18:06
  • Related link: [Retrieving Supported API versions](https://kafka.apache.org/protocol#api_versions) – Ricardo May 28 '21 at 18:21
  • @SamuelÅslund, _This seems to give the version of the "kafka-broker-api-versions.sh"_ that doesn't make sense to me. Why would one write a command to output its own version? Its purpose should be providing the broker version. – Ricardo May 28 '21 at 18:27
  • Also it's not clear to me what you meant by _run the same command with different versions of Kafka against the same running instance_; I provided the link of the `kafka-broker-api-versions.sh` PR (Pull Request), so you can find its meaning, since it seem to lack proper documentation. I hope that helps you somehow. – Ricardo May 28 '21 at 18:28
  • 1
    The most intuitive of all the answers, let's vote to push this answer up! – jumping_monkey Nov 29 '21 at 12:18
7

Simple way on macOS e.g. installed via homebrew

$ ls -l $(which kafka-topics)
/usr/local/bin/kafka-topics -> ../Cellar/kafka/0.11.0.1/bin/kafka-topics
Hartmut
  • 725
  • 9
  • 11
5

You can use for Debian/Ubuntu:

dpkg -l|grep kafka

Expected result should to be like:

ii  confluent-kafka-2.11                   0.11.0.1-1                                 all          publish-subscribe messaging rethought as a distributed commit log
ii  confluent-kafka-connect-elasticsearch  3.3.1-1                                    all          Kafka Connect connector for copying data between Kafka and Elasticsearch
ii  confluent-kafka-connect-hdfs           3.3.1-1                                    all          Kafka Connect connector for copying data between Kafka and Hadoop HDFS
ii  confluent-kafka-connect-jdbc           3.3.1-1                                    all          Kafka Connect connector for JDBC-compatible databases
ii  confluent-kafka-connect-replicator     3.3.1-1                                    all          Kafka Connect connector for replicating topics between Kafka clusters
ii  confluent-kafka-connect-s3             3.3.1-1                                    all          Kafka Connect S3 connector for copying data between Kafka and
ii  confluent-kafka-connect-storage-common 3.3.1-1                                    all          Kafka Connect Storage Common contains packages used by storage
ii  confluent-kafka-rest                   3.3.1-1                                    all          A REST proxy for Kafka
Kalin Borisov
  • 1,091
  • 1
  • 12
  • 23
5

cd kafka

./bin/kafka-topics.sh --version

Smaillns
  • 2,540
  • 1
  • 28
  • 40
4

go to kafka/libs folder we can see multiple jars search for something similar kafka_2.11-0.10.1.1.jar.asc in this case the kafka version is 0.10.1.1

MD5
  • 1,356
  • 15
  • 14
4

I found an easy way to do this without searching directories or log files:

kafka-dump-log --version

Output looks like this:

5.3.0-ccs (Commit:6481debc2be778ee)

TBowman
  • 615
  • 4
  • 15
0

When you install Kafka in Centos7 with confluent :

yum install confluent-platform-oss-2.11

You can see the version of Kafka with :

yum deplist confluent-platform-oss-2.11

You can read : confluent-kafka-2.11 >= 0.10.2.1

Karima Rafes
  • 1,016
  • 10
  • 19
0

To find the Kafka Version, We can use the jps command which show all the java processes running on the machine.

Step 1: Let's say, you are running Kafka as the root user, so login to your machine with root and use jps -m. It will show the result like

4979 Jps -m
9434 Kafka config/server.properties

Step 2: From the above result, you can take the PID for Kafka application and use pwdx 9434 which reports the current directory of the process. the result will be like

9434: /apps/kafka_2.12-2.4.0

here you can see the Kafka version which is 2.12-2.4.0

theNextBigThing
  • 131
  • 3
  • 14
0
cd confluent-7.2.0/share/java/kafka

then

$ ls -lha | grep kafka
-rw-r--r--  1 root root 5.3M Jul  5 09:45 kafka_2.13-7.2.0-ccs.jar
-rw-r--r--  1 root root 4.8M Jul  5 09:45 kafka-clients-7.2.0-ccs.jar
lrwxrwxrwx  1 root root   26 Jul 23 10:10 kafka.jar -> ./kafka_2.13-7.2.0-ccs.jar
-rw-r--r--  1 root root 9.4K Jul  5 09:45 kafka-log4j-appender-7.2.0-ccs.jar
-rw-r--r--  1 root root 458K Jul  5 09:45 kafka-metadata-7.2.0-ccs.jar
-rw-r--r--  1 root root 182K Jul  5 09:45 kafka-raft-7.2.0-ccs.jar
-rw-r--r--  1 root root  36K Jul  5 09:45 kafka-server-common-7.2.0-ccs.jar
-rw-r--r--  1 root root  84K Jul  5 09:45 kafka-shell-7.2.0-ccs.jar
-rw-r--r--  1 root root 151K Jul  5 09:45 kafka-storage-7.2.0-ccs.jar
-rw-r--r--  1 root root  23K Jul  5 09:45 kafka-storage-api-7.2.0-ccs.jar
-rw-r--r--  1 root root 1.6M Jul  5 09:45 kafka-streams-7.2.0-ccs.jar
-rw-r--r--  1 root root  41K Jul  5 09:45 kafka-streams-examples-7.2.0-ccs.jar
-rw-r--r--  1 root root 161K Jul  5 09:45 kafka-streams-scala_2.13-7.2.0-ccs.jar
-rw-r--r--  1 root root  52K Jul  5 09:45 kafka-streams-test-utils-7.2.0-ccs.jar
-rw-r--r--  1 root root 127K Jul  5 09:45 kafka-tools-7.2.0-ccs.jar
amarVashishth
  • 847
  • 3
  • 12
  • 26
-1

You can also type

cat /build.info

This will give you an output like this

BUILD_BRANCH=master
BUILD_COMMIT=434160726dacc4a1a592fe6036891d6e646a3a4a
BUILD_TIME=2017-05-12T16:02:04Z
DOCKER_REPO=index.docker.io/landoop/fast-data-dev
KAFKA_VERSION=0.10.2.1
CP_VERSION=3.2.1
-1

To check kafka version :

cd /usr/hdp/current/kafka-broker/libs
ls kafka_*.jar
Shiva Garg
  • 826
  • 9
  • 17