Book Image

Apache Kafka Cookbook

By : Saurabh Minni
Book Image

Apache Kafka Cookbook

By: Saurabh Minni

Overview of this book

<p>This book will give you details about how to manage and administer your Apache Kafka Cluster.</p> <p>We will cover topics like how to configure your broker, producer, and consumer for maximum efficiency for your situation. Also, you will learn how to maintain and administer your cluster for fault tolerance. We will also explore tools provided with Apache Kafka to do regular maintenance operations. We shall also look at how to easily integrate Apache Kafka with big data tools like Hadoop, Apache Spark, Apache Storm, and Elasticsearch.</p>
Table of Contents (15 chapters)
Apache Kafka Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Decommissioning brokers


With expanding the Kafka cluster also comes the scenario under which you might have to remove some nodes. The decommissioning of brokers is not automatic and you need to generate and apply the reassignment settings so that the replicas are moved to the other remaining brokers.

Getting ready

You should have a Kafka cluster up-and-running with at least three nodes. You can now create a topic with a replication factor of 3.

How to do it...

You can gracefully shutdown one of the broker nodes that you want to decommission. Once that broker node has shut down gracefully, perform the following steps:

  1. Create a JSON file named change-replication-factor.json with the following code:

    {"version":1,
    "partitions":[{"topic":"mytesttopic","partition":0,"replicas":[1,2]}]}
  2. Run the following command:

    > bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file change-replication-factor.json --execute
    

How it works…

After you have gracefully shut down the node you...