Starting Kafka and Zookeeper Servers for creating kafka topics & altering various paramters

Starting Kafka Servers


Lets download Kafka & Zookeeper.

Starting Zookeeper
  1. Unzip the download zookeeper & Go to inside zookeeper folder
    $ cd ~/zookeeper-3.4.10 
    
  2. create zookeeper configuration file from the sample config file provided by Apache.
    $ cp conf/zoo_sample.cfg conf/zoo.cfg
    
  3. 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
    
  4. 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
  1. Unzip the download kafka & Go to inside kafka folder
    $ cd ~/kafka_2.11-1.1.0 
    
  2. Starting the kafka broker server.
    ./bin/kafka-server-start.sh ./config/server.properties
    

Creating multiple brokers
  1. 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
    
  2. Update properties in server-1.properties file with below mentioned detail.
    broker.id=1
    port=9093
    log.dir=/tmp/kafka-logs-1
    
  3. Update properties in server-2.properties file with below mentioned detail.
    broker.id=2
    port=9094
    log.dir=/tmp/kafka-logs-2
    
  4. Starting new brokers
    ./kafka-server-start.sh ../config/server-1.properties
    ./kafka-server-start.sh ../config/server-2.properties