【发布时间】:2016-04-23 21:55:46
【问题描述】:
我在 cassandra.yaml 中找不到它,也许 nodetool 可以获取我集群的配置复制因子?
复制因子的默认值是多少?
【问题讨论】:
我在 cassandra.yaml 中找不到它,也许 nodetool 可以获取我集群的配置复制因子?
复制因子的默认值是多少?
【问题讨论】:
集群没有复制因子,但是您的 keyspaces does。
如果您想查看给定键空间的复制因子,只需执行SELECT * FROM system_schema.keyspaces;,它将打印您需要的所有复制信息。
【讨论】:
select * from system.schema_keyspaces;
考虑使用DESCRIBE SCHEMA - 使用system.schema_keyspaces 可能无法在未来的版本中工作(例如3.0+,其中架构移至system_schema);
【讨论】:
在 3.0 + Cassandra 版本中,您可以从 system_schema.keyspaces replication 列中的 system_schema 键空间获取 RF 详细信息。
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 的命令,如下所示:
[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}
【讨论】: