I am new to Cassandra, use latest Cassandra 3.10. I have 3 nodes to link to participate in Cassandra. Cluster name Test Cluster same as three nodes. Same Datacenter dc1 ,Rack as rack1 and snitch as GossipingPropertyFileSnitch used .It Configures
Node A:
-seeds : "A,B,C address"
listen_address & rpc_address are same to A node ip address
Node B:
-seeds : "A,B,C address"
listen_address & rpc_address are same to B node ip address
Node C:
-seeds : "A,B,C address"
listen_address & rpc_address are same to C node ip address
What i am do possibility here listed
i) suppose if A node is failure get data from node B and C .
ii) If any one or two node failure get data from another node. How to configure these nodes.
I have use Simple Strategy with replication factor 3 has used.
If node failure get node from another node data retrieve so, seeds address or mistaken? Briefly explain what to do.
Answering your questions:
If a Node A goes down, then you want to fetch data from node B and C.
If one or two node goes down, you want to fetch data from other node.
To achieve the above, the replication factor which you have configured is enough to handle the node failure. The wrong configuration is having all your nodes be seed node.
A seed node is used to bootstrap other nodes, So usually first node is started first in a data center as a seed node. Suppose you have 2 data centers. Then you should have 2 seed nodes, as mentioned in below datastax docs:
http://docs.datastax.com/en/cassandra/3.0/cassandra/initialize/initSingleDS.html
As per your last comment, you have mentioned "schema version mismatch detected". Which is means all your nodes are not in same cluster. Check the schema using nodetool when all your nodes are running
nodetool describecluster
This should give nodes schema version. All nodes should be same schema version.
So if any one node does not have same version then restart the node till the schema version is same.
Once you fix this schema error, you will be able to create keyspace.
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 two docker cassandra container nodes acting as node1 and node2 in the same data center.
My aim is to have my java application will always connect to node1 and my adhoc manual queries should return from node2 only (There should not be any inter node communication for data)
Normally i can execute read/write queries on top of container1 or container2 using cqlsh. If i fire some queries on top of container1 using cqlsh will it always return the data from same container (node1) or it may route to another node also internally?
and I know coordinator node will talk with peer node for data request , what will happen incase of RF=2 and 2 nodes cluster will coordinator node itself be able to serve the data?
Here, RF=2, node=2, Consistency=ONE
I have set up clusters before to separate OLTP from OLAP. The way to do it, is to separate your nodes into different logical data centers.
So node1 should have it's local data center in cassandra-rackdc.properties to be in "dc1."
dc=dc1
rack=r1
Likewise, node2 should be put into it's own data center, "dc2."
dc=dc2
rack=ra
Then your keyspace definition will look something like this:
CREATE KEYSPACE stackoverflow
WITH REPLICATION={'class':'NetworkTopologyStrategy','dc1':'1','dc2':'1'};
My aim is to have my java application will always connect to node1
In your Java code, you should specify "dc1" as your default data center, as I do in this example:
String dataCenter = "dc1";
Builder builder = Cluster.builder()
.addContactPoints(nodes)
.withQueryOptions(new QueryOptions().setConsistencyLevel(ConsistencyLevel.LOCAL_ONE))
.withLoadBalancingPolicy(new TokenAwarePolicy(
new DCAwareRoundRobinPolicy.Builder()
.withLocalDc(dataCenter).build()))
.withPoolingOptions(options);
That will make your Java app "sticky" to all nodes in data center "dc1," or just node1 in this case. Likewise, when you cqlsh into node2, your ad-hoc queries should be "sticky" to all nodes in "dc2."
Note: In this configuration, you do not have high-availability. If node1 goes down, your app will not jump over to node2.
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.
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.