Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
Yandex Data Transfer
  • Available transfers
  • Getting started
  • Step-by-step guide
  • Practical guidelines
    • All tutorials
    • Data migration
      • Migrating data between Yandex Managed Service for Apache Kafka® clusters
      • Migrating data to Yandex Managed Service for ClickHouse
      • Migrating data to Yandex Managed Service for Greenplum®
      • Migrating data to Yandex Managed Service for MongoDB
      • Migrating data to Yandex Managed Service for MySQL
      • Migrating data from Yandex Managed Service for MySQL to MySQL
      • Migrating data to Yandex Managed Service for PostgreSQL
    • Data delivery
    • Asynchronous replication of data
    • Saving data streams
  • Concepts
  • Troubleshooting
  • Access management
  • Pricing policy
  • API reference
  • Questions and answers
  1. Practical guidelines
  2. Data migration
  3. Migrating data to Yandex Managed Service for MySQL

Migrating data to Yandex Managed Service for MySQL

Written by
Yandex Cloud
  • Start a data transfer
  • Complete the data transfer
  • Delete the resources you created
  • See also

With Data Transfer, you can transfer data from a third-party source cluster to a Managed Service for MySQL target cluster.

This method lets you migrate the entire database without interrupting user service. To use it, allow connections to the source cluster from the internet.

To migrate the database from MySQL to Managed Service for MySQL:

  1. Start a data transfer.
  2. Complete the data transfer.

If you no longer need these resources, delete them.

Start a data transfer

  1. Prepare the source cluster.

  2. Prepare the infrastructure and start the data transfer:

    Manually
    Using Terraform
    1. Create a Managed Service for MySQL target cluster with any suitable configuration. In this case:

      • The MySQL version must be the same or higher than the version in the source cluster.

        Transferring data with an increase in the MySQL major version is possible, but not guaranteed. For more information, see the MySQL documentation.

        Migration with a MySQL version downgrade is impossible.

      • SQL mode must be the same as in the source cluster.

    2. Prepare the target cluster.

    3. Create a source endpoint:

      • Database type: MySQL.

      • Endpoint parameters → Connection settings: Custom installation.

        Specify the parameters for connecting to the source cluster.

    4. Create a target endpoint:

      • Database type: MySQL.

      • Endpoint parameters → Connection settings: MDB cluster.

        Select a target cluster from the list and specify the cluster connection settings.

    5. Create a transfer of the Snapshot and increment type that will use the created endpoints.

    6. Activate it.

      Warning

      Abstain from making any changes to the data schema in the source and target clusters when the data transfer is running. For more information, see Working with databases during the transfer.

    1. Prepare the source cluster.

    2. If you don't have Terraform, install and configure it.

    3. Download the file with provider settings. Place it in a separate working directory and specify the parameter values.

    4. Download the configuration file data-transfer-mysql-mmy.tf to the same working directory.

      This file describes:

      • Network.
      • Subnet.
      • Security groups and the rule required to connect to a cluster.
      • Managed Service for MySQL target cluster.
      • Source endpoint.
      • Target endpoint.
      • Transfer.
    5. Specify in the file data-transfer-mysql-mmy.tf:

      • Source endpoint parameters.

      • Target cluster parameters also used as target endpoint parameters:

        • target_mysql_version: The MySQL version must be the same or higher than the version in the source cluster.
        • target_sql_mode: SQL mode must be the same as in the source cluster.
        • target_db_name: Database name.
        • target_user and target_password: Username and password of the database owner.
    6. Run the command terraform init in the directory with the configuration file. This command initializes the provider specified in the configuration files and enables you to use the provider resources and data sources.

    7. Make sure the Terraform configuration files are correct using the command:

      terraform validate
      

      If there are errors in the configuration files, Terraform will point to them.

    8. Create the required infrastructure:

      1. Run the command to view planned changes:

        terraform plan
        

        If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.

      2. If you are happy with the planned changes, apply them:

        1. Run the command:

          terraform apply
          
        2. Confirm the update of resources.

        3. 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.

      Once created, a transfer is activated automatically.

Complete the data transfer

  1. Wait for the transfer status to change to Replicating.

  2. Switch the source cluster to read-only mode and switch the load to the target cluster.

  3. On the transfer monitoring page, wait for the Maximum lag on delivery metric to decrease to zero. This means that all changes that occurred in the source cluster after data was copied are transferred to the target cluster.

  4. Deactivate the transfer and wait for its status to change to Stopped.

    For more information about transfer statuses, see Transfer lifecycle.

Delete the resources you created

Manually
Using Terraform
  • Delete the Managed Service for MySQL cluster.
  • Delete the stopped transfer.
  • Delete endpoints for the source and target.
  1. In the terminal window, change to the directory containing the infrastructure plan.

  2. Delete the configuration file data-transfer-mysql-mmy.tf.

  3. Make sure the Terraform configuration files are correct using the command:

    terraform validate
    

    If there are errors in the configuration files, Terraform will point to them.

  4. Confirm the update of resources.

    1. Run the command to view planned changes:

      terraform plan
      

      If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.

    2. If you are happy with the planned changes, apply them:

      1. Run the command:

        terraform apply
        
      2. Confirm the update of resources.

      3. Wait for the operation to complete.

    All the resources described in the configuration file data-transfer-mysql-mmy.tf will be deleted.

For a real example of MySQL database migration using Data Transfer, see Syncing MySQL data using Yandex Data Transfer.

See also

For other migration methods, see the Yandex Managed Service for MySQL documentation.

Was the article helpful?

Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
In this article:
  • Start a data transfer
  • Complete the data transfer
  • Delete the resources you created
  • See also