如何在 cassandra 中使用 nodetool 查找总密钥空间大小?
how to find total keyspace size using nodetool in cassandra?
我想对 nodetool tablestats metadata 列出的所有表求和“Space 使用(总计):0” .谁能知道如何做到这一点?请帮忙
所需代码:为所有表添加 Space 使用(总计) 值;如下所示:
for Table: dbtimestamp
size += value(Space used (total))
Table: dbtimestamp_compressed
size += value((Space used (total))
Table: migration_status
size += value((Space used (total))
----------------------------------------------------------------------------
nodetool tablestats metadata
Total number of tables: 584
----------------
Keyspace : metadata
Read Count: 296
Read Latency: 0.23686486486486488 ms
Write Count: 68611
Write Latency: 0.02151582107825276 ms
Pending Flushes: 0
Table: dbtimestamp
SSTable count: 0
Space used (live): 0
Space used (total): 0
Space used by snapshots (total): 0
Off heap memory used (total): 0
Table: dbtimestamp_compressed
SSTable count: 0
Space used (live): 0
Space used (total): 0
Space used by snapshots (total): 0
Off heap memory used (total): 0
Table: migration_status
SSTable count: 2
Space used (live): 13014
Space used (total): 13014
Space used by snapshots (total): 0
Off heap memory used (total): 80
Table: reporttimestamp_by_type
SSTable count: 2
Space used (live): 121332
Space used (total): 121332
Space used by snapshots (total): 0
Off heap memory used (total): 112
能否请您尝试以下(因为您没有提到样品所以无法测试)。
awk '/Space used \(total\)/{sum+=$NF} END{print sum}' Input_file
我得到了答案,我在 awk statement.corrected 中拼错了 'END' 命令,如下所示:
nodetool tablestats metadata -H | awk '/Space used \(total\):/ {sum += } END {print sum}'
我想对 nodetool tablestats metadata 列出的所有表求和“Space 使用(总计):0” .谁能知道如何做到这一点?请帮忙
所需代码:为所有表添加 Space 使用(总计) 值;如下所示:
for Table: dbtimestamp
size += value(Space used (total))
Table: dbtimestamp_compressed
size += value((Space used (total))
Table: migration_status
size += value((Space used (total))
----------------------------------------------------------------------------
nodetool tablestats metadata
Total number of tables: 584
----------------
Keyspace : metadata
Read Count: 296
Read Latency: 0.23686486486486488 ms
Write Count: 68611
Write Latency: 0.02151582107825276 ms
Pending Flushes: 0
Table: dbtimestamp
SSTable count: 0
Space used (live): 0
Space used (total): 0
Space used by snapshots (total): 0
Off heap memory used (total): 0
Table: dbtimestamp_compressed
SSTable count: 0
Space used (live): 0
Space used (total): 0
Space used by snapshots (total): 0
Off heap memory used (total): 0
Table: migration_status
SSTable count: 2
Space used (live): 13014
Space used (total): 13014
Space used by snapshots (total): 0
Off heap memory used (total): 80
Table: reporttimestamp_by_type
SSTable count: 2
Space used (live): 121332
Space used (total): 121332
Space used by snapshots (total): 0
Off heap memory used (total): 112
能否请您尝试以下(因为您没有提到样品所以无法测试)。
awk '/Space used \(total\)/{sum+=$NF} END{print sum}' Input_file
我得到了答案,我在 awk statement.corrected 中拼错了 'END' 命令,如下所示:
nodetool tablestats metadata -H | awk '/Space used \(total\):/ {sum += } END {print sum}'