|
| 1 | +--- |
| 2 | +title: Apache Cassandra baseline testing on Google Axion C4A Arm Virtual machine |
| 3 | +weight: 5 |
| 4 | + |
| 5 | +### FIXED, DO NOT MODIFY |
| 6 | +layout: learningpathall |
| 7 | +--- |
| 8 | + |
| 9 | + |
| 10 | +Since Cassandra has been successfully installed on your GCP C4A Arm virtual machine, follow these steps to verify that it is running and functioning properly. |
| 11 | + |
| 12 | +## Baseline Testing for Apache Cassandra |
| 13 | + |
| 14 | +This guide helps verify the installation and perform baseline testing of **Apache Cassandra**. |
| 15 | + |
| 16 | +## Start Cassandra |
| 17 | + |
| 18 | +Run Cassandra in the background: |
| 19 | + |
| 20 | +```console |
| 21 | +cassandra -R |
| 22 | +``` |
| 23 | + |
| 24 | +The `-R` flag allows Cassandra to run in the background as a daemon, so you can continue using the terminal. The first startup may take **30–60 seconds** as it initializes the necessary files and processes. |
| 25 | + |
| 26 | +Check logs to ensure Cassandra started successfully: |
| 27 | + |
| 28 | +```console |
| 29 | +tail -f ~/cassandra/logs/system.log |
| 30 | +``` |
| 31 | +Look for the message **"Startup complete"**, which indicates Cassandra is fully initialized. |
| 32 | + |
| 33 | +### Check Cassandra Status |
| 34 | +```console |
| 35 | +nodetool status |
| 36 | +``` |
| 37 | +You should see an output similar to: |
| 38 | + |
| 39 | +```output |
| 40 | +Datacenter: datacenter1 |
| 41 | +======================= |
| 42 | +Status=Up/Down |
| 43 | +|/ State=Normal/Leaving/Joining/Moving |
| 44 | +-- Address Load Tokens Owns (effective) Host ID Rack |
| 45 | +UN 127.0.0.1 162.51 KiB 16 100.0% 78774686-39f3-47e7-87c3-3abc4f02a835 rack1 |
| 46 | +``` |
| 47 | +The `nodetool status` command displays the health and status of your Cassandra node(s). For a single-node setup, the output should indicate that the node is **Up (U)** and **Normal (N)**. This confirms that your Cassandra instance is running and ready to accept queries. |
| 48 | + |
| 49 | +### Connect with CQLSH (Cassandra Query Shell) |
| 50 | +**cqlsh** is the interactive command-line shell for Cassandra. It allows you to run Cassandra Query Language (CQL) commands to interact with your database, create keyspaces and tables, insert data, and perform queries. |
| 51 | + |
| 52 | +```console |
| 53 | +cqlsh |
| 54 | +``` |
| 55 | +You’ll enter the CQL (Cassandra Query Language) shell. |
| 56 | + |
| 57 | +### Create a Keyspace (like a database) |
| 58 | +A **keyspace** in Cassandra is similar to a database in SQL systems. Here, we create a simple keyspace `testks` with a **replication factor of 1**, meaning data will only be stored on one node (suitable for a single-node setup). |
| 59 | + |
| 60 | +```sql |
| 61 | +CREATE KEYSPACE testks WITH replication = {'class':'SimpleStrategy','replication_factor' : 1}; |
| 62 | +``` |
| 63 | +Check if created: |
| 64 | + |
| 65 | +```sql |
| 66 | +DESCRIBE KEYSPACES; |
| 67 | +``` |
| 68 | + |
| 69 | +You should see an output similar to: |
| 70 | + |
| 71 | +```output |
| 72 | +cqlsh> DESCRIBE KEYSPACES; |
| 73 | +
|
| 74 | +system system_distributed system_traces system_virtual_schema |
| 75 | +system_auth system_schema system_views testks |
| 76 | +``` |
| 77 | + |
| 78 | +### Create a Table |
| 79 | +Tables in Cassandra are used to store structured data. This step creates a `users` table with three columns: `id` (unique identifier), `name` (text), and `age` (integer). The `id` column is the primary key. |
| 80 | + |
| 81 | +```sql |
| 82 | +USE testks; |
| 83 | + |
| 84 | +CREATE TABLE users ( |
| 85 | + id UUID PRIMARY KEY, |
| 86 | + name text, |
| 87 | + age int |
| 88 | +); |
| 89 | +``` |
| 90 | + |
| 91 | +### Insert Data |
| 92 | +We insert two sample rows into the `users` table. The `uuid()` function generates a unique identifier for each row, which ensures that every user entry has a unique primary key. |
| 93 | + |
| 94 | +```sql |
| 95 | +INSERT INTO users (id, name, age) VALUES (uuid(), 'Alice', 30); |
| 96 | +INSERT INTO users (id, name, age) VALUES (uuid(), 'Bob', 25); |
| 97 | +``` |
| 98 | + |
| 99 | +### Query Data |
| 100 | +This command retrieves all rows from the `users` table. Successful retrieval confirms that data insertion works correctly and that queries return expected results. |
| 101 | + |
| 102 | +```sql |
| 103 | +SELECT * FROM users; |
| 104 | +``` |
| 105 | + |
| 106 | +You should see an output similar to: |
| 107 | + |
| 108 | +```output |
| 109 | + id | age | name |
| 110 | +--------------------------------------+-----+------- |
| 111 | + c08dafde-17f0-4a4a-82b8-54455bb07836 | 25 | Bob |
| 112 | + d47eb93c-3988-4aa1-bc85-9561500a6893 | 30 | Alice |
| 113 | +
|
| 114 | +(2 rows) |
| 115 | +``` |
| 116 | + |
| 117 | +This baseline test verifies that Cassandra 5.0.5 is installed and running correctly on the VM. It confirms the node status, allows connection via `cqlsh`, and ensures basic operations like creating a keyspace, table, inserting, and querying data work as expected. |
0 commit comments