Search code examples
cassandracql3

Cassandra Query for a Specific Node


I am using cassandra 1.2.15 cluster with 4 number of nodes and having a keyspace with a replication of 2 in Simple Network Topology. And I am using Murmur3Partitioner. I have used default configurations that are available in the yaml file. First node is the seed node, other 3 nodes pointed the first node as seed node.

First node yaml configuration is

initial_token: left empty
num_tokens: 256
auto_bootstrap: false

Other 3 nodes yaml configuration is

initial_token: left empty
num_tokens: 256
auto_bootstrap: true

I have three questions, My main question is Question1,

Question 1:

  • I need to query a specific node on the cluster. (ie) In a four node cluster I need to make a query to select all the rows in a column family for the node 2 alone.Is it possible? If yes how to proceed?

Question 2:

  • Whether my yaml configuration is correct or not for the above approach?

Question 3:

  • Whether this configuration will make any trouble in future, if I add two nodes in the cluster?

Solution

  • Q1 I need to query a specific node on the cluster. (ie) In a four node cluster I need to make a query to select all the rows in a column family for the node 2 alone.Is it possible? If yes how to proceed?

    Nope, not possible. What you can do is query a specific datacenter using the LOCAL_QUORUM or EACH_QUORUM consistency levels. Or you can connect to a specific node and query the system KS which is specific to each node (by specifying the address in either cqlsh or your driver). There are some times where this can be useful, but it's not what you're after.

    Q2 Whether my yaml configuration is correct or not for the above approach? In 1.2 I think it might be a better idea to populate the tokens on your own for your initial nodes rather than leaving that to C*. As for auto_bootstrap, false is the right choice for a fresh cluster node:

    This setting has been removed from default configuration. It makes new (non-seed)
    nodes automatically migrate the right data to themselves. When initializing a
    fresh cluster with no data, add auto_bootstrap: false.

    Q3 Whether this configuration will make any trouble in future, if I add two nodes in the cluster?

    I'd advice you to move away from simple network topology simply because it complicates the process of expanding to multiple data centres. Another thin to remember is to enable auto-bootstrap for your new nodes and it should work quite nicely with v-nodes.