温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Cassandra内建的工具nodetool - 监控篇

发布时间:2020-07-04 15:52:58 来源:网络 阅读:1322 作者:无锋剑 栏目:大数据

Cassandra 常用监控命令

Cassandra 自带了多个功能强大集群或数据管理工具,数量掌握有助于诊断和维护Cassandra集群、快速解决各种问题:

nodetool

nodetool是一个命令行的工具集,它可以监控Cassandra和执行例行的数据库操作。作为内建的工具,nodetool一般用于在节点上直接运行。
nodetool工具集支持大多数重要的JMX指标和操作,并且包含了一些为管理员准备的命令。

相关命令如下:

nodetool: 是一个命令行的工具集,它可以监控Cassandra和执行例行的数据库操作。作为内建的工具,nodetool一般用于在节点上直接运行。
nodetool工具集支持大多数重要的JMX指标和操作,并且包含了一些为管理员准备的命令。

cassandra utility: Cassandra utility 其实是Cassandra提供的一个启动时配置接口,也就是说通过这个方法可以配置cassandra启动参数,例如运行时java heap size等。

cassandra-stress tool:cassandra stress tool是一个针对集群进行压力测试的工具.

SSTable utilities: 是一组操作sstable的工具

CQL shell:是一个通过CQL( Cassandra Query Language)来与Cassandra集群中的数据进行交互的命令行工具,

集群节点列表:

[cassandra]
172.20.101.157 
172.20.101.164 
172.20.101.165 
172.20.101.160 
172.20.101.166 
172.20.101.167 

列出nodetool所有可用的命令

    nodetool help 

列出指定command 的帮助内容

    nodetool help command-name
例如:查看status 命令的详细帮助内容
    nodetool help status

nodetool常用监控命令:

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

nodetool describecluster

输出集群信息

Cluster Information:
        Name: pttest
        Snitch: org.apache.cassandra.locator.GossipingPropertyFileSnitch
        DynamicEndPointSnitch: enabled
        Partitioner: org.apache.cassandra.dht.Murmur3Partitioner
        Schema versions:
                8560f200-adbb-3a18-8d5e-a1f7f7856194: [172.20.101.164, 172.20.101.165, 172.20.101.166, 172.20.101.167, 172.20.101.160, 172.20.101.157]

nodetool status:

输出集群环的快速摘要和集群的当前状况;

[root@kubm-01 ~]# nodetool status 
Datacenter: dc1
===============
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address         Load       Tokens Owns (effective)  Host ID                               Rack
UN  172.20.101.164  173.72 KiB  256    34.2%       dcbbad83-fe7c-4580-ade7-aa763b8d2c40  rack1
UN  172.20.101.165  50.4 KiB   256    35.0%       cefe8a3b-918f-463b-8c7d-faab0b9351f9  rack1
UN  172.20.101.166  95.5 KiB   256    34.1%       88e16e35-50dd-4ee3-aa1a-f10a8c61a3eb  rack1
UN  172.20.101.167  50.4 KiB   256    32.3%       8808aaf7-690c-4f0c-be9b-ce655c1464d4  rack1
UN  172.20.101.160  194.83 KiB  256    31.5%       57cc39fc-e47b-4c96-b9b0-b004f2b79242  rack1
UN  172.20.101.157  176.67 KiB  256    33.0%       091ff0dc-415b-48a7-b4ce-e70c84bbfafc  rack1

nodetool netstats:

显示网络连接操作的统计数据;

[root@kubm-01 ~]# nodetool netstats --human-readable
Mode: NORMAL
Not sending any streams.
Read Repair Statistics:
Attempted: 0
Mismatch (Blocking): 0
Mismatch (Background): 0
Pool Name                    Active   Pending      Completed   Dropped
Large messages                  n/a         0              0         0
Small messages                  n/a         0            163         0
Gossip messages                 n/a         0        3150335         0

查看某个节点负载,内存使用情况

