Quick Wins

DSE Version: 6.0

Video

Exercises

In this unit, we will go through a quick overview on how to get Apache Cassandra started, and look at the basic commands used to interact with the database. There are two choices of distributions, DataStax Enterprise and Apache Cassandra open source.

NO TRANSCRIPT AVAILABLE.

No write up.

Exercise 1 Install and Start Apache Cassandra

In this exercise, you will:

  • SSH into your cloud instance using the IP provided by your instructor
  • In root directory, find and install DataStax Enterprise from a tarball instance
  • Start DataStaxEnterprise and verify that it is running with nodetool

To do the remaining exercises, you must complete this one successfully. If you have any questions, alert your instructor.

Steps

If you are taking this course in a class environment, your instructor will assign you and IP address of a cloud instance you will SSH into.

1) SSH to the cloud instance provided using the IP address provided to you by the instructor.
ssh -i your-key-file-name ubuntu@ip-address

2) In your home directory, list the contents and notice the presence of dse-6.0.0-bin.tar.gz. For this course, we will install DataStax Enterprise by extracting it locally. Do so by running the following command:
tar -xf dse-6.0.0-bin.tar.gz

3) List the contents of the directory again. You now have a dse-6.0.0/directory. Rename this directory to node/ by executing the following command:
mv dse-6.0.0 node

4) We have a simple auto-configuration script for you to tweak some values so that we can run Apache Cassandra multiple times on the same virtual machine instance. Run the script like so:
labwork/config_node

5) CD into the directory with DataStax Enterprise by running:
cd node/bin

6) Start DataStax Enterprise (and thus, Apache Cassandra™) from here by running:
./dse cassandra
DataStax Enterprise might take a few minutes to start up! Be patient. You may need to hit enter to get back a prompt.

7) To check to see if DataStax Enterprise has started, run the following:
./dsetool status

If it started up properly, you will see something like:

 
DC: Cassandra       Workload: Cassandra       Graph: no
======================================================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--   Address    Load        Owns    Token   Rack    Health [0,1]
UN   127.0.0.1  88.01 KiB   ?       0       rack1   0.00
8) Leave it up and running for the next exercise. Congrats! You installed and started DataStax Enterprise.

 

Exercise 2 CQL

In this exercise, you will:
  • Create a keyspace for KillrVideo
  • Create a table to store video metadata
  • Load the data for the video table from a CSV file

Steps

Welcome to the KillrVideo company! KillrVideo hired you to build the latest and greatest video sharing application on the Internet. Your task is to ramp up on the domain and become acquainted with Apache Cassandra™. To start, you decided to look into creating a table schema and to load some video data.

The video metadata is made up of:
Column NameData Type
video_idtimeuuid
added_datetimestamp
TitleText

1) Back in your Terminal window, make sure DataStax Enterprise is still running with ./dsetool status. If not, restart DataStax Enterprise.

2) In the terminal window, start cqlsh:

/home/ubuntu/node/resources/cassandra/bin/cqlsh

3) In cqlsh, create a keyspace called killrvideo. Use SimpleStrategy for the replication class with a replication factor of one.

NOTE: You can press the tab key within the CREATE KEYSPACE command to have `cqlsh` autocomplete the replication parameters.

4) In cqlsh switch to the newly created keyspace with the USE command.

5) Create a single table called videos with the same structure as shown above. video_id is the primary key.

6) Manually insert a single record using into the table using INSERT command. Use the first row from the table below:
video_idadded_datetitle
1645ea59-14bd-11e5-a993-8138354b7e312014-01-29Cassandra History
245e8024-14bd-11e5-9743-8238356b7e322012-04-03Cassandra & SSDs
3452f7de-14bd-11e5-855e-8738355b7e3a2013-03-17Cassandra Intro
4845ed97-14bd-11e5-8a40-8338255b7e332013-10-16DataStax DevCenter
5645f8bd-14bd-11e5-af1a-8638355b8e3a2013-04-16What is DataStax Enterprise?

7) Write a SELECT statement to verify your record was inserted.

8) Insert the second record as well and run a select statement to verify it's there.

9) Let's remove the data you inserted using the TRUNCATE command.

TRUNCATE videos;

10) Execute the following command to import data into your videos table.

COPY videos(video_id, added_date, title) FROM '/home/ubuntu/labwork/data-files/videos.csv' WITH HEADER=TRUE;

11) Use SELECT to verify the data loaded correctly.

12) Use SELECT to COUNT(*) the number of imported rows. It should match the number of rows COPY reported as imported.

13) To leave CQLSH execute this command:

QUIT

No FAQs.
No resources.
Comments are closed.