Quickstart Using cbt

This page explains how to use the cbt command to connect to a Cloud Bigtable instance, perform basic administrative tasks, and read and write data in a table.

If you are familiar with HBase, you might want to follow the quickstart using the HBase shell instead.

Before you begin

  1. In the Cloud Console, on the project selector page, select or create a Google Cloud project.

    Go to the project selector page

  2. Make sure that billing is enabled for your Google Cloud project. Learn how to confirm billing is enabled for your project.

  3. Enable the Cloud Bigtable and Cloud Bigtable Admin APIs.

    Enable the APIs

Create a Cloud Bigtable instance

  1. Open the Create Instance page in the Google Cloud Console.

    Open the Create Instance page

    Screenshot of the "Create instance" page

  2. For Instance name, enter Quickstart instance.

  3. For Instance ID, enter quickstart-instance.

  4. For Instance type, select Development.

  5. For Storage type, select SSD.

  6. For Cluster ID, enter quickstart-instance-c1.

  7. For Region, select us-east1.

  8. For Zone, select us-east1-c.

  9. Click Create to create the instance.

Connect to your instance

  1. Install the Cloud SDK if you haven't already.

  2. Open a terminal window, either locally or with Cloud Shell:

    Open Cloud Shell

  3. Install the cbt command:

    gcloud components update
    gcloud components install cbt
  4. Configure cbt to use your project and instance by creating a .cbtrc file, replacing [PROJECT_ID] with the project ID in which you created your Cloud Bigtable instance:

    echo project = [PROJECT_ID] > ~/.cbtrc
    echo instance = quickstart-instance >> ~/.cbtrc

Now you can use the cbt command with your instance!

Read and write data

Cloud Bigtable stores data in tables, which contain rows. Each row is identified by a row key.

Data in a row is organized into column families, which are groups of columns. A column qualifier identifies a single column within a column family.

A cell is at the intersection of a row and a column. In Cloud Bigtable, the intersection of a row and a column can have multiple cells, which are different versions of the value at that intersection. Each cell has a timestamp, which differentiates it from other cells at that intersection.

  1. Create a table named my-table.

    cbt createtable my-table
  2. List your tables:

    cbt ls

    The command displays output similar to the following:

  3. Add one column family named cf1:

    cbt createfamily my-table cf1
  4. List your column families:

    cbt ls my-table

    The command displays output similar to the following:

    Family Name     GC Policy
    -----------     ---------
    cf1             <never>
  5. Put the value test-value in the row r1, using the column family cf1 and the column qualifier c1:

    cbt set my-table r1 cf1:c1=test-value
  6. Use the cbt read command to read the data you added to the table:

    cbt read my-table

    The shell displays output similar to the following:

      cf1:c1                                   @ 2019/03/26-15:05:38.840000
  7. Delete the table my-table:

    cbt deletetable my-table

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this quickstart, follow these steps.

  1. Open the list of Cloud Bigtable instances in the Cloud Console.

    Open the instance list

  2. Click Quickstart instance.
  3. Click Delete instance.

    Screenshot of the
    'Delete instance' pane

  4. Type quickstart-instance, then click Delete to delete the instance.
  5. In your terminal, delete the .cbtrc file:
    rm ~/.cbtrc

What's next

क्या यह पेज उपयोगी था? हमारे काम के बारे में अपनी राय दें:

निम्न के बारे में फ़ीडबैक भेजें...