Starting Kafka Servers
Lets download Kafka & Zookeeper.
- Kafka: Can be downloaded here from the Apache site.
- Zookeeper: Can be downloaded here from the Apache site.
➠
Starting Zookeeper
- Unzip the download zookeeper & Go to inside zookeeper folder
$ cd ~/zookeeper-3.4.10
- create zookeeper configuration file from the sample config file provided by Apache.
$ cp conf/zoo_sample.cfg conf/zoo.cfg
- Starting the zookeeper server.
$ ./bin/zkServer.sh start
Output:
ZooKeeper JMX enabled by default
Using config: ~/zookeeper-3.4.10/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
- Checking the status of zookeeper server
$ ./bin/zkServer.sh status
Output:
ZooKeeper JMX enabled by default
Using config: ~/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: standalone
➠
Starting Kafka Broker
- Unzip the download kafka & Go to inside kafka folder
$ cd ~/kafka_2.11-1.1.0
- Starting the kafka broker server.
./bin/kafka-server-start.sh ./config/server.properties
➠
Creating multiple brokers
- Create as many copies of server.properties as many brokers need to be created, here 2 brokers are being created.
$ cp config/server.properties config/server-1.properties
$ cp config/server.properties config/server-2.properties
- Update properties in server-1.properties file with below mentioned detail.
broker.id=1
port=9093
log.dir=/tmp/kafka-logs-1
- Update properties in server-2.properties file with below mentioned detail.
broker.id=2
port=9094
log.dir=/tmp/kafka-logs-2
- Starting new brokers
./kafka-server-start.sh ../config/server-1.properties
./kafka-server-start.sh ../config/server-2.properties