Migrating to a third-party MySQL® cluster
You can migrate your databases from one MySQL® version to another, e.g., from MySQL® 5.7 to MySQL® 8. Note that the third-party cluster must run a major MySQL® version not lower than that on your Yandex Managed Service for MySQL® cluster.
To migrate a database deployed in a Yandex Managed Service for MySQL® cluster to a third-party MySQL® cluster:
If you no longer need the resources you created, delete them.
Getting started
Sign up for Yandex Cloud and create a billing account:
- Navigate to the management console
and log in to Yandex Cloud or create a new account. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVEorTRIAL_ACTIVEstatus. If you do not have a billing account, create one and link a cloud to it.
If you have an active billing account, you can create or select a folder for your infrastructure on the cloud page
Learn more about clouds and folders here.
Required paid resources
The migration infrastructure cost includes a fee for each transfer: use of computing resources and the number of transferred data rows (see Data Transfer pricing).
Prepare a third-party MySQL® cluster
Create a MySQL® cluster of any suitable configuration. In this case, the following applies:
-
The MySQL® version must be the same or higher than the version in the source cluster.
Data transfer with a major MySQL® version upgrade is possible but not guaranteed. For more information, see this MySQL® guide
.Migration with a MySQL® version downgrade is not supported
. -
SQL mode must be the same as in the source cluster.
Transfer the data
-
Create endpoints and a transfer:
ManuallyTerraform-
-
Database type:
MySQL. -
Connection settings:
Managed Service for MySQL cluster.Specify the source cluster ID.
-
-
-
Database type:
MySQL. -
Connection settings:
Custom installation.Configure the target cluster connection settings.
-
-
Create a transfer of the Snapshot and increment-type that will use the new endpoints.
-
If you do not have Terraform yet, install it.
-
Get the authentication credentials. You can add them to environment variables or specify them later in the provider configuration file.
-
Configure and initialize a provider. Instead of manually creating the provider configuration file, you can download it
. -
Place the configuration file in a separate working directory and specify the parameter values. If you have not added the authentication credentials to environment variables, specify them in the configuration file.
-
Download the data-transfer-mmy-mysql.tf
file with the transfer and endpoint configuration file to the same working directory. -
Specify the following in the configuration file:
-
Validate your Terraform configuration files using this command:
terraform validateTerraform will display any configuration errors detected in your files.
-
Create the required infrastructure:
-
Run this command to view the intended 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.
-
All the required resources will be created in the specified folder. You can check resource availability and their settings in the management console
.The transfer will be activated automatically as soon as it is created.
-
Warning
Avoid changing the data schema in either the source or target cluster while the transfer is in progress. For more information, see Working with databases during transfer.
-
-
Wait for the transfer status to change to Replicating.
-
Switch the source cluster to "read-only" mode and move the workload to the target cluster.
-
On the transfer monitoring page, wait until the Maximum data transfer delay value drops to zero. This indicates that the target cluster now contains all changes made in the source cluster after the data copy completed.
-
Deactivate the transfer and wait for its status to change to Stopped.
For more information about transfer statuses, see Transfer lifecycle.
-
To minimize resource consumption, delete the resources you no longer need:
ManuallyTerraform-
In the terminal window, go to the directory containing the infrastructure plan.
Warning
Make sure the directory has no Terraform manifests with the resources you want to keep. Terraform deletes all resources that were created using the manifests in the current directory.
-
Delete resources:
-
Run this command:
terraform destroy -
Confirm deleting the resources and wait for the operation to complete.
All the resources described in the Terraform manifests will be deleted.
-
-
How to delete the resources you created
Some resources are not free of charge. Delete the resources you no longer need, so you will not be charged for them:
- Once the transfer is stopped, delete it.
- Delete the source and target endpoints.
-
In the terminal window, go to the directory containing the infrastructure plan.
Warning
Make sure the directory has no Terraform manifests with the resources you want to keep. Terraform deletes all resources that were created using the manifests in the current directory.
-
Delete resources:
-
Run this command:
terraform destroy -
Confirm deleting the resources and wait for the operation to complete.
All the resources described in the Terraform manifests will be deleted.
-
Useful links
For other migration methods, see this Yandex Managed Service for MySQL® tutorial.