Linux command
cqlsh 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Start CQL shell
cqlsh
Connect to remote host
cqlsh [hostname] [9042]
Connect with authentication
cqlsh -u [username] -p [password]
Execute CQL from file
cqlsh -f [script.cql]
Execute single statement
cqlsh -e "SELECT * FROM [keyspace].[table]"
Check node status
nodetool status
View cluster info
nodetool info
Repair a node
nodetool repair
说明
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.
FAQ
What is the cqlsh command used for?
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.
How do I run a basic cqlsh example?
Run `cqlsh` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
Where can I find more cqlsh examples?
This page includes 8 examples for cqlsh, plus related commands for nearby Linux tasks.