Nodetool 常用命令整理

Nodetool是一个用来监控和维护Cassandra数据库的一个命令行工具。这里列出一些比较实用的命令。


数据备份相关

snapshot
给keyspace或者table创建一个快照
snapshot会保存在data/keyspace_name/table-UID/snapshots/snapshot_name

bash-4.4$ nodetool snapshot test_keyspace
Requested creating snapshot(s) for [test_keyspace] with snapshot name [1632883572068] and options {skipFlush=false}
Snapshot directory: 1632883572068
bash-4.4$ nodetool snapshot test_keyspace.test_table
Requested creating snapshot(s) for [test_keyspace.test_table] with snapshot name [1632884361616] and options {skipFlush=false}
Snapshot directory: 1632884361616


listsnapshot
顾名思义,列出本地所有保存的snapshot

bash-4.4$ nodetool listsnapshots
Snapshot Details:
Snapshot name Keyspace name Column family name True size Size on disk
1632884361616 test_keyspace test_table         0 bytes   893 bytes
1632884289001 test_keyspace test_table         0 bytes   893 bytes

clearsnapshot
删除snapshot, 建议带上 -t 和 快照名,否则会把所有快照删掉

bash-4.4$ nodetool clearsnapshot -t 1632884361616
Requested clearing snapshot(s) for [all keyspaces] with snapshot name [1632884361616]

nodetool没有复原快照的命令,如果有需求必须手动去restore,可以参考以下链接
https://docs.datastax.com/en/dse/5.1/dse-admin/datastax_enterprise/operations/opsBackupSnapshotRestore.html

refresh
重新加载磁盘中的sstable。 在复原snapshot时可能会先替换sstable然后再refresh

reloadlocalschema
加载磁盘里的表结构
scrub
保存一个快照,然后重构sstable

bash-4.4$ nodetool scrub test_keyspace test_table2

查看数据库统计数据

tablestats
查看表的统计数据,命令加keyspace来查看可以space里所有表,也可以加单个表如下

bash-4.4$ nodetool tablestats test_keyspace.test_table2
Total number of tables: 179
----------------
Keyspace : test_keyspace
        Read Count: 0
        Read Latency: NaN ms
        Write Count: 0
        Write Latency: NaN ms
        Pending Flushes: 0
                Table: test_table2
                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: -1.0
                Number of partitions (estimate): 0
                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
                Percent repaired: 100.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
                Dropped Mutations: 0

----------------

tableshistograms
获取15分钟内的读写延迟信息

bash-4.4$ nodetool tablehistograms test_keyspace test_table2
No SSTables e
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值