Apache Cassandra

CQLSH Consistency

“This tutorial will discuss how to use the consistency command in CQLSH. This command permits us to set and gather the cluster consistency level.”

In Cassandra, the consistency level governs the number of replica nodes required to reply for the proxy node (coordinator node) to process a non-lightweight transaction.

Source: Wikimedia Commons

MUST DO

Before modifying the data consistency levels for non-lightweight and lightweight transactions, ensure to familiarize yourself with Cassandra Data consistency operations, Quorum calculations, Data Replication, etc.

Command Syntax

The following describes the command syntax.

CONSISTENCY [ consistency_level ]

The command accepts the consistency_level as the parameter. Check the docs for more details on consistency levels and their corresponding functionality.

Cassandra Show Consistency Level

To display the current consistency level in Cassandra, use the consistency command without parameters as shown:

cassandra@cqlsh> consistency
Current consistency level is ONE.

By default, the consistency level is set to ONE.

Cassandra Change Consistency Level

You can use the consistency command followed by the consistency level you wish to set.

The following are the support Read Consistency Levels in Cassandra.

Source: DataStax Documentation.

Supported Write Consistency Levels:

Source: DataStax Documentation

For example, to set the consistency level to QUORUM, run the command:

cassandra@cqlsh> consistency quorum;
Consistency level set to QUORUM.

NOTE: The above command is provided for illustration purposes. Read the docs to determine how and why to change Cassandra’s consistency levels.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list