【问题标题】:how to find total keyspace size using nodetool in cassandra?如何在 cassandra 中使用 nodetool 查找总键空间大小?
【发布时间】:2019-06-22 06:56:50
【问题描述】:

我想对 nodetool tablestats 元数据列出的所有表求和“已用空间(总计):0”。谁能知道如何做到这一点?请帮忙。

所需代码:为所有表格添加 已用空间(总计) 值;如下:

 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

【问题讨论】:

  • 还请务必提及您为解决问题所做的努力以及预期的示例输出。
  • 通过查看您的个人资料就知道您从不选择正确的答案,给它一些时间,当您在帖子上看到足够的答案时,尝试选择其中任何一个作为正确的答案。您也可以针对较早的问题执行此操作。
  • @RavinderSingh13 :在我的大多数问题中,我自己都得到了答案,并且通过 Answer your question 标签更新了相同的问题。我会尝试在我所有的问题中做同样的事情。谢谢

标签: regex bash awk cassandra-3.0 nodetool


【解决方案1】:

请您尝试一下(因为您没有提到示例,所以无法测试它)。

awk '/Space used \(total\)/{sum+=$NF} END{print sum}'  Input_file

【讨论】:

  • 没有文件。我正在使用 nodetool tablestats metadata 命令输出作为我在上面的问题块中给出的输入。
  • @ParulChourasia,如果没有文件,请像your_command | my_above_awk comand 一样,然后告诉我进展如何?
  • 下面给出的是我的 awk 输出,其中我需要第 4 列的总和。 nodetool tablestats 元数据 -H | awk '/Space used (total):/{print $0}' Space used (total): 12.71 KiB Space used (total): 118.49 KiB Space used (total): 0 bytes 已用空间(total): 0 bytes 已用空间(总计):20.89 KiB 使用以下命令:nodetool tablestats metadata -H | awk '/Space used (total):/{sum+=$4} End{print sum}' 它不打印任何东西。
  • @ParulChourasia,请在代码标签中发布nodetool tablestats metadata -H 输出一次,然后让我知道?
  • 我在问题块的顶部给出了命令的输出。
【解决方案2】:

我得到了答案,我在 awk 语句中拼错了“END”命令。更正如下:

nodetool tablestats metadata -H | awk '/Space used \(total\):/ {sum += $4} END {print sum}'

【讨论】:

  • 你不需要添加这个答案,因为我已经给出了这个答案:)
  • 是的,好的......只是试图给出我的语法的更正版本。我之前也为你的答案投票了。
  • 添加您自己的问题的答案没有害处,但只有当您没有类似的答案时,您才能编辑我的答案。添加一个 EDIT 行并将其写入您编辑的代码。还有一件事只是为了您的知识投票和正确答案是两件不同的事情,干杯和快乐的学习。
猜你喜欢
  • 2015-07-07
  • 2016-02-13
  • 2015-01-16
  • 1970-01-01
  • 2017-05-19
  • 1970-01-01
  • 2016-10-06
  • 1970-01-01
  • 2015-08-22
相关资源
最近更新 更多