My production environment has one keyspace with a replication factor of 1 , I want to use ALTER KEYSPACE command to make it 3 , I am afraid that this operation will affect the production operation , Please tell me the result
My production environment has one keyspace with a replication factor of 1 , I want to use ALTER KEYSPACE command to make it 3 , I am afraid that this operation will affect the production operation , Please tell me the result
@KongBaiZZ what version of Cassandra are you using? Is it DataStax Enterprise (DSE)® or Open Source Apache Cassandra® or DataStax Astra DB®? Also, could you update your original question here to state what is the read & write consistency level that is being used by your application drivers?
I believe you mean ALTER KEYSPACE. That will actually not have any effect, other than replicating the writes. The impact will come from running a repair after you alter the keyspace replication factor. The repair will create merkle trees which will repair the data and replicate it to the other 2 nodes. That could likely have an impact, but it should be sustainable if you've properly sized your cluster. Repairs are a normal part of Cassandra operation as well, so a properly sized cluster should see negligible impact.
@steve.lacerda That is to say, After I use the Aleter Keyspace command, my production environment data can be accessed normally? Can you tell me the specific run command.
//first: ALTER KEYSPACE XXX WITH replication = {'class':'NetworkTopologyStrategy', 'replication_factor' : 3};
I don't know what command I need to run after Alter keyspace
ll me
After you ALTER the keyspace replication factor, cqlsh will say something like you need to run a repair. Which means you will need to run:
nodetool repair -pr <keyspace>
on all nodes in the cluster.
What @steve.lacerda said. Also, while you're at this activity, I would recommend you to go ahead with leveraging the following so that you don't have to re-do (i.e. change from SimpleStrategy
to NetworkTopologyStrategy
for the replication class) this when you want to expand your existing cluster to multiple datacenters in future,
REPLICATION = {
'class' : 'NetworkTopologyStrategy',
'datacenter_name' : N [,
'datacenter_name' : N ]
}
Online apps are using this keyspace data , So I think Alter keyspace will affect the app?? Are you sure it won't have any effect?
If it won't have any effect,Can you tell me how how should I do this.
first step am i running this command ?
But I don't know what command I need to run after Alter keyspace;
Can you tell me the detailed command steps?
one:
two:
three:
@KongBaiZZ see the documentation here for reference. Yes, your [properly right sized] cluster will be operating normally as it was before after issuing the alter command.
Changing the replication factor from 1 to 3 will have a huge impact to production clusters.
With only 1 replica, you would almost certainly be using a consistency level of ONE
or LOCAL_ONE
for read requests. Immediately after you issue the ALTER KEYSPACE
command, there will be an additional 2 replicas which would "think" they own the data and will respond to read requests.
However until you have full repaired the keyspace on all nodes in the ring, those 2 additional replicas will not have the data yet so your application will get inconsistent results.
As a workaround, you should update your application to use a consistency of LOCAL_QUORUM
for read requests to reduce the possibility that reads will return no results. Cheers!
8 People are following this question.
DataStax Enterprise is powered by the best distribution of Apache Cassandra ™
© 2023 DataStax, Titan, and TitanDB are registered trademarks of DataStax, Inc. and its subsidiaries in the United States and/or other countries.
Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries.
Privacy Policy Terms of Use