监控和管理Cassandra

时间:2022-04-20 03:36:58

了解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.\bin>nodetool cfstats
Starting NodeTool
Keyspace: system_traces
Read Count:
Read Latency: NaN ms.
Write Count:
Write Latency: NaN ms.
Pending Flushes:
Table: events
SSTable count:
Space used (live):
Space used (total):
Space used by snapshots (total):
Off heap memory used (total):
SSTable Compression Ratio: 0.0
Number of keys (estimate): -
Memtable cell count:
Memtable data size:
Memtable off heap memory used:
Memtable switch count:
Local read count:
Local read latency: NaN ms
Local write count:
Local write latency: NaN ms
Pending flushes:
Bloom filter false positives:
Bloom filter false ratio: 0.00000
Bloom filter space used:
Bloom filter off heap memory used:
Index summary off heap memory used:
Compression metadata off heap memory used:
Compacted partition minimum bytes:
Compacted partition maximum bytes:
Compacted partition mean bytes:
Average live cells per slice (last five minutes): NaN
Maximum live cells per slice (last five minutes):
Average tombstones per slice (last five minutes): NaN
Maximum tombstones per slice (last five minutes): Table: sessions
SSTable count:
Space used (live):
Space used (total):
Space used by snapshots (total):
Off heap memory used (total):
SSTable Compression Ratio: 0.0
Number of keys (estimate): -
Memtable cell count:
Memtable data size:
Memtable off heap memory used:
Memtable switch count:
Local read count:
Local read latency: NaN ms
Local write count:
Local write latency: NaN ms
Pending flushes:
Bloom filter false positives:
Bloom filter false ratio: 0.00000
Bloom filter space used:
Bloom filter off heap memory used:
Index summary off heap memory used:
Compression metadata off heap memory used:
Compacted partition minimum bytes:
Compacted partition maximum bytes:
Compacted partition mean bytes:
Average live cells per slice (last five minutes): NaN
Maximum live cells per slice (last five minutes):
Average tombstones per slice (last five minutes): NaN
Maximum tombstones per slice (last five minutes): ----------------
Keyspace: system
Read Count:
Read Latency: 7.373384615384615 ms.
Write Count:
...
...
nodetool netstats命令:
D:\EBOOK\NoSQL\apache-cassandra-2.2.\bin>nodetool netstats
Starting NodeTool
Mode: NORMAL
Not sending any streams.
Read Repair Statistics:
Attempted:
Mismatch (Blocking):
Mismatch (Background):
Pool Name Active Pending Completed
Large messages n/a
Small messages n/a
Gossip messages n/a D:\EBOOK\NoSQL\apache-cassandra-2.2.\bin>
nodetool tpstats命令:
D:\EBOOK\NoSQL\apache-cassandra-2.2.\bin>nodetool tpstats
Starting NodeTool
Pool Name Active Pending Completed Blocked All time blocked
MutationStage
ReadStage
RequestResponseStage
ReadRepairStage
CounterMutationStage
HintedHandoff
MiscStage
CompactionExecutor
MemtableReclaimMemory
PendingRangeCalculator
GossipStage
MigrationStage
MemtablePostFlush
ValidationExecutor
Sampler
MemtableFlushWriter
InternalResponseStage
AntiEntropyStage
CacheCleanupExecutor
Native-Transport-Requests Message type Dropped
READ
RANGE_SLICE
_TRACE
MUTATION
COUNTER_MUTATION
REQUEST_RESPONSE
PAGED_RANGE
READ_REPAIR D:\EBOOK\NoSQL\apache-cassandra-2.2.\bin>

DataStax OpsCenter

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

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

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

JConsole

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