4.2.4 Upgrading Kafka
Creating Backup for Kafka Log Files
- Create a backup of the Kafka data:
cd /u02/kafka
mkdir backup
cp -r kafka-logs backup/
cp -r zookeeper backup/
Upgrading Kafka Broker
- Go to Kafka home folder:
cd /u01/app/kafka
. - Stop Kafka broker services by running the command:
sudo systemctl stop kafka.service
. - Create a backup folder, by running the command,
mkdir backup
, and move all files into the backup folder. - Copy the Kafka 3.4.0 zip and extract the folder contents.
- Move all the extracted files to Kafka parent folder:
/u01/app/kafka
. - Copy config folder files from the backup to the config folder of the new kafka.
- Open the
server.property
file under the config folder and add the following parameters:inter.broker.protocol.version=<version_you_are_upgrading_from>
For example,inter.broker.protocol.version=2.1.1
log.message.format.version=<version_you_are_upgrading_from>
For example,log.message.format.version=2.1.1
- Start the broker by running the command,
sudo systemctl restart kafka.service
, and wait for a few minutes for the cluster to stabilize; check logs for any issues. - Stop the broker again by running the command,
sudo systemctl stop kafka.service
, and update the protocol again. - Stop the broker by running the command,
sudo systemctl stop kafka.service
, and update the message format. - Start the broker by running the command,
sudo systemctl restart kafka.service
, and wait for a few minutes for the cluster to stabilize; check logs for any issues. - Start the broker by running the command ,
sudo systemctl restart kafka.service
, and wait for a few minutes for the cluster to stabilize; check logs for any issues.
Now you have the latest Kafka broker running.
Upgrading Zookeeper
- Go to Kafka parent folder i.e /u01/app/kafka
- Stop kafka broker and kafka-zookeeper by running the following commands:
sudo systemctl stop kafka.service
sudo systemctl stop kafka-zookeeper.service
- Go to config folder and open zookeeper.properties file
- Add
admin.serverPort
property in the file and assign it to some port number which is not being used by any other services:admin.serverPort=9876
or to disable this feature, setadmin.enableServer=false
-
Start the zookeeper by running the command,
sudo systemctl restart kafka-zookeeper.service
.- Check if the zookeeper services are up, by running the command,
ggsa-services
. - If the services are not up, check the zookeeper logs for errors.
- If the error is related to snapshot, then download the snapshot file from https://issues.apache.org/jira/browse/ZOOKEEPER-3056, and copy it to the location,
/u02/kafka/zookeeper/version-2/
. - Open the zookeeper.properties file, add the property,
zookeeper.snapshot.trust.empty=true
, and restart the zookeeper by running the command,sudo systemctl restart kafka-zookeeper.service
.
- Check if the zookeeper services are up, by running the command,
- After the zookeeper gets started, start the Kafka broker by running the command,
sudo systemctl restart kafka.service
. - Check if the services
kafka.service
andkafka-zookeeper.service
are running fine.
Now you have an upgraded Kafka.