[Kafka Cookbook] Installation

In this part, we shall quickly look at the installation of Apache Kafka. For all post hence forth we shall assume that JDK is installed. To use Apache Kafka, we would need a working Apache Zookeeper ensemble.

Installing Apache Zookeeper

Download Apache Zookeeper and un-zip the files into a folder. We shall refer the same as ZOOKEEPER_HOME

Once we have Zookeeper installed, lets start it. See the command below
zoo.cfg does not exist in default installation. rename zoo-sample.cfg to zoo.cfg

bash-3.2$ bin/zkServer.sh start
JMX enabled by default
Using config: /Users/ashishpaliwal/tools/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
bash-3.2$

This is single Zookeeper installation. For production scenario, you would need a Zookeeper cluster

Installing Apache Kafka

Download Apache Kafka. Once downloaded, extract it. We shall refer to this as KAFKA_HOME

Let’s start Apache Kafka

$bin/kafka-server-start.sh config/server.properties

Kafka shall print a lot of debug statements on console and prints following at the end

[2015-06-25 13:13:08,163] INFO zookeeper state changed (SyncConnected) (org.I0Itec.zkclient.ZkClient)
[2015-06-25 13:13:08,250] INFO Log directory '/tmp/kafka-logs' not found, creating it. (kafka.log.LogManager)
[2015-06-25 13:13:08,264] INFO Loading logs. (kafka.log.LogManager)
[2015-06-25 13:13:08,271] INFO Logs loading complete. (kafka.log.LogManager)
[2015-06-25 13:13:08,272] INFO Starting log cleanup with a period of 300000 ms. (kafka.log.LogManager)
[2015-06-25 13:13:08,275] INFO Starting log flusher with a default period of 9223372036854775807 ms. (kafka.log.LogManager)
[2015-06-25 13:13:08,305] INFO Awaiting socket connections on 0.0.0.0:9092. (kafka.network.Acceptor)
[2015-06-25 13:13:08,305] INFO [Socket Server on Broker 0], Started (kafka.network.SocketServer)
[2015-06-25 13:13:08,382] INFO Will not load MX4J, mx4j-tools.jar is not in the classpath (kafka.utils.Mx4jLoader$)
[2015-06-25 13:13:08,421] INFO 0 successfully elected as leader (kafka.server.ZookeeperLeaderElector)
[2015-06-25 13:13:08,495] INFO Registered broker 0 at path /brokers/ids/0 with address 17.244.225.59:9092. (kafka.utils.ZkUtils$)
[2015-06-25 13:13:08,506] INFO [Kafka Server 0], started (kafka.server.KafkaServer)
[2015-06-25 13:13:08,567] INFO New leader is 0 (kafka.server.ZookeeperLeaderElector$LeaderChangeListener)

Cool, Apache Kafka is up and running

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.