Tutorial
Migrating from MySQL to Google Cloud SQL with Change Data Capture
How to Change Data Capture (CDC) to synchronize data from MySQL into a Google Cloud SQL instance
Benefits
Simplify Cloud Migrations
Say goodbye to downtime and complex migrations. Striim seamlessly loads and syncs your changing data.
Add New Cloud Applications
Add new, client-facing applications by synchronizing an existing on-premises application’s data set.
Sync Current and New Databases
Keep data in your current MySQL instance in sync with your new CloudSQL deployment until your migration goes live
On this page
Overview
Migrating from MySQL to Google Cloud SQL opens up cloud services that offer a wealth of capabilities with low management overhead and cost. But, moving your existing on-premises applications to the cloud can be a challenge. Existing applications built on top of on-premises deployments of databases like MySQL. In this blog post we are going to use a database technology called Change Data Capture to synchronize data from MySQL into a Google Cloud SQL instance.Introduction
One of the major hurdles when migrating applications, whether you’re changing the technology or moving to the cloud, is migrating your data. The older and bigger the application, the more difficult that migration becomes. Traditional Extract, Translate, and Load (ETL) tools require multiple passes and, potentially, significant downtime to handle data migration activities. This is where real-time ETL tools like Striim shine. There are a number of benefits in migrating applications this way, such as being able to: Add a new, client-facing cloud application by synchronizing an existing, traditionally on-premises application’s data set. Migrate one or more on-premises application (with data) to the cloud for production testing with almost zero impact on the existing application. Let’s walk through an example of connecting an on-premises instance of MySQL to Google Cloud SQL for MySQL.Step 1: Set Up the MySQL Database
Before we dive into Striim, we are assuming you have an on-premises MySQL instance already configured and containing relevant data. For the purpose of this post, the dataset we have loaded data from a GitHub source (https://github.com/datacharmer/test_db) in a local MySQL instance. The data set is pretty large, which is perfect for our purposes, and contains a dummy set of employee information, including salaries.Step 2: Set Up the Striim Application
Now that we have an on-premises data set in MySQL, let’s set up a new Striim application on Google Cloud Platform to act as the migration service. Open your Google Cloud console and open or start a new project. Go to the marketplace and search for Striim.Step 3: Create a Target Database
While we wait for the Striim server to deploy, let’s create a Google SQL database to which we’ll migrate our database. Select the SQL option from the side menu in Google Cloud and create a new MySQL instance.CREATE TABLE CHKPOINT ( id VARCHAR(100) PRIMARY KEY, sourceposition BLOB, pendingddl BIT(1), ddl LONGTEXT );
Step 4: Initial Load Application
Open the Google Console and go back to the Deployment Manager, and click “Visit site”. It’s important to note that the Striim VM currently has a dynamic external IP address. In a production environment, you’ll want to set this to static so it won’t change. When you first visit the site, you’ll see a congratulations screen. Click accept and fill in the basic details. Leave the license field blank for the trial version of Striim, or add your license key if you have one.jdbc:mysql://:/
We are also mapping the tables we want to sync by specifying them in the tables folder using
.
This allows us to restrict what is synchronized. Finally, under output to, specify a new WAEvent type for this connector.
.,.
Step 5: Change Data Capture
While the initial load takes place, let’s create the Change Data Capture (CDC) application to get ready for the synchronization process.Step 6: Adding More Load
While the servers are synchronizing, let’s go back to our local MySQL and add some other transactions. Import the remaining two salaries files, load_salaries2.dump and load_salaries3.dump. This will provide additional transactions to be synchronized and you’ll see Striim continue to add transactions as they happen without needing to do anything else.Next Steps
We looked at a really quick and easy way to synchronize an on-premises instance of MySQL to Google Cloud SQL using Striim. At this point, you could start using the cloud database to run additional applications or do data analysis — without affecting the performance and use of your existing system. If you open the menu on the Striim admin page, then open the apps section, and finally open this application, you’ll also see other steps you could add to this flow that support even more complex use cases, such as adding in transforms, combining multiple sources, or even splitting across targets. To learn more about migrating from MySQL to Google Cloud SQL, check out the product page. To see how Striim can help with your move to cloud-based services, schedule a demo with a Striim technologist, or download a free trial of the platform.Tools you need
Striim
Striim’s unified data integration and streaming platform connects clouds, data and applications.
MySQL
MySQL is an open-source relational database management system.
Google Cloud SQL
Google Cloud SQL is a fully managed relational database service for MySQL, PostgreSQL and SQL Server.