【Cassandra】使用nodetool cfstats / tablestats命令查询

0. 开始

・此文本是基于分发版本 DSE 4.8.16 进行记录
・从 Cassandra3.0 开始,注意命令已更改为 nodetool tablestats

1. 获取 nodetool cfstats / tablestats 摘要信息.

・Cassandra Ver3.0以降(DSE 5.0.x以降)进行了cfstats到tablestats命令的更改。
・获取一个或多个表的统计信息
(如果省略键空间和表名的指定,则输出所有表的统计信息)
・输出节点级别的统计信息
(统计值在集群内不唯一)
・计数器值在Cassandra节点启动时被重置
在数据刷新时或通过Compaction更改SSTables时更新统计信息(好像是这样)。

2. 统计数据的解释

關於令人在意的統計數據的筆記

① 使用空间(活跃), 使用空间(总共)

“使用空间 (实时) “是指SSTable在磁盘上所占用的字节数,而”使用空间 (总计)”则包括了等待进行垃圾回收的过时SSTables。

② 钥匙数量(估计)/ 分区数量(估计)

与命令名称相同,从Cassandra Ver3.0开始(DSE 5.0.x起),命令已改为从“键的数量”变为“分区的数量”。

“Number of keys (estimate)” 可以报告分区数的估计值。
(对于具有多行的聚类键,它仅表示分区数,正如DataStax管理指南中所述:“不是主键的数量。它提供了对表中估计分区数的了解。”)

(假设分区键为1列,总共有10个分区=10行)

CREATE TABLE ctest01.test01 (
    pkey1 text PRIMARY KEY,
    testdata text,
    uid timeuuid
) 

cqlsh:ctest01> select * from test01;

 pkey1                              | testdata     | uid
