cqlsh
interactive Cassandra Query Language shell
TLDR
Start CQL shell
SYNOPSIS
cqlsh [options] [host] [port]
nodetool [options] command [args]
DESCRIPTION
cqlsh is the Cassandra Query Language shell for executing CQL statements interactively or from scripts. nodetool manages Cassandra node operations.
CQL resembles SQL with some differences. Keyspaces are like databases; tables have partition keys and clustering columns. Queries must include partition key for efficient lookups.
nodetool status shows cluster health with Up/Down/Normal/Leaving/Joining states and token ownership. nodetool repair ensures data consistency across replicas.
Snapshots create hard-linked backups of SSTables for point-in-time recovery. cleanup removes data after topology changes. compact forces SSTable compaction.
Node lifecycle operations: drain prepares for shutdown, decommission removes node from cluster streaming data to others.
CONFIGURATION
~/.cassandra/cqlshrc
User-specific cqlsh settings including connection defaults, display formatting, and authentication credentials./etc/cassandra/cassandra.yaml
Main Cassandra configuration file controlling cluster behavior, data directories, network settings, and replication.
CQLSH PARAMETERS
-u, --username user
Authentication username.-p, --password pass
Authentication password.-k, --keyspace keyspace
Initial keyspace.-f file
Execute CQL file.-e statement
Execute single CQL statement.--ssl
Use SSL connection.--connect-timeout secs
Connection timeout.--request-timeout secs
Query timeout.
NODETOOL COMMANDS
status
Show cluster node status.info
Node information.ring
Token ring information.repair [keyspace]
Run anti-entropy repair.cleanup [keyspace]
Remove data not belonging to node.compact [keyspace]
Force compaction.flush [keyspace]
Flush memtables to SSTables.snapshot [name]
Take snapshot backup.decommission
Decommission the node.drain
Drain node for shutdown.describecluster
Cluster information.
CAVEATS
CQL is not SQL; avoid joins and complex queries. Wide partitions impact performance. Repair is resource-intensive; schedule appropriately. Decommission before removing nodes. Authentication default is off.
HISTORY
Apache Cassandra was initially developed at Facebook for inbox search and open-sourced in 2008. It became an Apache project in 2009 and top-level in 2010. Cassandra combines Dynamo's distribution model with Bigtable's data model. DataStax was founded in 2010 to provide commercial support. Version 4.0 (2021) brought major improvements after extensive testing.
