Cassandra - rollthecloudinc/school GitHub Wiki

Great! It looks like the playbook ran successfully, and Cassandra has been installed and configured on your machine. Now, let's perform a quick test to ensure that Cassandra is running and accessible.

Step 1: Verify the Cassandra Service

Check the status of the Cassandra service to confirm it is running:

Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML sudo systemctl status cassandra

You should see output indicating that the service is active (running). If it is not running, check the logs for errors:

Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML sudo journalctl -u cassandra

Step 2: Verify the Cassandra Version

Run the following command to verify the installed version of Cassandra:

Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML /opt/cassandra/bin/cassandra -v

This should return the version of Cassandra, e.g.,

4.1.9.

Step 3: Test Cassandra with cqlsh

The

cqlsh (Cassandra Query Language Shell) tool is included with Cassandra. Use it to connect to Cassandra and run a simple query:

  1. cqlsh:/opt/cassandra/bin/cqlshYou should see a prompt like this:Connected to TestCluster at 127.0.0.1:9042.[cqlsh 6.0.0 | Cassandra 4.1.9 | CQL spec 3.4.5 | Native protocol v5]Use HELP for help.

  2. cqlsh prompt, create a keyspace and a table:CREATE KEYSPACE test_keyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };USE test_keyspace;CREATE TABLE test_table (id UUID PRIMARY KEY, name TEXT);INSERT INTO test_table (id, name) VALUES (uuid(), 'Test Entry');SELECT * FROM test_table;You should see the inserted row in the output.

  3. cqlsh:exit

Step 4: Test Cassandra with nodetool

The

nodetool command is used to manage and monitor Cassandra nodes. Run the following command to check the status of the node:

Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML /opt/cassandra/bin/nodetool status

You should see output similar to this:

Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML Datacenter: datacenter1 ======================= Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack UN 127.0.0.1 123.45 KiB 256 100.0% abcdefgh-1234-5678-90ab-cdefghijklmn rack1

  • Status=UN means Up and Normal, indicating the node is running.

  • Address=127.0.0.1 shows the node is bound to the local address.

Step 5: Test Environment Variables

Ensure the environment variables are set correctly for all users. Run the following:

Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML echo $CASSANDRA_HOME

The output should be

/opt/cassandra.

Also, confirm the

PATH includes Cassandra's bin directory:

Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML echo $PATH

You should see

/opt/cassandra/bin in the output.

Step 6: Optional - Start Cassandra on Boot

If Cassandra is not already set to start on boot, enable the service:

Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML sudo systemctl enable cassandra

This ensures Cassandra starts automatically when the machine reboots.