Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use different ports for nodes in a Cassandra cluster?

Tags:

cassandra

We are programmatically creating Cassandra nodes (auto-generating yaml and using CassandraDaemon). Ideally we would be able to use different ports on different hosts due to configuration needs. Is this possible (via seed specification or implementation of a custom class)? It seems that the seeds list can only take IP addresses and not ports.

like image 308
Martin Serrano Avatar asked Jun 06 '13 19:06

Martin Serrano


People also ask

Which ports does Cassandra use?

What ports does Cassandra use? By default, Cassandra uses 7000 for cluster communication (7001 if SSL is enabled), 9042 for native protocol clients, and 7199 for JMX.

How many nodes does Cassandra cluster have?

As we said earlier, each instance of Cassandra has evolved to contain 256 virtual nodes. The Cassandra server runs core processes. For example, processes like spreading replicas around nodes or routing requests.

Which protocol is used by Cassandra to discover node state for all nodes in a cluster?

Cassandra uses a protocol called gossip to discover location and state information about the other nodes participating in a Cassandra cluster. Gossip is a peer-to-peer communication protocol in which nodes periodically exchange state information about themselves and about other nodes they know about.


2 Answers

After looking at the relevant source in the Cassandra network code, it is apparent that this is not supported. In the newSocket() method, the port for the remote node is obtained from the static DatabaseDescriptor.getSSLStoragePort() (excerpt below). This does not provide a different value per host or any hook to do so:

public Socket newSocket() throws IOException
{
    // zero means 'bind on any available port.'
    if (isEncryptedChannel())
    {
        return SSLFactory.getSocket(DatabaseDescriptor.getEncryptionOptions(), endPoint(), DatabaseDescriptor.getSSLStoragePort(), FBUtilities.getLocalAddress(), 0);
    }
    else {
        return new Socket(endPoint(), DatabaseDescriptor.getStoragePort(), FBUtilities.getLocalAddress(), 0);
    }
}
like image 123
Martin Serrano Avatar answered Oct 03 '22 19:10

Martin Serrano


take a look at https://github.com/pcmanus/ccm , they are using multipe cassandra instances on the same node. you can see how they are doing it.

like image 44
Rizwan Sharif Avatar answered Oct 03 '22 19:10

Rizwan Sharif