[ptmind@kubm-01 ~]$ nodetool info 
ID                     : 091ff0dc-415b-48a7-b4ce-e70c84bbfafc
Gossip active          : true
Thrift active          : false
Native Transport active: true
Load                   : 282.65 KiB
Generation No          : 1561803589
Uptime (seconds)       : 844997
Heap Memory (MB)       : 354.14 / 3970.00
Off Heap Memory (MB)   : 0.00
Data Center            : dc1
Rack                   : rack1
Exceptions             : 0
Key Cache              : entries 119, size 11.7 KiB, capacity 100 MiB, 435 hits, 596 requests, 0.730 recent hit rate, 14400 save period in seconds
Row Cache              : entries 0, size 0 bytes, capacity 0 bytes, 0 hits, 0 requests, NaN recent hit rate, 0 save period in seconds
Counter Cache          : entries 0, size 0 bytes, capacity 50 MiB, 0 hits, 0 requests, NaN recent hit rate, 7200 save period in seconds
Chunk Cache            : entries 11, size 704 KiB, capacity 480 MiB, 1388 misses, 2253 requests, 0.384 recent hit rate, NaN microseconds miss latency
Percent Repaired       : 100.0%
Token                  : (invoke with -T/--tokens to see all 256 tokens)w

nodetool tpstats:

显示如active、pending以及完成的任务等Cassandra操作的每个阶段的状态;

OPTIONS
        -F <format>, --format <format>
            Output format (json, yaml)
[root@kubm-01 ~]# nodetool tpstats 
Pool Name                         Active   Pending      Completed   Blocked  All time blocked
ReadStage                              0         0            140         0                 0
MiscStage                              0         0              0         0                 0
CompactionExecutor                     0         0         491131         0                 0
MutationStage                          0         0             45         0                 0
MemtableReclaimMemory                  0         0            586         0                 0
PendingRangeCalculator                 0         0             13         0                 0
GossipStage                            0         0        3150790         0                 0
.....
PerDiskMemtableFlushWriter_0           0         0            586         0                 0
ValidationExecutor                     0         0              0         0                 0
.....

Message type           Dropped
READ                         0
.........
REQUEST_RESPONSE             0
PAGED_RANGE                  0
READ_REPAIR                  0

nodetool cfstats:

显示了每个表和keyspace的统计数据;

选项
        -F <format>, --format <format>
            Output format (json, yaml)
        -H, --human-readable
            Display bytes in human readable form, i.e. KiB, MiB, GiB, TiB
        -i
            Ignore the list of tables and display the remaining tables
创建keyspace
create keyspace ptmind_test with replication = {'class':'NetworkTopologyStrategy','dc1':2} and durable_writes = true;

创建表
cassandra@cqlsh:ptmind_test> CREATE TABLE users (
               ...   user_id text PRIMARY KEY,
               ...   first_name text,
               ...   last_name text,
               ...   emails set<text>
               ... );

插入数据:
INSERT INTO users (user_id, first_name, last_name, emails) VALUES('2', 'kevin', 'kevin', {'kevin@ptmind.com', 'kevin@gmail.com'});
查看指定表空间,默认输出所有

[root@kubm-01 ~]# nodetool cfstats ptmind_test.users
Total number of tables: 37
----------------
Keyspace : ptmind_test
        Read Count: 0
        Read Latency: NaN ms
        Write Count: 0
        Write Latency: NaN ms
        Pending Flushes: 0
                Table: users
................................
                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
                Dropped Mutations: 0

nodetool cfhistograms:

显示表的统计数据,包括读写延迟,行大小,列的数量和SSTable的数量;

[root@kubm-01 ~]# nodetool cfhistograms ptmind_test.users

No SSTables exists, unable to calculate 'Partition Size' and 'Cell Count' percentiles
ptmind_test/users histograms
Percentile  SSTables     Write Latency      Read Latency    Partition Size        Cell Count
                              (micros)          (micros)           (bytes)                  
50%             0.00              0.00              0.00               NaN               NaN
........
Max             0.00              0.00              0.00               NaN               NaN

nodetool compactionstats

显示当前正在压缩的任务进度

pending tasks: 0
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI