1.查看集群是否使用了vnodes
用途:使用了virtual nodes,删除了节点之后它会自动均衡数据,不要你手动处理。
主要看你的cassandra.yml配置文件中,是否配置了initial_token,如果没有配置,就是使用了vnodes。
cassandra/conf$ less cassandra.yaml
# initial_token allows you to specify tokens manually. While you can use # it with
# vnodes (num_tokens > 1, above) -- in which case you should provide a
# comma-separated list -- it's primarily used when adding nodes # to legacy clusters
# that do not have vnodes enabled.
# initial_token:
发现这一行注释了,所以使用了virtual nodes
2.查看replication_factor
主要是运维一个比较生疏的集群,尤其在删除节点的时候,尤其要注意是不是会造成数据的丢失,所以需要看一下。
有两种方式:
a. desc keyspace_name
$desc
这个命令会把这个keyspace_name以及下面所有的column family都desc一下。
cqlsh> desc keyspace example;
CREATE KEYSPACE ad WITH replication = {
'class': 'NetworkTopologyStrategy', 'DC1': '3'} AND durable_writes = true;
...desc other column families
b.在system keyspace里面查看
cqlsh> use system;
cqlsh:system> select * from schema_keyspaces;
keyspace_name | durable_writes | strategy_class | strategy_options
---------------+----------------+------------------------------------------------------+----------------------------
OpsCenter | False | org.apache.cassandra.locator.NetworkTopologyStrategy | {
"DC1":"1","DC2":"1"}
system | True | org.apache.cassandra.locator.LocalStrategy | {}
example | True | org.apache.cassandra.locator.NetworkTopologyStrategy | {
"DC1":"3"}
可以看到ad这个keyspace的Strategy是NetworkTopologyStrategy,{"DC1":"3"}
3.查看当前集群状态
/cassandra/bin$ ./nodetool status
Datacenter: DC1
===================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving