arrow_back

Online Data Migration to BigQuery using Striim

Join Sign in

Online Data Migration to BigQuery using Striim

1 hour 30 minutes 1 Credit

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.

GSP828

Google Cloud self-paced labs logo

Overview

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.

Striim's high level architecture diagram

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.

Data flow from Cloud SQL to Striim Database Migration System, to BigQuery

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.

What you'll' learn

In this lab you will learn to:

  • Create and use a Cloud SQL for MySQL database

  • Deploy Striim through the Google Cloud Marketplace

  • Use Striim to read from a source Cloud SQL for MySQL database

  • Create and use a BigQuery data set

  • Use Striim to continuously replicate from Cloud SQL for MySQL to BigQuery.

Setup and requirements

Before you click the Start Lab button

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 will be made available to you.

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab---remember, once you start, you cannot pause a lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

How to start your lab and sign in to the Google Cloud Console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:

    • The Open Google Console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information, if needed, to step through this lab
  2. Click Open Google Console. 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.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username from the Lab Details panel and paste it into the Sign in dialog. Click Next.

  4. Copy the Password from the Lab Details panel and paste it into the Welcome dialog. Click Next.

    Important: You must use the credentials from the left panel. Do not use your Google Cloud Skills Boost credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  5. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Cloud Console opens in this tab.

Note: You can view the menu with a list of Google Cloud Products and Services by clicking the Navigation menu at the top-left. Navigation menu icon

Activate Cloud Shell

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.

  1. Click Activate Cloud Shell Activate Cloud Shell icon at the top of the Google Cloud console.

  2. Click Continue.

It takes a few moments to provision and connect to the environment. When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. The output contains a line that declares the PROJECT_ID for this session:

Your Cloud Platform project in this session 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.

  1. (Optional) You can list the active account name with this command:

gcloud auth list

Output:

ACTIVE: * ACCOUNT: student-01-xxxxxxxxxxxx@qwiklabs.net To set the active account, run: $ gcloud config set account `ACCOUNT`
  1. (Optional) You can list the project ID with this command:

gcloud config list project

Output:

[core] project = <project_ID>

Example output:

[core] project = qwiklabs-gcp-44776a13dea667a6 Note: For full documentation of gcloud, in Google Cloud, refer to the gcloud CLI overview guide.

Before you begin

In order to work on the database migration, some initial configuration is required:

  • In Cloud Shell, set the default compute zone for your database and compute resources. For more information, please see Geography and Regions. This lab uses us-central1-a, but change here if you want to use a different zone:

gcloud config set compute/zone us-central1-a export COMPUTE_ZONE=us-central1-a

Task 1. ​​Create a Cloud SQL for MySQL instance

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.

  1. In Cloud Shell, create environment variables to create the instance:

CSQL_NAME=striim-sql-src CSQL_USERNAME=striim-user CSQL_USER_PWD=$(openssl rand -base64 18) CSQL_ROOT_PWD=$(openssl rand -base64 18) export PROJECT_ID=$(gcloud config get-value project)
  1. If you close your window or the Cloud Shell session, you will lose the environment variables with the passwords, so use the echo command to show them and make a note of them:

echo $CSQL_USER_PWD echo $CSQL_ROOT_PWD echo $PROJECT_ID
  1. Run the following to create the Cloud SQL instance in Cloud Shell. This command might take a few minutes to complete:

gcloud sql instances create $CSQL_NAME \ --root-password=$CSQL_ROOT_PWD \ --zone=$COMPUTE_ZONE \ --enable-bin-log
  1. Create a Cloud SQL user that Striim will connect to:

gcloud sql users create $CSQL_USERNAME \ --instance $CSQL_NAME \ --password $CSQL_USER_PWD \ --host=%

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. Create a Cloud SQL for MySQL instance

Task 2. ​Setting up the Striim software

Next, set up an instance of the Striim server through the Google Cloud Marketplace.

  1. Navigate to the Striim offering on the Google Cloud Marketplace. If a list of Google Cloud projects is displayed then select the Qwiklabs project.

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.

  1. Click the button marked Launch. You will be presented with configuration options for the Striim server.

  • Change the zone to us-central1-a (or to the zone that you launched Cloud SQL in, if different than us-central1-a).
  • Check the box to accept the terms of service,
  • Choose whether to authorize information sharing with Striim,
  • Leave all other settings as is, and click the Deploy button.
