Migrating Apache Kafka® cluster hosts to a different availability zone
Managed Service for Apache Kafka® cluster hosts reside in Yandex Cloud availability zones. You can move Apache Kafka® hosts from one availability zone to another. The migration process is different for single-host and multi-host clusters.
Note
Clusters with hosts residing in the ru-central1-d availability zone do not support:
- Intel Broadwell
- Local SSD storage if using Intel Cascade Lake
If a Managed Service for Apache Kafka® cluster is an endpoint in Yandex Data Transfer, restart the transfer to make it work correctly. To find out which transfers to restart and how to do it, see Specifics of migration in Yandex Data Transfer.
Migrating a single-host cluster
You can migrate your cluster in the following ways:
-
Use the Yandex Cloud interfaces. In this case, the availability zone in the cluster configuration will change. You do not need to create an additional cluster.
This option is easier to implement; however, the cluster will remain idle during migration while changing its availability zone. This may take a few minutes.
-
Use auxiliary tools offered by MirrorMaker or Yandex Data Transfer. In this case, you need to create a new cluster and transfer data from the source cluster into it.
This option is more challenging to implement since it requires building and configuring the infrastructure. However, it allows you to avoid downtime: you can maintain two clusters with up-to-date data until you delete the source one.
Migrating a single-host cluster using Yandex Cloud interfaces
To move an Apache Kafka® host to a different availability zone in a Managed Service for Apache Kafka® cluster:
-
Create a subnet in the target availability zone.
-
If the cluster security group is set up for a subnet in the availability zone you are moving your cluster from, reconfigure the group for the new subnet. To do so, replace the source subnet CIDR with the new subnet CIDR in the security group rules.
-
Change the availability zone of your cluster and its Apache Kafka® host:
Management consoleCLITerraformREST APIgRPC API- In the management console
, navigate to the relevant folder. - Navigate to the Managed Service for Kafka service.
- In the cluster row, click
and select Edit. - Under Network settings, specify the new availability zone.
- If the new availability zone has multiple subnets, specify the one you need.
- Click Save.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the
yc config set folder-id <folder_ID>command. You can also set a different folder for any specific command using the--folder-nameor--folder-idparameter.To change the availability zone for a cluster and its Apache Kafka® host, run this command:
yc managed-kafka cluster update <cluster_name_or_ID> \ --zone-ids <availability_zone> \ --subnet-ids <subnet_ID>If there is only one subnet in the new availability zone, you do not need to specify
--subnet-ids.-
Open the current Terraform configuration file describing your infrastructure.
Learn how to create this file in Creating an Apache Kafka® cluster.
-
In the Managed Service for Apache Kafka® cluster description, specify the new subnet in
subnet_idsand the new availability zone inzones:resource "yandex_mdb_kafka_cluster" "<cluster_name>" { ... subnet_ids = ["<subnet>"] config { ... zones = ["<availability_zone>"] } ... }If there is only one subnet in the new availability zone, you do not need to specify
subnet_ids. -
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
For more information, see this Terraform provider guide.
Timeouts
The Terraform provider limits the time for all operations with the Managed Service for Apache Kafka® cluster to 60 minutes.
Operations exceeding the timeout are aborted.
How do I change these limits?
Add the
timeoutssection to your cluster description, such as the following:resource "yandex_mdb_kafka_cluster" "<cluster_name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.update method, e.g., via the following cURL
request:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
updateMaskparameter as a single comma-separated string.curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ -url 'https://mdb.api.cloud.yandex.net/managed-kafka/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "configSpec.zoneId,subnetIds", "subnetIds": [ "<subnet>" ] "configSpec": { "zoneId": [ "<availability_zone>" ] } }'Where:
-
updateMask: Comma-separated string of settings you want to update.Specify the relevant parameters:
subnetIds: To change the list of subnets.configSpec.zoneId: To change the availability zone.
-
subnetIds: Array of strings. Each string is a subnet ID. If there is only one subnet in the new availability zone, you do not need to specifysubnetIds. -
zoneId: New availability zone for the cluster.
You can get the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the ClusterService/Update method, e.g., via the following gRPCurl
request:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
update_maskparameter as an array ofpaths[]strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/kafka/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "subnet_ids", "config_spec.zone_id" ] }, "subnet_ids": [ "<subnet>" ] "config_spec": { "zone_id": [ "<availability_zone>" ] } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.kafka.v1.ClusterService.UpdateWhere:
-
update_mask: List of settings you want to update as an array of strings (paths[]).Specify the relevant parameters:
subnet_ids: To change the list of subnets.config_spec.zone_id: To change the availability zone.
-
subnet_ids: Array of strings. Each string is a subnet ID. If there is only one subnet in the new availability zone, you do not need to specifysubnet_ids. -
zone_id: New availability zone for the cluster.
You can get the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
- In the management console
-
To successfully connect to topics after migration, specify the new broker’s FQDN in your backend or client, e.g., in your application code or graphical IDE. Delete the FQDN of the original broker in your source availability zone.
To find out the FQDN, get the list of hosts in the cluster:
Management consoleCLIREST APIgRPC API- In the management console
, navigate to the relevant folder. - Go to Managed Service for Kafka.
- Click the name of your cluster and select the Hosts tab.
yc managed-kafka cluster list-hosts <cluster_name_or_ID>You will see the FQDN under
NAMEin the command output.-
Call the Cluster.listHosts method, e.g., via the following cURL
request:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-kafka/v1/clusters/<cluster_ID>/hosts'You can get the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful. You will find the FQDN in the
hosts[].namefield of the response.
-
Call the ClusterService/ListHosts method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/kafka/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.kafka.v1.ClusterService.ListHostsYou can get the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful. You will find the FQDN in the
hosts[].namefield of the response.
- In the management console
Migrating a single-host cluster using auxiliary tools
To move an Apache Kafka® host to a different availability zone in a Managed Service for Apache Kafka® cluster:
-
Create a subnet in the target availability zone.
-
If the cluster security group is set up for a subnet in the availability zone you are moving your cluster from, reconfigure the group for the new subnet. To do so, replace the source subnet CIDR with the new subnet CIDR in the security group rules.
-
Create a Managed Service for Apache Kafka® cluster with the same configuration as the source cluster, except for a different subnet and security group.
-
Migrate data from your source cluster to the new one using one of the following tools:
- MirrorMaker: You can use either the MirrorMaker connector embedded in Managed Service for Apache Kafka® or the MirrorMaker utility.
- Data Transfer.
-
To successfully connect to topics after migration, specify the new cluster’s broker FQDN in your backend or client, e.g., in your application code or graphical IDE. Delete the FQDN of your source cluster's broker in the source availability zone.
To find out the FQDN, get the list of hosts in the cluster:
Management consoleCLIREST APIgRPC API- In the management console
, navigate to the relevant folder. - Go to Managed Service for Kafka.
- Click the name of your cluster and select the Hosts tab.
yc managed-kafka cluster list-hosts <cluster_name_or_ID>You will see the FQDN under
NAMEin the command output.-
Call the Cluster.listHosts method, e.g., via the following cURL
request:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-kafka/v1/clusters/<cluster_ID>/hosts'You can get the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful. You will find the FQDN in the
hosts[].namefield of the response.
-
Call the ClusterService/ListHosts method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/kafka/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.kafka.v1.ClusterService.ListHostsYou can get the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful. You will find the FQDN in the
hosts[].namefield of the response.
- In the management console
-
Delete the source Managed Service for Apache Kafka® cluster.
Migrating a multi-host cluster
Note
Clusters running Apache Kafka® 3.6 or higher do not use ZooKeeper hosts. Migration is only possible for configurations with three brokers in the same availability zone.
If you create an Apache Kafka® 3.5 cluster out of more than one broker host, three dedicated ZooKeeper hosts will be automatically added to the cluster. Each host is assigned a subnet from different availability zones. After you create a cluster, you cannot change its subnet in the availability zone.
The migration process of an Apache Kafka® 3.5 cluster depends on which availability zones Apache Kafka® and ZooKeeper hosts reside in prior to migration and how many subnets each zone contains. See these examples to better understand how migration works.
To move Apache Kafka® hosts to a different availability zone in an Apache Kafka® 3.5 cluster:
-
Find out in which availability zones Apache Kafka® and ZooKeeper hosts reside:
Management consoleCLIREST APIgRPC API- In the management console
, navigate to the relevant folder. - Navigate to the Managed Service for Kafka service.
- Click the name of your cluster and select the Hosts tab. The Availability zone column lists the availability zones for each host.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the
yc config set folder-id <folder_ID>command. You can also set a different folder for any specific command using the--folder-nameor--folder-idparameter.yc managed-kafka cluster list-hosts <cluster_name_or_ID>The availability zone is specified in the command output under
ZONE ID.-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.listHosts method, e.g., via the following cURL
request:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-kafka/v1/clusters/<cluster_ID>/hosts'You can get the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful. You will find the availability zone in the
hosts[].zoneIdfield of the response.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the ClusterService/ListHosts method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/kafka/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.kafka.v1.ClusterService.ListHostsYou can get the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful. You will find the availability zone in the
hosts[].zone_idfield of the response.
- In the management console
-
If the target availability zone for Apache Kafka® hosts is not on the list, create a subnet in this zone.
If the target availability zone is on the list, Apache Kafka® hosts will migrate to the subnet that already contains Apache Kafka® or ZooKeeper hosts in that zone.
-
Check the cluster security group. If it is set up for a subnet in the source availability zone, reconfigure the group for the subnet in the target availability zone. To do so, replace the source subnet CIDR with the target subnet CIDR in the security group rules.
-
Change the availability zone of your cluster and its Apache Kafka® hosts:
Management consoleCLITerraformREST APIgRPC API-
In the management console
, navigate to the relevant folder. -
Navigate to the Managed Service for Kafka service.
-
In the cluster row, click
and select Edit. -
Under Network settings, set the new availability zones. Their total number must not decrease.
Warning
After adding a new availability zone, deselect one of the old zones. Otherwise, you will not be able to delete an old availability zone after you save the settings.
-
Specify a subnet in the new availability zone if:
- Apache Kafka® or ZooKeeper hosts were not previously placed in the target availability zone.
- The target availability zone has more than one subnet.
-
Click Save.
To update availability zones for a cluster and its Apache Kafka® hosts, run this command:
yc managed-kafka cluster update <cluster_name_or_ID> \ --zone-ids <availability_zones> \ --subnet-ids <subnet_IDs>In
--zone-ids, list the availability zones separated by commas. Their total number must not decrease.Warning
After adding a new availability zone, remove one of the old zones from the list. Otherwise, you will not be able to delete an old availability zone after you run the command.
In
--subnet-ids, list the subnets for theru-central1-a,ru-central1-b, andru-central1-davailability zones, separated by commas. You must specify subnets for these zones even if the Apache Kafka® hosts are deployed in fewer zones. You need all three availability zones for ZooKeeper hosts.-
Open the current Terraform configuration file describing your infrastructure.
Learn how to create this file in Creating an Apache Kafka® cluster.
-
In the Managed Service for Apache Kafka® cluster description, change the list of availability zones under
zones:resource "yandex_mdb_kafka_cluster" "<cluster_name>" { ... config { ... zones = ["<availability_zones>"] } ... }The number of availability zones must not decrease.
Warning
After adding a new availability zone, remove one of the old zones from the list. Otherwise, you will not be able to delete an old availability zone after you save the settings.
-
Change the list of subnets under
subnet_idsif these two conditions are met:- You are migrating Apache Kafka® hosts to an availability zone where ZooKeeper hosts were not previously placed.
- The target availability zone has more than one subnet.
If the cluster hosts are placed in the
ru-central1-aandru-central1-bavailability zones, and you change the availability zones toru-central1-a,ru-central1-b, andru-central1-d, specify a subnet only if theru-central1-dzone has multiple subnets. Otherwise, you do not need to specify it.resource "yandex_mdb_kafka_cluster" "<cluster_name>" { ... subnet_ids = ["<subnets>"] ... } -
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
For more information, see this Terraform provider guide.
Timeouts
The Terraform provider limits the time for all operations with the Managed Service for Apache Kafka® cluster to 60 minutes.
Operations exceeding the timeout are aborted.
How do I change these limits?
Add the
timeoutssection to your cluster description, such as the following:resource "yandex_mdb_kafka_cluster" "<cluster_name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }-
Call the Cluster.update method, e.g., via the following cURL
request:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
updateMaskparameter as a single comma-separated string.curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ -url 'https://mdb.api.cloud.yandex.net/managed-kafka/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "configSpec.zoneId,subnetIds", "subnetIds": [ <subnet_list> ], "configSpec": { "zoneId": [ <list_of_availability_zones> ] } }'Where:
-
updateMask: Comma-separated string of settings you want to update.Specify the relevant parameters:
subnetIds: To change the list of subnets.configSpec.zoneId: To change the list of availability zones.
-
subnetIds: Array of strings. Each string is a subnet ID. Change the list of subnets if these two conditions are met:- You are migrating Apache Kafka® hosts to an availability zone where ZooKeeper hosts were not previously placed.
- The target availability zone has more than one subnet.
If the cluster hosts are placed in the
ru-central1-a,ru-central1-b, andru-central1-cavailability zones, and you change the availability zones toru-central1-a,ru-central1-b, andru-central1-d, specify a subnet only if theru-central1-dzone has multiple subnets. Otherwise, you do not need to specify it. -
zoneId: New availability zones for the cluster. Their total number must not decrease.
You can get the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
-
Call the ClusterService/Update method, e.g., via the following gRPCurl
request:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
update_maskparameter as an array ofpaths[]strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/kafka/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "subnet_ids", "config_spec.zone_id" ] }, "subnet_ids": [ <subnet_list> ], "config_spec": { "zone_id": [ <list_of_availability_zones> ] } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.kafka.v1.ClusterService.UpdateWhere:
-
update_mask: List of settings you want to update as an array of strings (paths[]).Specify the relevant parameters:
subnet_ids: To change the list of subnets.config_spec.zone_id: To change the list of availability zones.
-
subnet_ids: Array of strings. Each string is a subnet ID. Change the list of subnets if these two conditions are met:- You are migrating Apache Kafka® hosts to an availability zone where ZooKeeper hosts were not previously placed.
- The target availability zone has more than one subnet.
If the cluster hosts are placed in the
ru-central1-a,ru-central1-b, andru-central1-cavailability zones, and you change the availability zones toru-central1-a,ru-central1-b, andru-central1-d, specify a subnet only if theru-central1-dzone has multiple subnets. Otherwise, you do not need to specify it. -
zone_id: New availability zones for the cluster. Their total number must not decrease.
You can get the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
-
To move Apache Kafka® hosts to a different availability zone in an Apache Kafka® cluster version 3.6 or higher:
-
Create a subnet in the target availability zone you are migrating Apache Kafka® hosts to.
-
Check the cluster security group. If it is set up for a subnet in the source availability zone, reconfigure the group for the subnet in the target availability zone. To do so, replace the source subnet CIDR with the target subnet CIDR in the security group rules.
-
Change the availability zone of your cluster and its Apache Kafka® hosts:
CLITerraformREST APIgRPC APITo change the availability zone for a cluster and its Apache Kafka® hosts, run this command:
yc managed-kafka cluster update <cluster_name_or_ID> \ --zone-ids <availability_zone> \ --subnet-ids <subnet_ID>-
Open the current Terraform configuration file describing your infrastructure.
Learn how to create this file in Creating an Apache Kafka® cluster.
-
In the Managed Service for Apache Kafka® cluster description, change the availability zone in the
zonesparameter:resource "yandex_mdb_kafka_cluster" "<cluster_name>" { ... config { ... zones = ["<availability_zone>"] } ... } -
In the
subnet_idsparameter, specify a subnet in the target availability zone.resource "yandex_mdb_kafka_cluster" "<cluster_name>" { ... subnet_ids = ["<subnet>"] ... } -
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
For more information, see this Terraform provider guide.
Timeouts
The Terraform provider limits the time for all operations with the Managed Service for Apache Kafka® cluster to 60 minutes.
Operations exceeding the timeout are aborted.
How do I change these limits?
Add the
timeoutssection to your cluster description, such as the following:resource "yandex_mdb_kafka_cluster" "<cluster_name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }-
Call the Cluster.update method, e.g., via the following cURL
request:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
updateMaskparameter as a single comma-separated string.curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ -url 'https://mdb.api.cloud.yandex.net/managed-kafka/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "configSpec.zoneId,subnetIds", "subnetIds": [ <subnet_in_target_availability_zone> ], "configSpec": { "zoneId": [ <target_availability_zone> ] } }'Where:
-
updateMask: Comma-separated string of settings you want to update.In this case, specify
subnetIdsandconfigSpec.zoneId. -
subnetIds: Array of strings. Each string is a subnet ID. Specify only the subnet in the target availability zone. -
zoneId: New availability zones for the cluster. Specify only the target availability zone.
You can get the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
-
Call the ClusterService/Update method, e.g., via the following gRPCurl
request:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
update_maskparameter as an array ofpaths[]strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/kafka/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "subnet_ids", "config_spec.zone_id" ] }, "subnet_ids": [ <subnet_in_target_availability_zone> ], "config_spec": { "zone_id": [ <target_availability_zone> ] } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.kafka.v1.ClusterService.UpdateWhere:
-
update_mask: List of settings you want to update as an array of strings (paths[]).In this case, the array consists of the
subnetIdsandconfigSpec.zoneIdstrings. -
subnetIds: Array of strings. Each string is a subnet ID. Specify only the subnet in the target availability zone. -
zoneId: New availability zones for the cluster. Specify only the target availability zone.
You can get the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
-
To successfully connect to topics after migration, specify the new broker’s FQDN in your backend or client, e.g., in your application code or graphical IDE. Delete the FQDN of the original broker in your source availability zone.
To find out the FQDN, get the list of hosts in the cluster:
- In the management console
, navigate to the relevant folder. - Go to Managed Service for Kafka.
- Click the name of your cluster and select the Hosts tab.
yc managed-kafka cluster list-hosts <cluster_name_or_ID>
You will see the FQDN under NAME in the command output.
-
Call the Cluster.listHosts method, e.g., via the following cURL
request:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-kafka/v1/clusters/<cluster_ID>/hosts'You can get the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful. You will find the FQDN in the
hosts[].namefield of the response.
-
Call the ClusterService/ListHosts method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/kafka/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.kafka.v1.ClusterService.ListHostsYou can get the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful. You will find the FQDN in the
hosts[].namefield of the response.
Examples of migrating a multi-host cluster
The examples below provide insight into situations where you need to specify a subnet to migrate a Managed Service for Apache Kafka® 3.5 multi-host cluster to a different availability zone.
A ZooKeeper host already resides in the target availability zone
Let’s assume your cluster comprises the following hosts:
- Apache Kafka® host 1 in the
ru-central1-aavailability zone - Apache Kafka® host 2 in the
ru-central1-cavailability zone - ZooKeeper host 1 in the
ru-central1-aavailability zone - ZooKeeper host 2 in the
ru-central1-bavailability zone - ZooKeeper host 3 in the
ru-central1-davailability zone
You need to migrate Apache Kafka® hosts to the ru-central1-a and ru-central1-d availability zones.
ZooKeeper host 3 already resides in the ru-central1-d zone, which means it belongs to one of the subnets in this availability zone. This subnet will be used for migration, since you cannot change subnets after you create the cluster. As a result, you do not need to specify a subnet during migration.
The target availability zone contains no hosts and has one subnet
Let’s assume your cluster comprises the following hosts:
- Apache Kafka® host 1 in the
ru-central1-aavailability zone - Apache Kafka® host 2 in the
ru-central1-bavailability zone - Apache Kafka® host 3 in the
ru-central1-cavailability zone - ZooKeeper host 1 in the
ru-central1-aavailability zone - ZooKeeper host 2 in the
ru-central1-bavailability zone - ZooKeeper host 3 in the
ru-central1-cavailability zone
You need to migrate Apache Kafka® hosts to the ru-central1-a, ru-central1-b, and ru-central1-d availability zones.
No hosts initially reside in the ru-central1-d zone. But there is only one subnet in it, so you need not specify a subnet when performing the migration.
The target availability zone contains no hosts and has multiple subnets
Let’s assume your cluster comprises the following hosts:
- Apache Kafka® host 1 in the
ru-central1-aavailability zone - Apache Kafka® host 2 in the
ru-central1-bavailability zone - Apache Kafka® host 3 in the
ru-central1-cavailability zone - ZooKeeper host 1 in the
ru-central1-aavailability zone - ZooKeeper host 2 in the
ru-central1-bavailability zone - ZooKeeper host 3 in the
ru-central1-cavailability zone
You need to migrate Apache Kafka® hosts to the ru-central1-a, ru-central1-b, and ru-central1-d availability zones.
No hosts initially reside in the ru-central1-d zone. However, there are multiple subnets, so you need to specify a subnet to perform the migration.
Specifics of migration in Yandex Data Transfer
If your cluster is used as an endpoint when transferring data with Data Transfer, and the transfer type is Replication or Snapshot and increment, restart the transfer after migrating the cluster. This way, the transfer will get data about the cluster's new topology.
You do not need to restart Snapshot transfers, as information about the new topology is provided automatically while activating them.
To restart a transfer, choose one of the two methods:
- Deactivate the transfer and wait for its status to change to Stopped. Next, reactivate the transfer and wait for its status to change to Replicating.
- Update any setting for the transfer or endpoint.
For more information, see Migrating a Data Transfer transfer and endpoints to a different availability zone.
For an example of transferring data using Data Transfer, see this tutorial.