Upgrade the Apache Kafka version
You can upgrade an existing MSK cluster to a newer version of Apache Kafka.
Note
-
You can't upgrade an existing MSK cluster from a ZooKeeper-based Apache Kafka version to a newer version that uses or requires KRaft mode. Instead, to upgrade your cluster, create a new MSK cluster with a KRaft-supported Kafka version and migrate your data and workloads from the old cluster.
-
Amazon MSK only upgrades the server software. It doesn't upgrade your clients.
-
You can't downgrade an existing MSK cluster to an older version of Apache Kafka.
When you upgrade the Apache Kafka version of an MSK cluster, also check your client-side software to make sure its version enables you to use the features of the cluster's new Apache Kafka version.
For information about how to make a cluster highly available during an upgrade, see Build highly available clusters.
Upgrade the Apache Kafka version using the AWS Management Console
Open the Amazon MSK console at https://console.aws.amazon.com/msk/
. -
In the navigation bar, choose the Region where you created the MSK cluster.
-
Choose the MSK cluster which you want to upgrade.
-
On the Properties tab, choose Upgrade in the Apache Kafka version section.
-
In the Apache Kafka version section, do the following:
-
In the Choose Apache Kafka version dropdown list, choose the version to which you want to upgrade. For example, choose
3.9.x
. -
(Optional) Choose Version compatibility to view the compatibility between your cluster's current version and the version to which you want to upgrade. Then, choose Choose to proceed or choose Cancel.
-
Choose the Update cluster configuration checkbox to automatically apply a new Kafka configuration revision that's compatible with the upgraded version. This ensures compatibility and enables new features or improvements of the upgraded version. However, skip it if you want to maintain your existing custom configurations.
-
Choose Upgrade.
-
Upgrade the Apache Kafka version using the AWS CLI
Run the following command, replacing
ClusterArn
with the Amazon Resource Name (ARN) that you obtained when you created your cluster. If you don't have the ARN for your cluster, you can find it by listing all clusters. For more information, see List Amazon MSK clusters.aws kafka get-compatible-kafka-versions --cluster-arn
ClusterArn
The output of this command includes a list of the Apache Kafka versions to which you can upgrade the cluster. It looks like the following example.
{ "CompatibleKafkaVersions": [ { "SourceVersion": "2.2.1", "TargetVersions": [ "2.3.1", "2.4.1", "2.4.1.1", "2.5.1" ] } ] }
-
Run the following command, replacing
ClusterArn
with the Amazon Resource Name (ARN) that you obtained when you created your cluster. If you don't have the ARN for your cluster, you can find it by listing all clusters. For more information, see List Amazon MSK clusters.Replace
Current-Cluster-Version
with the current version of the cluster. ForTargetVersion
you can specify any of the target versions from the output of the previous command.Important
Cluster versions aren't simple integers. To find the current version of the cluster, use the DescribeCluster operation or the describe-cluster
AWS CLI command. An example version is KTVPDKIKX0DER
.aws kafka update-cluster-kafka-version --cluster-arn
ClusterArn
--current-versionCurrent-Cluster-Version
--target-kafka-versionTargetVersion
The output of the previous command looks like the following JSON.
{ "ClusterArn": "arn:aws:kafka:us-east-1:012345678012:cluster/exampleClusterName/abcdefab-1234-abcd-5678-cdef0123ab01-2", "ClusterOperationArn": "arn:aws:kafka:us-east-1:012345678012:cluster-operation/exampleClusterName/abcdefab-1234-abcd-5678-cdef0123ab01-2/0123abcd-abcd-4f7f-1234-9876543210ef" }
-
To get the result of the
update-cluster-kafka-version
operation, run the following command, replacingClusterOperationArn
with the ARN that you obtained in the output of theupdate-cluster-kafka-version
command.aws kafka describe-cluster-operation --cluster-operation-arn
ClusterOperationArn
The output of this
describe-cluster-operation
command looks like the following JSON example.{ "ClusterOperationInfo": { "ClientRequestId": "62cd41d2-1206-4ebf-85a8-dbb2ba0fe259", "ClusterArn": "arn:aws:kafka:us-east-1:012345678012:cluster/exampleClusterName/abcdefab-1234-abcd-5678-cdef0123ab01-2", "CreationTime": "2021-03-11T20:34:59.648000+00:00", "OperationArn": "arn:aws:kafka:us-east-1:012345678012:cluster-operation/exampleClusterName/abcdefab-1234-abcd-5678-cdef0123ab01-2/0123abcd-abcd-4f7f-1234-9876543210ef", "OperationState": "UPDATE_IN_PROGRESS", "OperationSteps": [ { "StepInfo": { "StepStatus": "IN_PROGRESS" }, "StepName": "INITIALIZE_UPDATE" }, { "StepInfo": { "StepStatus": "PENDING" }, "StepName": "UPDATE_APACHE_KAFKA_BINARIES" }, { "StepInfo": { "StepStatus": "PENDING" }, "StepName": "FINALIZE_UPDATE" } ], "OperationType": "UPDATE_CLUSTER_KAFKA_VERSION", "SourceClusterInfo": { "KafkaVersion": "2.4.1" }, "TargetClusterInfo": { "KafkaVersion": "2.6.1" } } }
If
OperationState
has the valueUPDATE_IN_PROGRESS
, wait a while, then run thedescribe-cluster-operation
command again. When the operation is complete, the value ofOperationState
becomesUPDATE_COMPLETE
. Because the time required for Amazon MSK to complete the operation varies, you might need to check repeatedly until the operation is complete.
Upgrade the Apache Kafka version using the API
Invoke the GetCompatibleKafkaVersions operation to get a list of the Apache Kafka versions to which you can upgrade the cluster.
Invoke the UpdateClusterKafkaVersion operation to upgrade the cluster to one of the compatible Apache Kafka versions.