用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Dev-Toolbelt/dev-team-agents --skill cassandra命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | cassandra |
| description | Cassandra — partition keys, CQL, consistency levels, CLI. |
Load when the project uses Cassandra or ScyllaDB (signal: cassandra-driver, cassandra-python-driver, datastax-astra, cassandra: in docker-compose, CASSANDRA_HOST env var).
# cqlsh (bundled with Cassandra):
cqlsh "$CASSANDRA_HOST" "${CASSANDRA_PORT:-9042}" \
-u "$CASSANDRA_USER" -p "$CASSANDRA_PASSWORD"
# with TLS:
cqlsh "$CASSANDRA_HOST" 9142 --ssl \
-u "$CASSANDRA_USER" -p "$CASSANDRA_PASSWORD"
# DataStax Astra (cloud):
cqlsh -b "$ASTRA_BUNDLE_PATH" -u "$ASTRA_CLIENT_ID" -p "$ASTRA_SECRET"
Key inspection commands:
DESCRIBE KEYSPACES;
DESCRIBE TABLES;
DESCRIBE TABLE keyspace.table;
SELECT * FROM system.local; -- node info, rack, DC
SELECT * FROM system.peers; -- cluster topology
TRACING ON; -- trace next query for latency breakdown
Cassandra requires query-driven data modeling. Unlike relational databases, denormalization is expected.
Primary key anatomy:
PRIMARY KEY ((partition_key), clustering_col1, clustering_col2)
WHERE partition_key = ?)Design rules:
-- Create table with TTL:
CREATE TABLE user_sessions (
user_id UUID,
session_id UUID,
data TEXT,
PRIMARY KEY (user_id, session_id)
) WITH default_time_to_live = 86400;
-- Insert with per-row TTL:
INSERT INTO user_sessions (user_id, session_id, data)
VALUES (?, ?, ?) USING TTL 3600;
-- Lightweight transaction (compare-and-set):
INSERT INTO users (id, email) VALUES (?, ?) IF NOT EXISTS;
UPDATE users SET email = ? WHERE id = ? IF email = ?;
| Level | Reads from | Writes to | Trade-off |
|---|---|---|---|
ONE | 1 replica | 1 replica | Fastest; risk of stale reads |
QUORUM | Majority | Majority | Strong consistency across DC |
LOCAL_QUORUM | Majority in local DC | Majority in local DC | Low latency in multi-DC |
ALL | All replicas | All replicas | Strongest; not fault-tolerant |
EACH_QUORUM | Quorum per DC | Quorum per DC | Geo-distributed writes |
Strong consistency rule: read CL + write CL > replication factor
QUORUM (2) + read QUORUM (2) = 4 > 3 → strongly consistentDefault recommendation: write LOCAL_QUORUM, read LOCAL_QUORUM for most OLTP workloads.
| Strategy | Best for |
|---|---|
SizeTieredCompactionStrategy (default) | Write-heavy; infrequent reads; heavy data |
LeveledCompactionStrategy | Read-heavy; predictable read latency; smaller SSTables |
TimeWindowCompactionStrategy | Time series with TTL; groups SSTables by time window |
Change strategy: ALTER TABLE t WITH compaction = {'class': 'LeveledCompactionStrategy'};
nodetool tpstatsTRUNCATE in production without checking dependent materialized views| Gotcha | Fix |
|---|---|
ALLOW FILTERING in query | Re-model the table for the query or add a SAI index |
| Hotspot partition (one partition grows unbounded) | Add a time-bucket to the partition key |
| Lightweight transactions (IF NOT EXISTS) slow | Use sparingly — they use Paxos; not for hot paths |
Reading with IN on partition key | May cause coordinator hotspot; prefer parallel single-partition reads |
nodetool repair not scheduled | Run weekly on each node; skipping causes inconsistency and tombstone accumulation |