As part of a POC. I have a 1 node cassandra cluster with system_auth keyspace RF=1.
I added a second node to this cluster(with empty data/commitlog/saved_cache directory) and I notice user credentials are replicated to the new node. Since RF=1 for existing node, I don't expect it to replicate to new node.
Any reason why ?
Cassandra Version : 2.1.8
For most system_auth queries, Cassandra uses a consistency level of LOCAL_ONE and uses QUORUM for the default cassandrasuperuser. If both nodes are up, you will be able to see the data and login without any problem. Also you added second node with empty commit log and saved caches, but if you copied the rest of the data form the original node the data will be there, including system_auth.
Related
I have a Single Node Cassandra Cluster which has around 44gb of data on it(/var/lib/cassandra/data/my_keyspace). The current storage is 1 tb and I need to migrate all the data to another VM which will have the same setup(single node cluster). My data-node has data being pushed to it every second so I can't afford any downtime(Some sensors are pushing time-series data).
Keyspace :- CREATE KEYSPACE my_keysopace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 43.4 GiB 256 100.0% e0ae36db-f639-430c-91ad-6af3ffb6f906 rack1
After a bit of research I decided it's best to add the new node to existing cluster and then let the old node stream all the data and after streaming is done, decommission the old node.
Source :- https://docs.datastax.com/en/archived/cassandra/2.0/cassandra/operations/ops_add_node_to_cluster_t.html
Configure old node as seed node for the new node
Add new node node to the ring(auto_bootstrap = true)
Once the status is UN for both nodes, run nodetool cleanup on old node
Decommission the old node
My only concern is will I be facing any data loss/ is this approach appropriate ?
Please let me know if I am missing anything here
Thanks
Firstly, disclaimer, using a single node of C* voids the purpose of the distributed database. Minimal cluster size tends to be 3 so some nodes can go offline without downtime (I'm sure you've seen this warning before). Now with that out the way, let's discuss the process.
Configure old node as seed node for the new node
Yep.
1.5. (Potentially missing step) The step you're missing is the consistency level of your queries needs to be verified. I see you're using replication_factor 1 for all keyspaces in use so make sure you're using a CONSISTENCY_LEVEL of ONE for your queries.
Add new node node to the ring(auto_bootstrap = true)
Sounds good. Make sure you've configured various ports / listen_address etc.
Once the status is UN for both nodes,
Once you reach UN double-check that the client isn't seeing any consistency errors.
3.5. run nodetool cleanup on old node
3.5. (Redundant step) You don't need to run nodetool cleanup. You won't care about left over data from the decommissioned node, as all the data will be moved to the new node replacing it.
Decommission the old node
Yep.
(Missing step) You'll have to modify the new node to see itself as a seed once you've decomissioned the old node or it wont be able to re-start.
I'm a beginner in Cassandra. I want to understand the two nodes(the streaming node and joining node) how to work when a new node joins an existing cluster. Can they provide normal services to the outside?
If the service is provided normally. I assumed the joining node is nodeA, and the node where the fetching data is nodeB. That means nodeA fetch data from nodeB. Assume that the data range C is transmitted from the nodeB to the nodeA, at which time new data falling into the range C is inserted into the cluster. Is the new data written to nodeA or nodeB?
I'm using datastax community edition of cassandra, version 3.11.3.
thanks!
Sun your question is bit confusing .. but what I make of it is , You want to understand the process to adding new node to existing cluster.
Adding a new node to existing cluster requires cassandra.yaml properties for new node identification and communications.
Set the following properties in the cassandra.yaml and, depending on the snitch, the cassandra-topology.properties or cassandra-rackdc.properties configuration files:
auto_bootstrap - This property is not listed in the default cassandra.yaml configuration file, but it might have been added and set to false by other operations. If it is not defined in cassandra.yaml, Cassandra uses true as a default value. For this operation, search for this property in the cassandra.yaml file. If it is present, set it to true or delete it..
cluster_name - The name of the cluster the new node is joining.
listen_address/broadcast_address - Can usually be left blank. Otherwise, use IP address or host name that other Cassandra nodes use to connect to the new node.
endpoint_snitch - The snitch Cassandra uses for locating nodes and routing requests.
num_tokens - The number of vnodes to assign to the node. If the hardware capabilities vary among the nodes in your cluster, you can assign a proportional number of vnodes to the larger machines.
seeds - Determines which nodes the new node contacts to learn about the cluster and establish the gossip process. Make sure that the -seeds list includes the address of at least one node in the existing cluster.
When a new node joins a cluster using topology defined, Seed nodes starts the gossip with the new node by the time it do not communicate with the client directly. Once the gossip completes the new node is ready to take the actual data load.
Hope this helps in understanding the process.
I have a 5 node cassandra cluster with RF=3 (only for application related db) with only 1 data centre. I wish to change password of default cassandra user
My system_auth key space has the following setting
CREATE KEYSPACE system_auth WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
Questions
Should the strategy by changed to NetworkTopology ? I thought it
wasn't required as there is only 1 DC
Should the RF be 3 same as for other application related DB ?
When I change the credentials of default cassandra user using ALTER
USER command, should I change it in each of the hosts since currently RF=1 ?
Should the strategy by changed to NetworkTopology ? I thought it
wasn't required as there is only 1 DC
Since its a single data center, simple strategy should work fine. Consider changing to Network Topology strategy when going Multi-DC
Should the RF be 3 same as for other application related DB ?
Its definitely recommended to have system_auth keyspace RF to be more than 1. Having RF=1 entails only one copy of the storing user credentials and hence any particular node loss would cause loss of a portion of authorization data. Increase it to a minimum of 3.
When I change the credentials of default cassandra user using ALTER USER command, should I change it in each of the hosts since currently RF=1 ?
No its not required to change in each node. With RF=1, the user credentials of "Cassandra" would live in only node. Irrespective of which node you pick to change its password, it will act as a coordinator and route the password change to appropriate node storing Cassandra user. Again if you loose that node which stored Cassandra, you potentially lost access to the cluster. So having RF=3, will avoid that.
I am provisioning a new datacenter for an existing cluster. A rather shaky VPN connection is hindering me from making a nodetool rebuild bootstrap of the new DC. Interestingly, I have a full fresh database snapshot/backup at the same location as the new DC (transferred outside of the VPN). I am now considering the following approach:
Make sure my clients are using the old DC.
Provision the new nodes in new DC.
ALTER the keyspace to enable replicas on the new DC. This
will start replicating all writes from old DC to new DC.
Before gc_grace_seconds after operation 3) above, use sstableloader to
stream my backup to the new nodes.
For safety precaution, do a full repair.
Would this work?
Our team also faced a similar situation. We run C* on Amazon EC2.
So first we prepared a snapshot of existing nodes and used them to create them for other datacenter(to avoid huge data transfer).
Procedure we followed:
Change replication strategy for all DC1 servers from simple-strategy to networkTopologyStrategy {DC1:x, DC2:y}
change cassandra.yaml
endpoint_snitch: GossipingPropertyFileSnitch
add a DC2 node IP to seeds list
others no need to change
change cassandra-rackdc.properties
dc=DC1
rack=RAC1
restart nodes one at a time.
restart seed node first
Alter the keyspace.
ALTER KEYSPACE keyspace_name WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'DC1' : x, 'DC2':y };
Do it for all keyspace in DC1
no need to repair.
verify if the system is stable by query
Add DC2 servers as new data center to DC1 data center
https://docs.datastax.com/en/cassandra/2.1/cassandra/operations/ops_add_dc_to_cluster_t.html
in DC2 db, cassandra.yaml > auto_bootstrap: false
fix seeds, endpoint_snitch, cluster name
Node1 DC1 IP, Node2 DC2 IP as seeds.
recommended endpoint_snitch : GossipingPropertyFileSnitch
cluster name, same as DC1: test-cluster
fix gossiping-property-file-snith : cassandra-rackdc.properties
dc=DC2
rack=RAC1
bring DC2 nodes up one at a time
seed node first
change keyspace to networkTopologyStrategy {DC1:x, DC2:y}
since the DC2 db is copied from DC1, we should repair instead of rebuild
Yes, the approach should work. I've verified it with two knowledgeable people within the Cassandra community. Two pieces that are important to note, however:
That the snapshot is being taken efter the mutations have started being written to the new datacenter.
The backup must be fully imported before gc_grace_seconds after when the backup is taken. Otherwise you risk getting zombie data popping up.
We have 2 node Cassandra cluster. Replication factor is 1 and consistency level is 1. We are not using replication as the data we are inserting is very huge for each record.
How does Cassandra reacts when a node is down when write is being performed in that node? We are using Hector API from Java client.
My understanding is that Cassandra will perform the write to other node which is running.
No, using CL.ONE the write would not be performed if the inserted data belongs to the tokenrange of the downed node. The consistency level defines how many replica nodes have to respond to accept the request.
If you want to be able to write, even if the replica node is down, you need to use CL.ANY. ANY will make sure that the coordinator stores a hint for the request. Hints are stored in System.Hints table. After the replica comes back up again, all hints will be processed and sent to the upcoming node.
Edit
You will receive the following error:
com.datastax.driver.core.exceptions.UnavailableException: Not enough replica available for query at consistency ONE (1 required but only 0 alive)