Skip to main content

Multi Node Apache Kafka 0.9 in Linux

Manually Deploying Apache Kafka

Please Install Java version 8 before proceeding the Kafka installation.
1) Edit the /etc/hostname in each node.

        vi /etc/hostname

                   kafka1 or kafka2 or kafka3

2) Check hostname.

        $ hostname

3)  Confirm everything went right.

     $ sudo hostname -F /etc/hostname

4) Now edit /etc/hosts to point one node to other nodes and do the same in each node.

     $ nano /etc/hosts

         127.0.0.1       localhost
127.0.1.1       ubuntu
<IP of node1 >   kafka1
<IP of node2>    kafka2
<IP of node3>    kafka3
# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

5) Reboot each node.

6) Download Scala and untar it in all nodes.

    Add following below command in .bashrc

$ export SCALA_HOME=/root/scala-2.11.7
$ export PATH=$PATH:$SCALA_HOME/bin

7) Download Apache Kafka and untar it in all nodes and do the following commands.

$ cd kafka/config/
$ vi zookeeper.properties

dataDir=/root/zookeeper
# the port at which the clients will connect
clientPort=2181
# disable the per-ip limit on the number of connections since this is a non-production config
maxClientCnxns=0
initLimit=5
syncLimit=2
server.1=kafka1:2888:3888
server.2=kafka2:2888:3888
server.3=kafka3:2888:3888

$ vi server.properties in all nodes

               broker.id=<1 or 2 or 3>
               listeners=PLAINTEXT://:9092
               port=9092
               host.name=<kafka1 or kafka2 or kafka3>
               advertised.host.name=<IP of node>
               advertised.port=9092 
               log.retention.ms=86400000
               log.roll.ms=86400000
               log.cleaner.delete.retention.ms=10000
               log.flush.interval.messages=1000000
               log.flush.scheduler.interval.ms=60000
               log.cleaner.threads=4
               log.segment.bytes=1073741824
               log.retention.check.interval.ms=3000
               log.cleaner.enable=true
               zookeeper.connect=kafka1:2181,kafka2:2181,kafka3:2181
               zookeeper.connection.timeout.ms=30000
               delete.topic.enable = true
               auto.create.topics.enable = true
               default.replication.factor=2
               auto.leader.rebalance.enable=true
               controlled.shutdown.enable=true
               controller.socket.timeout.ms=120000

Create a path directory that you have defined in zookeeper.properties file in key dataDir and then within dataDir directory touch a file myid. Now edit myid file and write same value as you have defined in the key broker.id of server.properties.

8) Automatically start Kafka on Reboot (in all nodes) 

      $ cd /etc/init

      $ vi kafka.conf

kill timeout 300
start on runlevel [2345]
stop on runlevel [06]
script
    KAFKA_HOME=/root/kafka_2.10-0.9.0.0
    nohup $KAFKA_HOME/bin/zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties > /root/zookeeper.log 2>&1 &
    sleep 30
    nohup $KAFKA_HOME/bin/kafka-server-start.sh $KAFKA_HOME/config/server.properties > /root/kafka.log 2>&1 &
end script

Comments

Popular posts from this blog

StandAlone Apache Storm Installation in Ubuntu 14.04 LTS

Deploying Apache Storm  1) If Java 7 is not present, please install it. 2) Zookeeper Installation Download zookeeper-3.4.6 from Apache site       $ tar -xvf zookeeper-3.4.6.tar.gz       $ cd zookeeper-3.4.6/       $ cp conf/zoo_sample.cfg conf/zoo.cfg       $ bin/zkServer.sh start 3) Storm Cluster Installation Download the storm tarball from official Apache Mirror.  Untar it.       $ tar xzvf apache-storm-0.9.2-incubating.tar.gz Move to new directory.       $ sudo cp -R apache-storm-0.9.2-incubating /usr/lib/ Go to /usr/lib/apache-storm-0.9.2-incubating/ and configure storm.yaml present in conf folder, add the followuing line, this folder must have write permissions too. storm.zookeeper.servers:     - "localhost" storm.zookeeper.port: 2181 nimbus.host: "localhost" storm.local.dir: "/var/stormtmp"    ...

Replace GRUB With BURG to Beautify Boot Menu, Install in Ubuntu via PPA

Burg is boot loader forked of GRUB loader. It uses a new object format which allows it to be built in a wider range of OS, including Linux/Windows/OSX/Solaris/FreeBSD, etc. It also has a highly configurable menu system which works in both text and graphic mode. Additional features like stream support and multiple input/output device are also planned for BURG. BURG features superior theming and has a highly configurable menu system which works at boot time in both text and graphical mode. Since BURG is derived from GRUB, its configuration is similar in most respects. The main configuration file is /boot/burg/burg.cfg  and is usually generated automatically. You can create one by yourself or use  grub-customizer  to modify BRUG entries and other stuff. You can even design theme for BURG checkout this  link  for more details about BURG. All below images are from Noobslab Available for Ubuntu 14.04/14.10/12.04/Linux Mint 17/13 To install Burg with...

How to Re-enable Hibernation in Ubuntu 14.04

1) Open the terminal (Ctrl+alt+T) 2) type: sudo gedit /var/lib/polkit-1/localauthority/10-vend ­or.d/com.ubuntu.desktop.pkla 3) Enter your password when requested. 4) Search for the section  [Disable hibernate by default in upower] Identity=unix-user:* Action=org.freedesktop.upower.hibernate ResultActive=no [Disable hibernate by default in logind] Identity=unix-user:* Action=org.freedesktop.login1.hibernate ResultActive=no 5) Change both value of "ResultActive=no" to "ResultActive=yes" 6) Save and close the editor. 7) Log out and then log back in, or reboot the system. You are now good to go!