arrow_back

Deploying an Open Source Cassandra™ Database using the GCP Marketplace

가입 로그인
Test and share your knowledge with our community!
done
Get access to over 700 hands-on labs, skill badges, and courses

Deploying an Open Source Cassandra™ Database using the GCP Marketplace

Lab 30분 universal_currency_alt 크레딧 1개 show_chart 입문
Test and share your knowledge with our community!
done
Get access to over 700 hands-on labs, skill badges, and courses

GSP704

Google Cloud self-paced labs logo

Overview

In this lab you will deploy an Apache Cassandra™ database using the Google Cloud marketplace. You will connect to the database using CQL Shell and run some simple DDL commands to create a table, load some data and query it.

What you'll learn

In this lab, you learn how to perform the following tasks:

  • Deploy Apache Cassandra™ using the Google Cloud marketplace.
  • Connect to Cassandra™ using CQL Shell.
  • Create keyspaces and tables using CQL.
  • Read and write data using CQL.

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

  4. Click Next.

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

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

Note: To view a menu with a list of Google Cloud products and services, click 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.

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 {{{project_0.project_id | "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
  1. Click Authorize.

Output:

ACTIVE: * ACCOUNT: {{{user_0.username | "ACCOUNT"}}} 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_0.project_id | "PROJECT_ID"}}} Note: For full documentation of gcloud, in Google Cloud, refer to the gcloud CLI overview guide.

Task 1. Deploy Cassandra™

  1. On the Navigation menu (Navigation menu icon), click Marketplace.

  2. Search for “apache cassandra” and click on the search result named "Apache Cassandra packaged by Bitnami”.

  1. Click GET STARTED.

  2. Accept the Terms and agreements, and click Agree.

  3. Click Deploy.

  1. Under Machine Type, change the Series to E2, and select the e2-medium Machine type.

  2. Leave all the other values as default, and click Deploy.

When the database has finished deploying you will see the details in the Deployment Manager.

Click Check my progress to verify the objective. Deploy Cassandra Database using the Google Cloud Marketplace

Task 2. Connect to the database

  1. Note the Admin user and Admin password on the right side.

Cassandra window displaying the highlighted Admin user and Admin password

  1. To connect to the database, open up an SSH session by clicking the SSH button on the Deployment details pane.

  2. Open up the CQL Shell by typing the following into the command line, replacing <<user>> and <<pass>> with those you previously recorded:

cqlsh -u <<user>> -p <<pass>> ifinlayson@cassandra-1-vm:~$ cqlsh -u cassandra -p DfxSsKZAQa1S Connected to My Cluster at 127.0.0.1:9042. [cqlsh 5.0.1 | Cassandra 3.11.5 | CQL spec 3.4.4 | Native protocol v4 Use HELP for help. cassandra@cqlsh

Task 3. Create a keyspace and table

  1. Once you are logged in to the database, create a keyspace:
CREATE KEYSPACE space_flights WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
  1. Create a table in the keyspace:
CREATE TABLE space_flights.catalog ( spacecraft_name text, journey_id timeuuid, start timestamp, end timestamp, active boolean, summary text, PRIMARY KEY ((spacecraft_name), journey_id) ) WITH CLUSTERING ORDER BY (journey_id desc);
  1. You can view the keyspace and table you created using the following commands:
DESCRIBE KEYSPACE space_flights; DESCRIBE TABLE space_flights.catalog;

Notice that the output includes default values for a number of settings that you did not specify when you ran the CREATE statements.

Output from the command Describe Table space_flights.catalog;

Click Check my progress to verify the objective. Create a keyspace and table

Insert data into the table

  • Insert the following data:
INSERT INTO space_flights.catalog (spacecraft_name, journey_id, start, end, active, summary) VALUES ('vostok1', 805b1a00-5673-11a8-8080-808080808080, '1961-4-12T06:07:00+0000', '1961-4-12T07:55:00+0000', False, 'First manned spaceflight. Completed one Earth orbit.'); INSERT INTO space_flights.catalog (spacecraft_name, journey_id, start, end, active, summary) VALUES ('mercury-redstone3', 2396fc00-68cd-11a8-8080-808080808080, '1961-5-5T14:34:00+0000', '1961-5-5T14:49:00+0000', False, 'First American manned suborbital spaceflight (altitude 187 kilometres, 116 miles).'); INSERT INTO space_flights.catalog (spacecraft_name, journey_id, start, end, active, summary) VALUES ('mercury-redstone4', 2d2f1800-a53c-11a8-8080-808080808080, '1961-7-21T12:20:00+0000', '1961-7-21T12:35:00+0000', False, 'Second American manned suborbital flight (altitude 118.26mi, 190km).'); INSERT INTO space_flights.catalog (spacecraft_name, journey_id, start, end, active, summary) VALUES ('vostok2', 5c2ac800-b191-11a8-8080-808080808080, '1961-8-6T05:00:00+0000', '1961-8-7T05:01:00+0000', False, 'Day-long flight. Completed 17 Earth orbits. Brief manual control by pilot.'); INSERT INTO space_flights.catalog (spacecraft_name, journey_id, start, end, active, summary) VALUES ('mercury-atlas6', 8c7b3200-4d82-11a9-8080-808080808080, '1962-2-20T15:47:00+0000', '1962-2-20T20:42:00+0000', False, 'First American manned orbital flight. Completed three orbits.'); INSERT INTO space_flights.catalog (spacecraft_name, journey_id, start, end, active, summary) VALUES ('mercury-atlas7', e9d69600-9685-11a9-8080-808080808080, '1962-5-24T13:45:00+0000', '1962-5-24T18:41:00+0000', False, 'First manual retrofire. Earth photography and study of liquids in weightless conditions.'); INSERT INTO space_flights.catalog (spacecraft_name, journey_id, start, end, active, summary) VALUES ('vostok3', ff31b400-d46d-11a9-8080-808080808080, '1962-8-11T08:30:00+0000', '1962-8-15T06:52:00+0000', False, 'First instance of two manned spacecraft in orbit simultaneously.'); INSERT INTO space_flights.catalog (spacecraft_name, journey_id, start, end, active, summary) VALUES ('vostok4', 403fcc00-d533-11a9-8080-808080808080, '1962-8-12T08:02:00+0000', '1962-8-15T06:59:00+0000', False, 'First instance of two manned spacecraft in orbit simultaneously.'); INSERT INTO space_flights.catalog (spacecraft_name, journey_id, start, end, active, summary) VALUES ('mercury-atlas8', 977b6200-fe3b-11a9-8080-808080808080, '1962-10-3T13:15:00+0000', '1962-10-3T22:28:00+0000', False, 'First flawless Mercury mission.');

Task 4. Query the table

  1. Select all of the records from the table:
select * from space_flights.catalog;

Output table displaying 9 rows under the column headings spacecraft_name, journey_id, active, end, start, summary

  1. Select one of the records by its primary key:
SELECT * FROM space_flights.catalog WHERE spacecraft_name = 'vostok2';

Output table displaying 1 row under the column headings spacecraft_name, journey_id, active, end, start, summary

  1. Exit the CQL shell:
exit
  1. Close the SSH window.

Click Check my progress to verify the objective. Insert data into the table

Congratulations!

In this lab you deployed an Apache Cassandra™ database, connected to the database using CQL Shell and ran some simple DDL commands to create a table, load some data and query it.

Next steps / Learn more

  • DataStax on the Google Cloud Marketplace!
  • Take advantage of the largest library of technical courses at DataStax Academy.

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 October 9, 2023

Lab Last Tested October 9, 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.