随笔 - 2228  文章 - 4  评论 - 372  阅读 - 1109万

监控和管理Cassandra

了解Cassandra集群的性能特点有助于诊断和维护Cassandra。由于Cassandra使用JAVA开发的,所以它就提供了JMX环境下的一些管理工具来管理Cassandra,它们包括:Cassandra nodetool工具、DataStax OpsCenter管理控制台和JConsole。

使用nodetool工具

nodetool是一个命令行的工具集,它可以监控Cassandra和执行例行的数据库操作。作为内建的工具,nodetool一般用于在节点上直接运行。

nodetool工具集支持大多数重要的JMX指标和操作,并且包含了一些为管理员准备的命令。这个工具集用得最多的还是输出集群环的快速摘要和集群的当前状况——也就是nodetool status。

nodetool工具集提供了一批用于查看表的指标、服务器指标和压缩统计。

  • nodetool cfstats显示了每个表和keyspace的统计数据
  • nodetool cfhistograms提供了表的统计数据,包括读写延迟,行大小,列的数量和SSTable的数量。
  • nodetool netstats提供了网络连接操作的统计数据。
  • nodetool tpstats提供了如active、pending以及完成的任务等Cassandra操作的每个阶段的状态。

示例:

nodetool cfstats命令:

复制代码
D:\EBOOK\NoSQL\apache-cassandra-2.2.6\bin>nodetool cfstats
Starting NodeTool
Keyspace: system_traces
        Read Count: 0
        Read Latency: NaN ms.
        Write Count: 0
        Write Latency: NaN ms.
        Pending Flushes: 0
                Table: events
                SSTable count: 0
                Space used (live): 0
                Space used (total): 0
                Space used by snapshots (total): 0
                Off heap memory used (total): 0
                SSTable Compression Ratio: 0.0
                Number of keys (estimate): -1
                Memtable cell count: 0
                Memtable data size: 0
                Memtable off heap memory used: 0
                Memtable switch count: 0
                Local read count: 0
                Local read latency: NaN ms
                Local write count: 0
                Local write latency: NaN ms
                Pending flushes: 0
                Bloom filter false positives: 0
                Bloom filter false ratio: 0.00000
                Bloom filter space used: 0
                Bloom filter off heap memory used: 0
                Index summary off heap memory used: 0
                Compression metadata off heap memory used: 0
                Compacted partition minimum bytes: 0
                Compacted partition maximum bytes: 0
                Compacted partition mean bytes: 0
                Average live cells per slice (last five minutes): NaN
                Maximum live cells per slice (last five minutes): 0
                Average tombstones per slice (last five minutes): NaN
                Maximum tombstones per slice (last five minutes): 0

                Table: sessions
                SSTable count: 0
                Space used (live): 0
                Space used (total): 0
                Space used by snapshots (total): 0
                Off heap memory used (total): 0
                SSTable Compression Ratio: 0.0
                Number of keys (estimate): -1
                Memtable cell count: 0
                Memtable data size: 0
                Memtable off heap memory used: 0
                Memtable switch count: 0
                Local read count: 0
                Local read latency: NaN ms
                Local write count: 0
                Local write latency: NaN ms
                Pending flushes: 0
                Bloom filter false positives: 0
                Bloom filter false ratio: 0.00000
                Bloom filter space used: 0
                Bloom filter off heap memory used: 0
                Index summary off heap memory used: 0
                Compression metadata off heap memory used: 0
                Compacted partition minimum bytes: 0
                Compacted partition maximum bytes: 0
                Compacted partition mean bytes: 0
                Average live cells per slice (last five minutes): NaN
                Maximum live cells per slice (last five minutes): 0
                Average tombstones per slice (last five minutes): NaN
                Maximum tombstones per slice (last five minutes): 0

----------------
Keyspace: system
        Read Count: 52
        Read Latency: 7.373384615384615 ms.
        Write Count: 105
...
...
复制代码

 

nodetool netstats命令:
复制代码
D:\EBOOK\NoSQL\apache-cassandra-2.2.6\bin>nodetool netstats
Starting NodeTool
Mode: NORMAL
Not sending any streams.
Read Repair Statistics:
Attempted: 0
Mismatch (Blocking): 0
Mismatch (Background): 0
Pool Name                    Active   Pending      Completed
Large messages                  n/a         0              0
Small messages                  n/a         0              0
Gossip messages                 n/a         0              0

D:\EBOOK\NoSQL\apache-cassandra-2.2.6\bin>
复制代码
nodetool tpstats命令:
复制代码
D:\EBOOK\NoSQL\apache-cassandra-2.2.6\bin>nodetool tpstats
Starting NodeTool
Pool Name                    Active   Pending      Completed   Blocked  All time blocked
MutationStage                     0         0            209         0                 0
ReadStage                         0         0              1         0                 0
RequestResponseStage              0         0              0         0                 0
ReadRepairStage                   0         0              0         0                 0
CounterMutationStage              0         0              0         0                 0
HintedHandoff                     0         0              0         0                 0
MiscStage                         0         0              0         0                 0
CompactionExecutor                0         0            145         0                 0
MemtableReclaimMemory             0         0              7         0                 0
PendingRangeCalculator            0         0              1         0                 0
GossipStage                       0         0              0         0                 0
MigrationStage                    0         0              0         0                 0
MemtablePostFlush                 0         0             35         0                 0
ValidationExecutor                0         0              0         0                 0
Sampler                           0         0              0         0                 0
MemtableFlushWriter               0         0              7         0                 0
InternalResponseStage             0         0              0         0                 0
AntiEntropyStage                  0         0              0         0                 0
CacheCleanupExecutor              0         0              0         0                 0
Native-Transport-Requests         0         0              0         0                 0

Message type           Dropped
READ                         0
RANGE_SLICE                  0
_TRACE                       0
MUTATION                     0
COUNTER_MUTATION             0
REQUEST_RESPONSE             0
PAGED_RANGE                  0
READ_REPAIR                  0

D:\EBOOK\NoSQL\apache-cassandra-2.2.6\bin>
复制代码

 

DataStax OpsCenter

相对于nodetool而言,DataStax OpsCenter就方便多了。DataStax OpsCenter提供了统一的图形化入口来监控和管理Cassandra集群。DataStax OpsCenter是与DataStax服务一起打包的。你可以注册一个免费的版本用于开发或非生产环境下使用。

有一点屁民瑞威认为比较重要:那就是OpsCenter的监控指标和相关信息是存储在Cassandra里面而不是存储到其他地方,所以这就给我们一个好的学习使用Cassandra的例子。

关于这个工具的安装和使用,屁民部落将在随后的文章中提及。

JConsole

JConsole这个工具是JDK5.0以后自带的用于监控JAVA程序。估计这个工具用得不多,也就不做过多介绍。有兴趣的朋友可以查看其官方文档。

posted on   duanxz  阅读(7591)  评论(0编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端
历史上的今天:
2012-11-07 zk 03之 linux上的zookeeper单机与伪集群安装
2012-11-07 Guava 2.1-不可变集合
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示