------------------------------------+--------------+--------------------------------------
                         \x13\x1cM- | | \nz@Qj\x1c | d0ad65f0-df07-11e8-db82-ebecdb03ffa5
 \x0ed(\x1f`\x1dM\x1etA\x0c7g\x1b"{ |  \x0fKYehv(E | 3e55a540-988c-11d3-db82-ebecdb03ffa5
     s\x0cqCGM{E^L_\x17\x1eE!\x1c3t | | \nz@Qj\x1c | c25547d0-f9e6-11e3-db82-ebecdb03ffa5
               {\x03],\x04&{r4#\x14 |  E}P^k\x7fQE | 33bf7590-28fa-11e7-db82-ebecdb03ffa5
                           |Q\x1bGF |  P+|u\x0bQ-X | 9607d760-3493-11e3-db82-ebecdb03ffa5
                    \x7fpJW*\x1d, a | | \nz@Qj\x1c | 79346760-06ba-11e6-db82-ebecdb03ffa5
                            YC\x04^ |  \x0fKYehv(E | c03a3d30-e7bd-11be-db82-ebecdb03ffa5
        C\x01%~\x1f5\x15p\x14XR\x04 |  E}P^k\x7fQE | 1fa01d60-2f3a-11d0-db82-ebecdb03ffa5
                           l\I5\x11 |  \x0fKYehv(E | 0f9f76e0-5d72-11e2-db82-ebecdb03ffa5
                            jf\x01@ |  \x0fKYehv(E | 656a0bf0-490d-11e6-db82-ebecdb03ffa5

(10 rows)
cqlsh:ctest01> 

# nodetool flush
# nodetool cfstats ctest01.test01
Keyspace: ctest01
        Read Count: 0
        Read Latency: NaN ms.
        Write Count: 10
        Write Latency: 0.0106 ms.
        Pending Flushes: 0
                Table: test01
                SSTable count: 1
 :
途中略
 : 
                Number of keys (estimate): 10
 :
途中略
 : 
# 

(如果分区键有2列,每个分区有10行)

CREATE TABLE ctest01.test02 (
    pkey1 text,
    pkey2 text,
    testdata text,
    uid timeuuid,
    PRIMARY KEY ((pkey1, pkey2))
)

cqlsh:ctest01> select * from test02;

 pkey1                              | pkey2                                 | testdata     | uid
------------------------------------+---------------------------------------+--------------+--------------------------------------
                            jf\x01@ |                               hA\x001 | .dap\x1fa\rh | ca7840b0-8a60-11b7-db82-ebecdb03ffa5
                         \x13\x1cM- |         fKu2BON8JR_`oG\x1aA\x10@\x1cI |  E}P^k\x7fQE | 79a38860-363e-11b6-db82-ebecdb03ffa5
        C\x01%~\x1f5\x15p\x14XR\x04 |         ltv*F\x05=k%o\x0fY9ngFx=\x18O |  P+|u\x0bQ-X | 59eae4f0-0f68-11d6-db82-ebecdb03ffa5
                           l\I5\x11 |                                    DD |  \x0fKYehv(E | 2e0fd9a0-7167-11c8-db82-ebecdb03ffa5
                           |Q\x1bGF |   piE\x1cl\x1a<"{\x06\x1d_K%ESh\x1fzQ | | \nz@Qj\x1c | 893da570-c9a5-11c1-db82-ebecdb03ffa5
               {\x03],\x04&{r4#\x14 |                                 \x1c- |  \x0fKYehv(E | 1aa10190-39db-11d8-db82-ebecdb03ffa5
                    \x7fpJW*\x1d, a |                   |`]\x07\x13Lna<\x07 |  P+|u\x0bQ-X | 7a7bb350-890a-11c1-db82-ebecdb03ffa5
 \x0ed(\x1f`\x1dM\x1etA\x0c7g\x1b"{ | a\nQ{h$"\x0cu\x17\x10g\x12z8l\x03\x08 | | \nz@Qj\x1c | 2e078210-5036-11ba-db82-ebecdb03ffa5
     s\x0cqCGM{E^L_\x17\x1eE!\x1c3t |                      VO\rp\x16O\x02Cr | | \nz@Qj\x1c | ee0ace30-5b4f-11ca-db82-ebecdb03ffa5
                            YC\x04^ |                Fhx_n\x7f'"\x0eK\x116= |  E}P^k\x7fQE | 918c8970-57cd-11bc-db82-ebecdb03ffa5

(10 rows)
cqlsh:ctest01> 

# nodetool flush
# nodetool cfstats ctest01.test02
Keyspace: ctest01
        Read Count: 0
        Read Latency: NaN ms.
        Write Count: 10
        Write Latency: 0.0116 ms.
        Pending Flushes: 0
                Table: test02
                SSTable count: 1
 :
途中略
 : 
                Number of keys (estimate): 10
 :
途中略
 : 
# 

(如果使用2个分区键 + 1个聚簇键,共有10个分区 = 10行 的情况下)

CREATE TABLE ctest01.test03 (
    pkey1 text,
    pkey2 text,
    ckey1 text,
    testdata text,
    uid timeuuid,
    PRIMARY KEY ((pkey1, pkey2), ckey1)
) 

cqlsh:ctest01> select * from test03;

 pkey1                              | pkey2                                 | ckey1             | testdata     | uid
------------------------------------+---------------------------------------+-------------------+--------------+--------------------------------------
                            jf\x01@ |                               hA\x001 | |\\x0eZy\x1e\x1cV |  E}P^k\x7fQE | 203db9a0-60e6-11b9-db82-ebecdb03ffa5
                         \x13\x1cM- |         fKu2BON8JR_`oG\x1aA\x10@\x1cI |        L"eJ\N\x1e |  P+|u\x0bQ-X | 729f7240-9755-11de-db82-ebecdb03ffa5
        C\x01%~\x1f5\x15p\x14XR\x04 |         ltv*F\x05=k%o\x0fY9ngFx=\x18O |      G`&\t\x1a4XC |  E}P^k\x7fQE | 1f1d7f70-e8e1-11e4-db82-ebecdb03ffa5
                           l\I5\x11 |                                    DD |       KAP>sx\x046 | | \nz@Qj\x1c | aacc8400-ba03-11bd-db82-ebecdb03ffa5
                           |Q\x1bGF |   piE\x1cl\x1a<"{\x06\x1d_K%ESh\x1fzQ |         z\x128d'0 |  P+|u\x0bQ-X | f7650b00-5cc8-11cb-db82-ebecdb03ffa5
               {\x03],\x04&{r4#\x14 |                                 \x1c- |         B7\x1eyN? | .dap\x1fa\rh | 46f91050-1965-11da-db82-ebecdb03ffa5
                    \x7fpJW*\x1d, a |                   |`]\x07\x13Lna<\x07 |  \x17Q\x01]/*\x10 |  \x0fKYehv(E | eb80fa00-3312-11cf-db82-ebecdb03ffa5
 \x0ed(\x1f`\x1dM\x1etA\x0c7g\x1b"{ | a\nQ{h$"\x0cu\x17\x10g\x12z8l\x03\x08 |        *|y\x05b(( | .dap\x1fa\rh | 980e9060-45a9-11c8-db82-ebecdb03ffa5
     s\x0cqCGM{E^L_\x17\x1eE!\x1c3t |                      VO\rp\x16O\x02Cr |     _\x12y\x0f"92 |  \x0fKYehv(E | 6b3f4190-900c-11d1-db82-ebecdb03ffa5
                            YC\x04^ |                Fhx_n\x7f'"\x0eK\x116= |        \x1b\x14P! |  E}P^k\x7fQE | 4a11ac90-03c2-11d7-db82-ebecdb03ffa5

(10 rows)
cqlsh:ctest01> 

# nodetool flush
# nodetool cfstats ctest01.test03
Keyspace: ctest01
        Read Count: 0
        Read Latency: NaN ms.
        Write Count: 10
        Write Latency: 0.023 ms.
        Pending Flushes: 0
                Table: test03
                SSTable count: 1
 :
途中略
 : 
                Number of keys (estimate): 10
 :
途中略
 : 
# 

(具有分区键为2列和聚集键为1列,共计10个分区=20行的情况下)

CREATE TABLE ctest01.test04 (
    pkey1 text,
    pkey2 text,
    ckey1 text,
    testdata text,
    uid timeuuid,
    PRIMARY KEY ((pkey1, pkey2), ckey1)
) 

cqlsh:ctest01> select * from test04;

 pkey1                              | pkey2                                 | ckey1             | testdata     | uid
------------------------------------+---------------------------------------+-------------------+--------------+--------------------------------------
                            jf\x01@ |                               hA\x001 |          Xj \x0b$ |  E}P^k\x7fQE | 07567ac0-c90e-11e3-db82-ebecdb03ffa5
                            jf\x01@ |                               hA\x001 | |\\x0eZy\x1e\x1cV |  E}P^k\x7fQE | 203db9a0-60e6-11b9-db82-ebecdb03ffa5
                         \x13\x1cM- |         fKu2BON8JR_`oG\x1aA\x10@\x1cI |         A\x0eAZqK |  \x0fKYehv(E | e2a8ff40-6a46-11e6-db82-ebecdb03ffa5
                         \x13\x1cM- |         fKu2BON8JR_`oG\x1aA\x10@\x1cI |        L"eJ\N\x1e |  P+|u\x0bQ-X | 729f7240-9755-11de-db82-ebecdb03ffa5
        C\x01%~\x1f5\x15p\x14XR\x04 |         ltv*F\x05=k%o\x0fY9ngFx=\x18O |      G`&\t\x1a4XC |  E}P^k\x7fQE | 1f1d7f70-e8e1-11e4-db82-ebecdb03ffa5
        C\x01%~\x1f5\x15p\x14XR\x04 |         ltv*F\x05=k%o\x0fY9ngFx=\x18O |        LD]v^\x12+ |  E}P^k\x7fQE | 79e14370-e10c-11e3-db82-ebecdb03ffa5
                           l\I5\x11 |                                    DD |    \x1c\x02o&\x0f |  \x0fKYehv(E | dff2cbf0-88cf-11cb-db82-ebecdb03ffa5
                           l\I5\x11 |                                    DD |       KAP>sx\x046 | | \nz@Qj\x1c | aacc8400-ba03-11bd-db82-ebecdb03ffa5
                           |Q\x1bGF |   piE\x1cl\x1a<"{\x06\x1d_K%ESh\x1fzQ |             ON\~k | | \nz@Qj\x1c | 5fca5410-5825-11ca-db82-ebecdb03ffa5
                           |Q\x1bGF |   piE\x1cl\x1a<"{\x06\x1d_K%ESh\x1fzQ |         z\x128d'0 |  P+|u\x0bQ-X | f7650b00-5cc8-11cb-db82-ebecdb03ffa5
               {\x03],\x04&{r4#\x14 |                                 \x1c- |   \x125\x05l\x7fF | | \nz@Qj\x1c | 0100e790-2f83-11dc-db82-ebecdb03ffa5
               {\x03],\x04&{r4#\x14 |                                 \x1c- |         B7\x1eyN? | .dap\x1fa\rh | 46f91050-1965-11da-db82-ebecdb03ffa5
                    \x7fpJW*\x1d, a |                   |`]\x07\x13Lna<\x07 |  \x17Q\x01]/*\x10 |  \x0fKYehv(E | eb80fa00-3312-11cf-db82-ebecdb03ffa5
                    \x7fpJW*\x1d, a |                   |`]\x07\x13Lna<\x07 |      J\x0eR\x13)^ |  E}P^k\x7fQE | 44c3def0-b6a8-11cc-db82-ebecdb03ffa5
 \x0ed(\x1f`\x1dM\x1etA\x0c7g\x1b"{ | a\nQ{h$"\x0cu\x17\x10g\x12z8l\x03\x08 |           \x06Qi$ | | \nz@Qj\x1c | faa71360-c83e-11d7-db82-ebecdb03ffa5
 \x0ed(\x1f`\x1dM\x1etA\x0c7g\x1b"{ | a\nQ{h$"\x0cu\x17\x10g\x12z8l\x03\x08 |        *|y\x05b(( | .dap\x1fa\rh | 980e9060-45a9-11c8-db82-ebecdb03ffa5
     s\x0cqCGM{E^L_\x17\x1eE!\x1c3t |                      VO\rp\x16O\x02Cr |         FL\x03+0y | .dap\x1fa\rh | c0962010-e0de-11d0-db82-ebecdb03ffa5
     s\x0cqCGM{E^L_\x17\x1eE!\x1c3t |                      VO\rp\x16O\x02Cr |     _\x12y\x0f"92 |  \x0fKYehv(E | 6b3f4190-900c-11d1-db82-ebecdb03ffa5
                            YC\x04^ |                Fhx_n\x7f'"\x0eK\x116= |        \x1b\x14P! |  E}P^k\x7fQE | 4a11ac90-03c2-11d7-db82-ebecdb03ffa5
                            YC\x04^ |                Fhx_n\x7f'"\x0eK\x116= |     R;Zo\x05\x00U | | \nz@Qj\x1c | 2308b2e0-fbf0-11c1-db82-ebecdb03ffa5

(20 rows)
cqlsh:ctest01> 

# nodetool flush
# nodetool cfstats ctest01.test04
Keyspace: ctest01
        Read Count: 0
        Read Latency: NaN ms.
        Write Count: 10
        Write Latency: 0.009699999999999999 ms.
        Pending Flushes: 0
                Table: test04
                SSTable count: 1
 :
途中略
 : 
                Number of keys (estimate): 10
 :
途中略
 : 
# 

本地阅读次数,本地写入次数。

卡桑德拉启动以后的计数值

通过获取时间差分,可以确认每个单位时间的读写次数。

这个计数器的值是针对每个表的,所以无法知道是通过哪个协调者传递的。

④ 待处理的冲洗

在DataStax管理指南中,因为它是重要的。(示例将会在不久的将来提供)

广告
将在 10 秒后关闭
bannerAds