Puntos de control
Dataflow API
/ 10
Create a cloud Bigtable instance
/ 15
Create new cloud Bigtable table
/ 15
Load data files from cloud storage using a dataflow template
/ 30
Delete a Bigtable table and instance
/ 10
Creating and Populating a Bigtable Instance
GSP1054
Overview
Bigtable is Google's fully managed, scalable NoSQL database service. Bigtable is ideal for storing large amounts of data in a key-value store and for use cases such as personalization, ad tech, financial tech, digital media, and Internet of Things (IoT). Bigtable supports high read and write throughput at low latency for fast access to large amounts of data for processing and analytics.
For personalization use cases, Bigtable can handle both high writes to store users' interactions with online products and high reads to provide these interactions to models that produce personalized recommendations.
In this lab, you use the Google Cloud Console to create a Bigtable instance with a table to store user interactions with products. Then, you use a Dataflow template to populate the table from pre-generated data files on Cloud Storage. After the Dataflow job has finished, you verify that the table has been successfully populated with data and then complete the lab by deleting the Bigtable data.
What you'll do
In this lab, you learn how to create a Bigtable instance and load data from Cloud Storage without writing any code.
- Create a Bigtable instance and a Bigtable table with column families.
- Use a Dataflow template to load SequenceFile files from Cloud Storage into Bigtable.
- Verify the data loaded into Bigtable.
- Delete the Bigtable table and instance.
Prerequisites
- Basic understanding of database concepts and terms such as instances, schemas, and keys
- Completion of the lab titled Designing and Querying Bigtable Schemas
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).
- Time to complete the lab---remember, once you start, you cannot pause a lab.
How to start your lab and sign in to the Google Cloud console
-
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 Cloud console button
- Time remaining
- The temporary credentials that you must use for this lab
- Other information, if needed, to step through this lab
-
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.
Note: If you see the Choose an account dialog, click Use Another Account. -
If necessary, copy the Username below and paste it into the Sign in dialog.
{{{user_0.username | "Username"}}} You can also find the Username in the Lab Details panel.
-
Click Next.
-
Copy the Password below and paste it into the Welcome dialog.
{{{user_0.password | "Password"}}} You can also find the Password in the Lab Details panel.
-
Click Next.
Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges. -
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 Google Cloud console opens in this tab.
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.
- Click Activate Cloud Shell at the top of the Google Cloud console.
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.
- (Optional) You can list the active account name with this command:
- Click Authorize.
Output:
- (Optional) You can list the project ID with this command:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
Dataflow API
Ensure that the Dataflow API is successfully enabled
To ensure access to the necessary API, restart the connection to the Dataflow API.
-
In the Google Cloud Console, enter Dataflow API in the top search bar.
-
Click on the result for Dataflow API.
-
Click Manage.
-
Click Disable API.
If you are asked to confirm, click Disable.
-
Click Enable.
Click Check my progress to verify the objective.
Task 1. Create a Bigtable instance
To create a new table in Bigtable, you first need to create a Bigtable instance to store your table.
-
In the Google Cloud Console, on the Navigation menu (), under Databases, click Bigtable.
-
Click Create instance.
-
Enter the required information to create a Bigtable instance:
Property | Value |
---|---|
Instance name | Personalized Sales |
Instance ID | Leave the default value |
Storage Type | SSD |
Cluster ID | Leave the default value |
Region | |
Zone | |
Node scaling mode | Manual allocation |
Quantity | Leave the default value |
- Click Create.
Click Check my progress to verify the objective.
Task 2. Create a new Bigtable table
In Bigtable, each row in a table has a unique identifier called a row key, and columns in a table are grouped by column family to organize related columns. In this task, you create a new Bigtable table with appropriate row keys and column families for user interactions.
First, you create a table named UserSessions to store user online interactions with various products and confirmed sales, using the user ID combined with the timestamp as the row key. Then you create two column families called Interactions and Sales to help organize the related columns.
-
From the list of Bigtable instances, click on the instance ID named personalized-sales.
-
In the navigation menu, under Instance, click Tables.
-
Click Create table.
-
For Table ID, type UserSessions
-
Click Add column family.
-
For Column family name, type Interactions
Leave the default value for garbage collection policy.
-
Click Done.
-
Repeat steps 5 through 7 to create another column family named Sales.
-
Click Create.
Click Check my progress to verify the objective.
Task 3. Load data files from Cloud Storage using a Dataflow template
In this task, you run a Dataflow job to load data from Cloud Storage to Bigtable. In order to run the Dataflow job successfully, you first have to create a Cloud Storage bucket for Dataflow to write temporary files as needed. Then you can successfully create and run a new Dataflow job from a template.
Create a Cloud Storage bucket
-
In the Google Cloud Console, on the Navigation menu (), click Cloud overview > Dashboard.
-
Under Project info, copy the value for Project ID (such as
). You will use your Qwiklabs Project ID, which is already globally unique, as the Cloud Storage bucket name.
-
In the Google Cloud Console, on the Navigation menu (), click Cloud Storage > Buckets.
-
Click Create Bucket.
-
Enter the required information to create a Cloud Storage bucket, replacing project-id with the project ID you copied in step 2.
Property | Value |
---|---|
Name | project-id |
Location type | Multi-region |
Location | us (multiple regions in United States) |
Leave the default values for the remaining parameters.
-
Click Create.
-
If prompted Public access will be prevented, click Confirm.
Create a Dataflow job using a template
-
In the Google Cloud Console, on the Navigation menu (), under Analytics, click Dataflow > Jobs.
-
Click Create job from template.
-
Enter the required information to create a Dataflow job from a template, replacing project-id with the project ID you previously copied.
Property | Value |
---|---|
Job name | import-usersessions |
Regional endpoint | |
Dataflow template | SequenceFile Files on Cloud Storage to Cloud Bigtable |
Project ID | project-id |
Instance ID | personalized-sales |
Table ID | UserSessions |
Source path pattern | gs://cloud-training/OCBL377/retail-interactions-sales-00000-of-00001 |
Temporary location | gs://project-id/temp |
Leave the default values for the remaining parameters.
-
Click Run Job.
-
On the Job Graph page, under Job steps view, select Graph view.
The Graph view displays a graph of how the job progresses to complete the following steps:
- Read the SequenceFiles on Cloud Storage.
- Mutate the data for loading into Bigtable.
- Write the data to Bigtable.
- To see a table view of the same steps, select Table view.
When the job has successfully completed, a green check mark for a Succeeded status is displayed next to each task in the Job Graph. This job will take approximately 3 to 5 minutes to run successfully.
Click Check my progress to verify the objective.
Task 4. Verify data loaded into Bigtable
After your Dataflow job has successfully completed, you can use cbt
(Cloud Bigtable command-line tool) commands to connect to your Bigtable instance and verify that the table has been populated with data.
Configure the Bigtable CLI
To connect to Bigtable using cbt
CLI commands, you first need to update the .cbtrc
configuration file with your project ID and your Bigtable instance ID using Cloud Shell.
For a review of how to access Cloud Shell, click Setup and Requirements on the right-side menu of this page.
- To modify the
.cbtrc
file with the project ID and instance ID, run the following commands in Cloud Shell:
- To verify that you successfully modified the
.cbtrc
file, run the following command:
The output should resemble the following:
Query data in the table
After you configure the .cbtrc
configuration file in Cloud Shell, you can run a simple cbt
CLI command to query the first ten records of the table.
- To see the data for the first ten rows of the table, run the following command:
The output is structured as follows:
The output values will resemble the following:
Task 5. Delete a Bigtable table and instance
-
In the Google Cloud Console, on the Navigation menu (), under Databases, click Bigtable.
-
From the list of Bigtable Instances, click on the Instance ID named personalized-sales.
-
In the navigation menu, under Instance, click Tables.
-
Click on the table named UserSessions.
-
Click Delete table.
-
In the confirmation dialog, type UserSessions
-
Click Delete.
-
In the navigation menu, under Instance, click Overview.
-
Click Delete instance.
-
In the confirmation dialog, type personalized-sales
-
Click Delete.
Click Check my progress to verify the objective.
Congratulations!
In this lab, you used Bigtable to create a new instance and table, loaded data into the table using a Dataflow template, and confirmed that the data was successfully loaded by running simple cbt
CLI commands. Then, you completed the lab by deleting the Bigtable table and instance.
Next steps / Learn more
- Check out the lab titled Streaming Data to Bigtable.
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.
Manual Last Updated May 30, 2024
Lab Last Tested February 17, 2023
Copyright 2024 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.