Apache kafka Multi Broker Cluster Single Node Zookeeper
Apache kafka Multi Broker Cluster Single Node Zookeeper
Since we are running zookeper in single machine, we will run in mutiple ports
Create multiple configurations
aux-137@thashitharan:~/kafka/kafka_2.12-1.1.0$ cp config/server.properties config/servertwo.propertiesaux-137@thashitharan:~/kafka/kafka_2.12-1.1.0$ cp config/server.properties config/serverthree.properties
Change 'broker.id=1' (unique id), 'port=9093', 'log.dirs=/tmp/kafka-logs-1' (Identify logs)
aux-137@thashitharan:~/kafka/kafka_2.12-1.1.0$ nano config/servertwo.propertiesChange 'broker.id=2' (unique id), 'port=9094', 'log.dirs=/tmp/kafka-logs-2' (Identify logs)
aux-137@thashitharan:~/kafka/kafka_2.12-1.1.0$ nano config/serverthree.propertiesNo need to change zookeeper port as all 3 brokers report to the same zookeeper
Start zookeeper
aux-137@thashitharan:~/kafka/kafka_2.12-1.1.0$ bin/zookeeper-server-start.sh config/zookeeper.propertiesStart first broker
aux-137@thashitharan:~/kafka/kafka_2.12-1.1.0$ bin/kafka-server-start.sh config/server.propertiesStart second broker
aux-137@thashitharan:~/kafka/kafka_2.12-1.1.0$ bin/kafka-server-start.sh config/servertwo.propertiesStart third broker
aux-137@thashitharan:~/kafka/kafka_2.12-1.1.0$ bin/kafka-server-start.sh config/serverthree.propertiesCreate new topic
aux-137@thashitharan:~/kafka/kafka_2.12-1.1.0$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic replicationtopicStart the producer (list of all the broker in our cluster), mention the topic
aux-137@thashitharan:~/kafka/kafka_2.12-1.1.0$ bin/kafka-console-producer.sh --broker-list localhost:9092, localhost:9093, localhost:9094 --topic replicationtopicStart the consumer
aux-137@thashitharan:~/kafka/kafka_2.12-1.1.0$ bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic replicationtopicCheck fault tolerance
Find process id
aux-137@thashitharan:~/kafka/kafka_2.12-1.1.0$ lsof -i:9093 |grep LISTENkill the process
aux-137@thashitharan:~/kafka/kafka_2.12-1.1.0$ kill -15 19168Still consumer can receive the message
Comments
Post a Comment