【问题标题】:Search key of big partition in cassandracassandra中大分区的搜索键
【发布时间】:2017-03-18 04:34:26
【问题描述】:

nodetool cfstats/tablestats 显示“压缩分区最大字节数”

现在如何找到这个分区或其他巨大分区的键?

目的是分析为什么这些分区越来越大,并相应地纠正数据模型。

我已经看到可以在日志中看到这些分区键,但不幸的是我的日志会被定期删除。

【问题讨论】:

标签: cassandra


【解决方案1】:

您可能会查看nodetool toppartitions 命令,它应该向您显示最活跃的分区。有时它有助于分析和管理您的数据。

【讨论】:

    【解决方案2】:

    您可以使用 instaclustr 工具

    https://www.instaclustr.com/support/documentation/tools/ic-tools-for-cassandra-sstables/

    以下命令对于查找大分区很有用:

    ic-pstats [-n <num>] [-t <snapshot>] [-f <filter>] <keyspace> <column-family>

    -n <num>    Number of partitions to display in leaders lists
    -t <name>   Snapshot to analyse (snapshot name from nodetool listsnapshots). Snapshot is created if none is specified.
    -f <files>  Comma separated list of Data.db sstables to filter on
    

    另一个有用的工具是 sstable-tools:

    https://github.com/tolbertam/sstable-tools

    它有一个描述命令,显示最宽和最大的分区

    java -jar sstable-tools.jar describe ma-2-big-Data.db
    

    输出是这样的:

    /Users/clohfink/git/sstable-tools/./src/test/resources/ma-2-big-Data.db
    =======================================================================
    Partitions: 1
    Rows: 1
    Tombstones: 0
    Cells: 4
    Widest Partitions:
       [frodo] 1
    Largest Partitions:
       [frodo] 104 (104 B)
    Tombstone Leaders:
    Partitioner: org.apache.cassandra.dht.Murmur3Partitioner
    Bloom Filter FP chance: 0.010000
    Size: 50 (50 B)
    Compressor: org.apache.cassandra.io.compress.LZ4Compressor
      Compression ratio: -1.0
    Minimum timestamp: 1455937221199050 (02/19/2016 21:00:21)
    Maximum timestamp: 1455937221199050 (02/19/2016 21:00:21)
    SSTable min local deletion time: 2147483647 (01/18/2038 21:14:07)
    SSTable max local deletion time: 2147483647 (01/18/2038 21:14:07)
    TTL min: 0 (0 milliseconds)
    

    【讨论】:

      【解决方案3】:

      也许您可以使用Apache drillpresto-db 之类的外部工具来运行如下查询:

      SELECT key1, key2, COUNT(*) AS total
      FROM yourTable
      GROUP BY key1, key2
      ORDER BY total DESC
      LIMIT 10;
      

      key1key2 是分区键的一部分。

      此查询将按大小获取前 10 个分区。

      希望对你有帮助。

      【讨论】:

      • 我正在尝试用 spark 来做到这一点,这可悲地导致其他问题。
      猜你喜欢
      • 2020-10-05
      • 1970-01-01
      • 2018-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-18
      • 2019-06-02
      相关资源
      最近更新 更多