I cant find it in cassandra.yaml, maybe nodetool can get me the configured replication factor of my cluster?
What is the default value of the replication factor?
I cant find it in cassandra.yaml, maybe nodetool can get me the configured replication factor of my cluster?
What is the default value of the replication factor?
A cluster doesn't have a replication factor, however your keyspaces does.
If you want to look at the replication factor of a given keyspace, simply execute SELECT * FROM system_schema.keyspaces;
and it will print all replication information you need.
select * from system.schema_keyspaces;
–
Benniebenning Consider using DESCRIBE SCHEMA
- it's likely that using system.schema_keyspaces
will fail to work in a future version (such as 3.0+, where schema is moved to system_schema
);
In the versions 3.0 + Cassandra you can get the RF details from the system_schema
keyspace in the system_schema.keyspaces
replication column.
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'}
For Cassandra 3.11 Version and above:
cd /usr/local/cassandra/apache-cassandra-3.11.0/bin
./cqlsh
(your Cassandra node IP)SELECT * FROM system_schema.keyspaces;
Output: You will get the replication factors of all the respective keyspaces in Cassandra
If you don't want to use cqlsh
and just want to print the info from the terminal, use the nodetool
and command called describe cluster, like this:
[user@user ~]$ nodetool describecluster
It will print very useful and brief info, including the info about keyspaces like this:
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}
If you're looking for one particular keyspace replication info, just use the following command (in this example, we'll ask about system_auth
keyspace info):
[user@user ~]$ nodetool describecluster | grep system_auth
..and it will print the info like this:
system_auth -> Replication class: NetworkTopologyStrategy {dc1=3}
© 2022 - 2024 — McMap. All rights reserved.