Skip to main content

Connecting to Cloud Bigtable with cbt

Hands-On Lab

 

Photo of Joseph Lowery

Joseph Lowery

Google Cloud Training Architect II in Content

Length

00:30:00

Difficulty

Beginner

Sometimes data is relatively straight-forward — there's just an overwhelming amount of it. That's exactly what Cloud Bigtable is meant for. Cloud Bigtable is a fully managed NoSQL database service designed to handle massive amounts of information. In this hands-on lab, you’ll configure database instances and clusters for Cloud Bigtable in the console and then use command line cbt commands to create a schema and populate the table with data.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Connecting to Cloud Bigtable with cbt

In this hands-on lab, you’ll configure database instances and clusters for Cloud Bigtable in the console and then use command line cbt commands to create a schema and populate the table with data.

How to Log in to Google Lab Accounts

On the lab page, right-click Open GCP Console and select the option to open it in a new private browser window (this option will read differently depending on your browser — e.g., in Chrome, it says "Open Link in Incognito Window"). Then, sign in to Google Cloud Platform using the credentials provided on the lab page.

On the Welcome to your new account screen, review the text, and click Accept. In the "Welcome L.A.!" pop-up once you're signed in, check to agree to the terms of service, choose your country of residence, and click Agree and Continue.

Connecting to Cloud Bigtable with cbt

Now, on to the lab!

Enable API.

  1. From the main navigation, choose APIs & Services > Library.
  2. Search for Bigtable.
  3. Select the Cloud Bigtable Admin API card.
  4. Click Enable.

Create Bigtable instance.

  1. Navigate to Bigtable.
  2. Choose Create instance.
  3. Set the following fields:
    • Instance name: la-data-cbt
    • Instance type: Development
    • Storage type: HDD
    • Cluster Region: us-east1
    • Cluster Zone: us-east1-b
  4. Click Done and then Create.

Install and configure cbt.

  1. Activate the Cloud Shell by clicking its icon in the top row.

  2. If you're working from your own command line, you may need to first enter:

    gcloud components update
  3. In the Cloud Shell, enter the following:

    gcloud components install cbt
  4. Configure cbt with the following commands (replacing <PROJECT_ID> with the yellow ID found in the Cloud Shell):

    echo project = <PROJECT_ID> > ~/.cbtrc
    echo instance = la-data-cbt >> ~/.cbtrc

Create data table.

  1. In the Cloud Shell, enter the following:

    cbt createtable la-table
    cbt ls

Define table structure and add data.

  1. In the Cloud Shell, enter the following to create the first column family (a group of columns):

    cbt createfamily la-table offerings
  2. Enter the following to create the column qualifier (the column within the column family) and put some data in the first cell:

    cbt set la-table r1 offerings:c1=labs
  3. Review the results so far:

    cbt read la-table
  4. Add a second column qualifier:

    cbt set la-table r1 offerings:c2=courses
  5. Review the results:

    cbt read la-table

Delete Bigtable instance.

  1. From the console, select the Bigtable instance.
  2. Click Delete Instance.
  3. Enter the name of the instance in the dialog to confirm the deletion.
  4. Click Delete.

Conclusion

Congratulations on completing this hands-on lab!