Note: Marketplace solutions typically come with various resources that launch together in order to support the software. Be sure to review the monthly billing estimate before launching Striim in your production account.

Click Check my progress to verify the objective. Setting up the Striim software

  1. On the Deployment Manager page, once the Striim server is provisioned, the deployment details will show. Take a note of the name of the VM ("Instance" in the example screenshot below) and the zone it is deployed in ("Instance zone").

Striim deployment details

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.

  1. In Cloud Shell, execute the following commands replacing [STRIIM VM NAME] and[STRIIM VM ZONE] that you just noted previously in step 3, acknowledge that you want to continue by pressing "Y" when prompted.:

STRIIMVM_NAME=[STRIIM VM NAME] STRIIMVM_ZONE=[STRIIM VM ZONE] gcloud sql instances patch $CSQL_NAME --authorized-networks=$(gcloud compute instances describe $STRIIMVM_NAME --format='get(networkInterfaces[0].accessConfigs[0].natIP)' --zone=$STRIIMVM_ZONE)
  1. 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.

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

  3. The next screen will ask for license details. Leave the field empty and click the button Save and Continue.

Note: Do not use spaces or other punctuation in the form.
  1. Click the green Launch button and then the green Log In button. Log in using the 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.
Note: The "admin" user is a built-in user that must be used in order for login to succeed.

Task 3. Setting up Connector/J

You will now follow the Striim online documentation and use the MySQL Connector/J to connect Striim to your Cloud SQL instance.

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

  2. Run the following commands to create the user directory and give the user permissions to access it:

export user_id=`whoami` sudo mkdir /home/$user_id sudo chown -R $user_id /home/$user_id sudo chmod -R u+rX /home/$user_id
  1. Close the SSH window and click the SSH button again to reconnect to the VM.

  2. Download Connector/J to the VM and unpack it:

sudo curl -LO https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.29.tar.gz sudo tar -xvzf mysql-connector-java-8.0.29.tar.gz
  1. Copy the file to the Striim library path, allow it to be executable, and change ownership of it:

sudo cp mysql-connector-java-8.0.29/mysql-connector-java-8.0.29.jar /opt/striim/lib sudo chmod +x /opt/striim/lib/mysql-connector-java-8.0.29.jar sudo chown striim /opt/striim/lib/mysql-connector-java-8.0.29.jar

Click Check my progress to verify the objective. Setting up Connector/J

  1. You now need to restart the Striim server to recognize the new library. Do this in the same SSH session by running the following:

sudo systemctl stop striim-node sudo systemctl stop striim-dbms sudo systemctl start striim-dbms sudo systemctl start striim-node
  1. Go back to the browser window for the Striim administration console, refresh the window, and log in using the 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/

Note: The admin user is a built-in user that must be used in order for login to succeed at the Striim administration console.

Task 4. ​​Loading sample transactions to Cloud SQL

Before you build your first Striim application, you need to load some existing transactions into the MySQL instance.

  1. In Cloud Shell, connect to the instance using the CSQL_USER_PWD set from before:

gcloud sql connect $CSQL_NAME --user=$CSQL_USERNAME
  1. Create a sample database and load some transactions into it at the mysql> prompt:

CREATE DATABASE striimdemo; USE striimdemo; CREATE TABLE ORDERS (ORDER_ID Integer, ORDER_DATE VARCHAR(50), ORDER_MODE VARCHAR(8), CUSTOMER_ID Integer, ORDER_STATUS Integer, ORDER_TOTAL Float, SALES_REP_ID Integer, PROMOTION_ID Integer, PRIMARY KEY (ORDER_ID)); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1001, 1568927976017, 'In-Store', 1001, 9, 34672.59, 331, 9404); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1002, 1568928036017, 'In-Store', 1002, 1, 28133.14, 619, 2689); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1003, 1568928096017, 'CompanyB', 1003, 1, 37367.95, 160, 30888); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1004, 1568928156017, 'CompanyA', 1004, 1, 7737.02, 362, 89488); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1005, 1568928216017, 'CompanyA', 1005, 9, 15959.91, 497, 78454); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1006, 1568928276017, 'In-Store', 1006, 1, 82531.55, 399, 22488); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1007, 1568928336017, 'CompanyA', 1007, 7, 52929.61, 420, 66256); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1008, 1568928396017, 'Online', 1008, 1, 26912.56, 832, 7262); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1009, 1568928456017, 'CompanyA', 1009, 1, 97706.08, 124, 12185); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1010, 1568928516017, 'CompanyB', 1010, 1, 47539.16, 105, 17868);
  1. Do a quick check by counting the records and ensuring that 10 records have been inserted. Also note the average and total size of the orders; they should be 43148.95649414063 and 431489.56494140625, respectively:

