LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub

Upgrade Kafka Cluster

Note: After upgrade to 2.2.1, we have upgraded the testnet to 2.3.1 recently by following the same process.

In the previous section, we have written down the steps to install a Kafka cluster on test1/test2/test3 VMs. The installed version is 2.0.0, which was the latest at the time of the installation.

The current latest version is 2.2.1, and we are going to upgrade our test cluster to the latest version and see if the data file is compatible.

Prepare VMs

Before upgrading to the latest Kafka, we first make sure that Ubuntu 18.04 is upgraded to the most recent. Log in to each of the VM and run the following commands.

sudo apt update
sudo apt upgrade

Download Kafka

Kafka was installed in the /opt folder before. Let’s download the latest package to the same folder on each server.

cd /opt
sudo wget http://mirror.csclub.uwaterloo.ca/apache/kafka/2.2.1/kafka_2.12-2.2.1.tgz

For Kafka 2.3.1 version.

cd /opt
sudo wget http://mirror.dsrg.utoronto.ca/apache/kafka/2.3.1/kafka_2.12-2.3.1.tgz

Shutdown

First, let’s shutdown all the services that are depending on the Kafka. My services are running in docker containers and it can be checked with docker ps

Once the docker instances are found, shutdown them with the docker-compose command.

Once the services are down, we need to shut down the Kafka on three servers. As you have learned, the Kafka is running as Linux service on each server. We need to shut down Kafka first and then Zookeeper second.

sudo systemctl stop kafka
sudo systemctl stop zookeeper

Backup

If there are previous kafka-logs.tar.gz, zookeeper.tar.gz and kafka.bak folder, remove them before the backup.

Now, let’s backup the data for both Kafka and Zookeeper.

Kafka data is located in /opt/kafka-logs and Zookeeper data is located at /var/zookeeper

cd /opt
sudo tar -czvf kafka-logs.tar.gz kafka-logs
cd /var
sudo tar -czvf zookeeper.tar.gz zookeeper

Now, let’s move the kafka folder to kakfa.bak

cd /opt
sudo mv kafka kafka.bak

Unzip

cd /opt
sudo mkdir -p /opt/kafka
sudo tar -xf kafka_2.12-2.2.1.tgz -C /opt/kafka --strip-components=1
sudo chown -R kafka:kafka /opt/kafka

For version 2.3.1

sudo tar -xf kafka_2.12-2.3.1.tgz -C /opt/kafka --strip-components=1

Update config

Edit zookeeper.properties

su - kafka
vi config/zookeeper.properties
dataDir=/var/zookeeper
 
server.1=38.113.162.51:2888:3888
server.2=38.113.162.52:2888:3888
server.3=38.113.162.53:2888:3888
#add here more servers if you want
initLimit=5
syncLimit=2

Edit server.properties

vi config/server.properties

Update the following configuration

broker.id=0 # for test1 host, increase for test2 and test3
log.dirs=/opt/kafka-logs # directory we created in the previous step
num.partitions=3
offsets.topic.replication.factor=3
# change IP for test2 and test3
advertised.listeners=PLAINTEXT://38.113.162.51:9092 
zookeeper.connect=38.113.162.51:2181,38.113.162.52:2181,38.113.162.53:2181

Start Zookeeper

To start Zookeeper and Kafka, we need to exit kafka user as it is not in the sudo list.

sudo systemctl start zookeeper

After three servers are up and running, check the zookeeper with

echo mntr | nc localhost 2181

You should see one of the servers has zk_synced_followers 2 which indicates the master server.

Start Kafka

sudo systemctl start kafka

To ensure that Kafka works, issue the following commands.

su - kafka
bin/kafka-topics.sh --list --zookeeper localhost:2181

At this moment, we have upgraded the Kafka to 2.2.1 and kept the existing data. You may start your services that are depending on the Kafka cluster.

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Upgrade Kafka Cluster” was last updated: July 5, 2021: fixes #275 checked and corrected grammar/spelling for majority of pages (#276) (b3bbb7b)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute