
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create a Cloud SQL for MySQL instance
/ 10
Setting up the Striim software
/ 15
Setting up Connector/J
/ 20
Creating a BigQuery data set
/ 25
Creating an online database migration
/ 20
Creating a continuous Cloud SQL for MySQL to BigQuery data pipeline
/ 10
This lab was developed with our partner, Striim. Your personal information may be shared with Striim, the lab sponsor, if you have opted-in to receive product updates, announcements, and offers in your Account Profile.
This lab demonstrates how to migrate a Cloud SQL for MySQL database to BigQuery using Google Cloud's data migration partner, Striim.
Striim is a comprehensive streaming ETL platform that enables online data migrations and continuous streaming replication from on-premises and cloud data sources to Google Cloud data services through a graphical drag and drop interface. The following figure shows Striim's high level architecture.
This lab will focus on the implementation of a continuous migration from MySQL to BigQuery, and is not an explanation of database migration or database replication, or why you might want to migrate your underlying database. If you'd like to learn more about database migrations and replications, refer to Simplify your database migration journey.
The figure shows the various services that you will create as well as the data flow from Cloud SQL for MySQL to BigQuery via Striim that you will implement in this lab.
In this lab you will learn to:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
In order to work on the database migration, some initial configuration is required:
Next, create a Cloud SQL for MySQL instance that you will use to connect Striim to. In this case, it will act as the source transactional system to be replicated. In a real world scenario this could be one of many transactional database systems.
echo
command to show them and make a note of them:You have completed setting up the Cloud SQL for MySQL database for Striim to ingest data from.
Click Check my progress to verify the objective.
Next, set up an instance of the Striim server through the Google Cloud Marketplace.
OPEN STRIIM IN THE MARKETPLACE banner
Alternatively you can search in the Marketplace, the direct link is: https://console.cloud.google.com/marketplace/details/striim/striim.
<ql-variable key="project_0.default_zone" placeHolder="ZONE"></ql-variable>
).Click Check my progress to verify the objective.
In order to allow Striim to communicate with Cloud SQL, you need to add the Striim server's IP address to allow it to connect.
Click the Visit the site button on the right half of the screen. This will open up the Striim configuration wizard in a new browser tab. Click I Agree and accept the EULA by clicking Accept Striim EULA and Continue.
Configure the server and be sure to note the cluster name, the cluster and administrator passwords, and the sys user and keystore passwords. Click the button Save and Continue.
The next screen will ask for license details. Leave the field empty and click the button Save and Continue.
admin
user and the administrator password you set in the previous step. This will take you to the Striim administrator console, and you are now ready to connect to the MySQL database.You will now follow the Striim online documentation and use the MySQL Connector/J to connect Striim to your Cloud SQL instance.
In the Deployment Manager page for your Striim instance, click the SSH button located next to the blue Visit the site button. This will open up a new window and will automatically SSH into the virtual machine.
Run the following commands to create the user directory and give the user permissions to access it:
Close the SSH window and click the SSH button again to reconnect to the VM.
Download Connector/J to the VM and unpack it:
Click Check my progress to verify the objective.
admin
user and password. The administration console will take a few minutes to refresh after the restart. If the administration console does not reload on the first try, keep refreshing until the administration console comes up.If the administration console does not come up, use the site address, but with port 9080 instead of 9070, i.e. http://[IP_ADDRESS]:9080/
admin
user is a built-in user that must be used in order for login to succeed at the Striim administration console.Before you build your first Striim application, you need to load some existing transactions into the MySQL instance.
CSQL_USER_PWD
set from before:mysql>
prompt:43148.95649414063
and 431489.56494140625
, respectively:Results in:
exit
command and get back to the Cloud Shell command line:CSQL_ROOT_PWD
set from before:exit
command and get back to the Cloud Shell command line:You will now create a BigQuery dataset and load the Service Account credentials from the Cloud Console so that Striim can write to the BigQuery table.
For this lab, deploy BigQuery in the same region as Cloud SQL. If you chose a different region than
striimdemo
with the following command:The dataset is set to expire in 7200 seconds (2 hours) for the purposes of this lab.
striimdemo.orders
in the new BigQuery dataset:The table is also set to expire in 7200 seconds (2 hours) for the purposes of this lab.
This will create a Service Account Key named striim-bq-key.json
in your home path.
From the Cloud Shell toolbar, Click on the three dots (⋮) next to the file in the file browser. Then click on Downloads then click on Toggle file browser icon and expand the user name and select the striim-bq-key.json file and click on DOWNLOAD to save the file on your local machine to use further in the lab.
Now you need to move the key you just created to the Striim VM. Identify the name of the virtual machine in which Striim is deployed on by either going to the deployment details page in the Deployment Manager, or by using gcloud compute instances list
command in Cloud Shell. Once you obtain the name of the Striim VM, continue with the instructions below.
Copy the JSON file to the Striim server with the scp
command. This operation might cause a new SSH key to be generated and in this case you will be asked to provide a passphrase:
/opt/striim
directory using the following command:You are now ready to create a Striim application!
Click Check my progress to verify the objective.
An online database migration moves data from a source database (either on-premises or hosted on a cloud provider) to a target database in Google Cloud. The source database remains fully accessible to the business applications throughout the migration with minimal performance impact.
In an online migration, an initial bulk load is performed, and a continuous capture of changes is also being run. You then synchronize the source and target databases to ensure that no data is lost during the migration. Typically both databases will be retained for extended periods of time to test and verify that the applications and users are not impacted negatively by switching to a new cloud database.
If you'd like to focus on creating a Change Data Capture (CDC) pipeline, please jump ahead to section 9. Creating a continuous Cloud SQL for MySQL to BigQuery data pipeline. Here, you will start by creating an initial bulk load from your source to target database.
Get back to the browser tab with the Striim Web UI, and click on the Apps pane in the middle.
Click on the Create App button on the upper right side of the page.
There are multiple ways to create applications in Striim. Click on Start From Scratch.
Name the application something that is easily remembered. The lab will use MySQLToBigQuery_initLoad
. Below the application name, you can choose a namespace. These are logical groupings that help you organize applications. Use the default admin
namespace. Click Save.
You'll be greeted by the Flow Designer page. All of the out-of-the-box connectors that you will need to create streaming data applications are in the left menu bar.
To perform a one time bulk initial load of data from MySQL database table, you'll use the Database Reader.
mysql_source
as the name.gcloud sql instances list
in the PRIMARY_ADDRESS
field. Use this to construct your Connection URL. It should look like jdbc:mysql://[PRIMARY_ADDRESS]:3306/striimdemo
.CSQL_USERNAME
environment variable as (this lab uses striim-user
)CSQL_USER_PWD
value for the password.Tables
that you'd like to migrate with the syntax DatabaseName.SchemaName
. Per your earlier MySQL setup, this should be striimdemo.ORDERS
.stream_CloudSQLMySQLInitLoad
.Now you will do a quick test to see if the configuration settings are correct, and that Striim can successfully connect to MySQL.
In the Deployment window, this is where you can specify that you want to run certain pieces of your application on certain parts of your deployment topology. You'll typically use this if you're running a lightweight forwarding Striim agent deployed on premises next to your data source, pushing data over specific ports to the Striim server running in the cloud. Since we're using a simple deployment topology, go ahead and select the default option and click Deploy.
Click the wave icon beneath your Database Reader component, and then click the eye icon next to it to preview your data as it flows through the Striim data pipeline.
Go back up to the top menu bar, click Deployed, then click Start App. You should now see the Striim application running, and data flowing through the pipeline. If there are any errors, it means that there is an issue connecting to the source database since there is only a source component in the pipeline. If you see your application successfully run but no data flows through, typically that means that you don't have any existing data in your database.
So far you've successfully connected to your source database and tested that it can read data. Click where it says Running on the top menu bar, and then select Stop App. Then click again where it now says Stopped, and then select Undeploy App. We are now ready to connect to BigQuery.
Click the wave button under the DatabaseReader. This time, a + button will appear. Click it, and then select Connect next Target component. Name this target object BigQueryInitialLoadTarget
. Then search for "BigQuery" under the Adapter field in the left panel. Select BigQueryWriter.
The tables property is a list of source/target pairs separated by semi-columns. Each pair denotes the full names of the source and target tables separated by commas. The list will look like srcSchema1.srcTable1,tgtSchema1.tgtTable1; srcSchema2.srcTable2,tgtSchema2.tgtTable2
. For this lab, use only one pair striimdemo.ORDERS,striimdemo.orders
.
Enter the PROJECT_ID
into the Project Id input field. The project name (PROJECT_ID
) can easily be found within the Cloud Shell.
In SERVICE ACCOUNT KEY click on Choose option then under the Or Upload a file section click Select File and select the file that you downloaded in Task5 and then Click Upload and Select to browse and upload the file from local.
Click Save. Repeat the directions in steps 8 - 10 to deploy and run the app.
striimdemo
dataset. Since you're working with BigQuery, you'll run an analytical query to verify that your data arrived properly, such as to find the average and total size of the orders. They should be 43148.952
and 431489.52
respectively:Output:
You have successfully set up your Striim environment and pipeline to perform a batch load!
Click Check my progress to verify the objective.
With the initial one time bulk load in place, you can now set up a continuous replication pipeline. It will look very similar to the bulk pipeline that you just created, but with a different source object.
MySQLToBigQuery_cdc
. Create it in the same admin
namespace as before. This time, instead of choosing a DatabaseReader source, choose a MySQL CDC reader.Give your new source a name. Copy in the connection URL, username, password, and table information that you used in steps 6 and 7 from the previous section. Create a new target. We will name it tgt_MySQLCDCBigQuery
. Repeat steps 12, 13, and 14 from the previous section to add the BigQuery target to the data pipeline. Deploy and start the app, click the wave icon, and then the eye icon next to it to view the data as it is replicated. Since only the changes in the source database table from the time of the creation of the app are replicated to the target in real-time, you initially won't see any data flowing through the pipeline.
Go back to the Cloud Shell and connect to your MySQL instance. In the striimdemo
database, execute the following commands:
striimdemo
dataset. We'll run one final query to verify that your data arrived properly, such as SELECT COUNT(*) AS ORDERS, AVG(ORDER_TOTAL) AS ORDERS_AVE, SUM(ORDER_TOTAL) AS ORDERS_SUM FROM striimdemo.orders;
to find the average order size as well as the total order sum. It should be 41959.899333333335
and 629398.49
after the CDC pipeline, respectively.Click Check my progress to verify the objective.
In this lab, you successfully set up a streaming pipeline from Cloud SQL for MySQL to BigQuery.
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Last Tested Date: February 22, 2024
Last Updated Date: February 22, 2024
Copyright 2025 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one