SELECT COUNT(*) AS ORDERS, AVG(ORDER_TOTAL) AS ORDERS_AVE, SUM(ORDER_TOTAL) AS ORDERS_SUM FROM ORDERS;

Results in:

+--------+-------------------+--------------------+ | ORDERS | ORDERS_AVE | ORDERS_SUM | +--------+-------------------+--------------------+ | 10 | 43148.95649414063 | 431489.56494140625 | +--------+-------------------+--------------------+
  1. Exit MySQL with exit command and get back to the Cloud Shell command line:

exit
  1. Log back into the SQL instance as the root user using the CSQL_ROOT_PWD set from before:

gcloud sql connect $CSQL_NAME --user=root
  1. Run the following commands to give Striim MySQL privileges:

GRANT REPLICATION SLAVE ON *.* TO 'striim-user'@'%'; GRANT REPLICATION CLIENT ON *.* TO 'striim-user'@'%'; GRANT SELECT ON *.* TO 'striim-user'@'%';
  1. Exit MySQL with exit command and get back to the Cloud Shell command line:

exit

Task 5. Creating a BigQuery data set

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 us-central1 for Cloud SQL, change the region for BigQuery accordingly. More information about BigQuery regions is available.

  1. Create a BigQuery dataset named striimdemo with the following command:

bq --location=US mk -d --default_table_expiration 7200 --description "Striim Target Dataset" striimdemo

The dataset is set to expire in 7200 seconds (2 hours) for the purposes of this lab.

  1. Create a target table named striimdemo.orders in the new BigQuery dataset:

bq mk \ -t \ --expiration 7200 \ --description "Striim Target Table" \ striimdemo.orders \ ORDER_ID:INTEGER,\ ORDER_DATE:STRING,\ ORDER_MODE:STRING,\ CUSTOMER_ID:INTEGER,\ ORDER_STATUS:INTEGER,\ ORDER_TOTAL:FLOAT,\ SALES_REP_ID:INTEGER,\ PROMOTION_ID:STRING

The table is also set to expire in 7200 seconds (2 hours) for the purposes of this lab.

  1. Create a Service Account for Striim to use for connecting to BigQuery, then add policy binding and export some environment variables:

gcloud iam service-accounts create striim-bq --display-name striim-bq export PROJECT=$(gcloud info --format='value(config.project)') export sa_striim_bq=$(gcloud iam service-accounts list --filter="displayName:striim-bq" --format='value(email)') echo $PROJECT echo $sa_striim_bq gcloud projects add-iam-policy-binding $PROJECT --role roles/bigquery.dataEditor --member serviceAccount:$sa_striim_bq gcloud projects add-iam-policy-binding $PROJECT --role roles/bigquery.user --member serviceAccount:$sa_striim_bq gcloud iam service-accounts keys create ~/striim-bq-key.json --iam-account $sa_striim_bq

This will create a Service Account Key named striim-bq-key.json in your home path.

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

  2. 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:

gcloud compute scp ~/striim-bq-key.json $STRIIMVM_NAME:~ --zone=$STRIIMVM_ZONE Note: There might be a workgroup error displayed in the console - you can safely ignore that.
  1. Now, move the JSON file on the Striim VM to the /opt/striim directory using the following command:

gcloud compute ssh --zone=$STRIIMVM_ZONE $STRIIMVM_NAME -- 'sudo cp ~/striim-bq-key.json /opt/striim && sudo chown striim /opt/striim/striim-bq-key.json'

You are now ready to create a Striim application!

Click Check my progress to verify the objective. Creating a BigQuery data set

