我在 cassandra.yaml 中找不到它,也许 nodetool 可以让我获得集群的配置复制因子?
复制因子的默认值是多少?
集群没有复制因子,但是您的键空间有。
如果您想查看给定键空间的复制因子,只需执行 SELECT * FROM system_schema.keyspaces;
,它将打印您需要的所有复制信息。
考虑使用DESCRIBE SCHEMA
- usingsystem.schema_keyspaces
在未来的版本中可能无法正常工作(例如 3.0+,其中架构移至system_schema
);
在 3.0 + Cassandra 版本中,您可以从复制列system_schema
中的键空间获取 RF 详细信息。system_schema.keyspaces
cassandra@cqlsh:system_schema> SELECT * FROM system_schema.keyspaces;
keyspace_name | durable_writes | replication
--------------------+----------------+-------------------------------------------------------------------------------------
system_auth | True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '1'}
system_schema | True | {'class': 'org.apache.cassandra.locator.LocalStrategy'}
system_distributed | True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '3'}
company | True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '2'}
system | True | {'class': 'org.apache.cassandra.locator.LocalStrategy'}
jerry | True | {'class': 'org.apache.cassandra.locator.NetworkTopologyStrategy'}
system_traces | True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '2'}
对于 Cassandra 3.11 及以上版本:
cd /usr/local/cassandra/apache-cassandra-3.11.0/bin
./cqlsh
您的 Cassandra 节点 IP)SELECT * FROM system_schema.keyspaces;
输出:您将获得 Cassandra 中所有相应键空间的复制因子
如果您不想使用cqlsh
并且只想从终端打印信息,请使用nodetool
名为describe cluster的 and 命令,如下所示:
[user@user ~]$ nodetool describecluster
它将打印非常有用且简短的信息,包括有关键空间的信息,如下所示:
Keyspaces:
system_schema -> Replication class: LocalStrategy {}
system -> Replication class: LocalStrategy {}
system_distributed -> Replication class: SimpleStrategy {replication_factor=3}
system_traces -> Replication class: SimpleStrategy {replication_factor=2}
system_auth -> Replication class: NetworkTopologyStrategy {dc1=3}
如果您正在寻找一个特定的键空间复制信息,只需使用以下命令(在此示例中,我们将询问system_auth
键空间信息):
[user@user ~]$ nodetool describecluster | grep system_auth
..它会打印这样的信息:
system_auth -> Replication class: NetworkTopologyStrategy {dc1=3}