Task 6. Creating an online database migration

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.

  1. Get back to the browser tab with the Striim Web UI, and click on the Apps pane in the middle.

  2. Click on the Create App button on the upper right side of the page.

  3. There are multiple ways to create applications in Striim. Click on Start From Scratch.

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

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

  1. Drag and drop the Database tile from the Sources pane to the application canvas in the middle. Enter all of your connection properties on the right New Source.
  • Use mysql_source as the name.

  • The IP address can be found through Cloud Shell with the command 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.

  • Use the username that you set the CSQL_USERNAME environment variable as (this lab uses striim-user)

  • Use the CSQL_USER_PWD value for the password.

  1. Click the Show Advanced Settings link to see more configuration properties.
  • Enter a table name into the field Tables that you'd like to migrate with the syntax DatabaseName.SchemaName. Per your earlier MySQL setup, this should be striimdemo.ORDERS.

  • Under the OUTPUT TO section, name the new stream in the New Output box as stream_CloudSQLMySQLInitLoad.

  1. Make a note of the settings in this and the previous step as you will need them again in the next section. Click Save.

Now you will do a quick test to see if the configuration settings are correct, and that Striim can successfully connect to MySQL.

  1. In the middle of the page, there will be a button marked Created with a drop-down arrow next to it. Click the button, and select Deploy App.

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.

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

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

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

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

  5. Enter the rest of the connection properties as follows. The Service Account Key property is a fully qualified path and name of the key file you created and uploaded previously, located at /opt/striim/striim-bq-key.json.

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

  7. Enter the PROJECT_ID into the Project Id input field. The project name (PROJECT_ID) can easily be found within the Cloud Shell.

  8. Click Save. Repeat the directions in steps 8 - 10 to deploy and run the app.

Note: It might take 90 seconds for the transactions to start appearing due to the default configuration settings.
  1. In the Cloud Console, navigate to BigQuery, and then to your 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:

SELECT COUNT(*) AS ORDERS, AVG(ORDER_TOTAL) AS ORDERS_AVE, SUM(ORDER_TOTAL) AS ORDERS_SUM FROM striimdemo.orders;

Output:

Query results tabbed page

You have successfully set up your Striim environment and pipeline to perform a batch load!

Click Check my progress to verify the objective. Creating an online database migration

Task 7. Creating a continuous Cloud SQL for MySQL to BigQuery data pipeline

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.

  1. Click the Striim logo in the upper-left corner of the screen to bring up the main menu. Click on Home to bring you back to the main page, click Apps, and then click the Create App button in the upper-right corner to create a new app.
  1. Click Start from Scratch, and then name the app MySQLToBigQuery_cdc. Create it in the same admin namespace as before. This time, instead of choosing a DatabaseReader source, choose a MySQL CDC reader.

Flow Designer page

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

  2. Go back to the Cloud Shell and connect to your MySQL instance. In the striimdemo database, execute the following commands:

USE striimdemo; INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1011, 1568928576017, 'In-Store', 1011, 9, 13879.56, 320, 88252); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1012, 1568928636017, 'CompanyA', 1012, 1, 19729.99, 76, 95203); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1013, 1568928696017, 'In-Store', 1013, 5, 7286.68, 164, 45162); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1014, 1568928756017, 'Online', 1014, 1, 87268.61, 909, 70407); INSERT INTO ORDERS (ORDER_ID, ORDER_DATE, ORDER_MODE, CUSTOMER_ID, ORDER_STATUS, ORDER_TOTAL, SALES_REP_ID, PROMOTION_ID) VALUES (1015, 1568928816017, 'CompanyB', 1015, 1, 69744.13, 424, 79401);
  1. Go back to the Striim console, and you should start to see the transactions flow through!
Note: It might take 90 seconds for the transactions to start appearing due to the default configuration settings.
  1. In the Cloud Console, navigate to BigQuery, and then to your 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.

Query results tabbed page

Click Check my progress to verify the objective. Creating a continuous Cloud SQL for MySQL to BigQuery data pipeline

Congratulations!

In this lab, you successfully set up a streaming pipeline from Cloud SQL for MySQL to BigQuery.

Next steps/ Learn more

Google Cloud training and certification

...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: August 18, 2022

Last Updated Date: June 24, 2022

Copyright 2022 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.