API Management

Setting up Cassandra Cluster

To avoid a single point of failure, Cassandra server can be run on each server machine (AMS and AGS), thereby Cassandra servers acting as a cluster.

To set up the Cassandra cluster, perform the following actions:

  1. Open Cassandra.yaml file and specify the below:

    1. cluster_name: Give a name for the cluster.

      All nodes must use the same cluster name.

    2. seeds: Mention the IP address of each node in the cluster, separated by commas. 

      Example

      192.168.1.73,192.168.1.74

    3. listen_address: This is the IP address that other nodes in the cluster will use to connect. By default, the value will be "localhost" which canneeds to be changed to the IP address of the node.

      Example

      listen_address: 192.168.1.74

    4. rpc_address: This is the IP address for remote procedure calls. The default value is "localhost". If the server's hostname is properly configured, leave this as is. It can be replaced with the server's IP address or the loopback address (127.0.0.1).

      Example

      rpc_address: 192.168.1.74

    5. endpoint_snitch: Set the value to "GossipingPropertyFileSnitch".

      endpoint_snitch: GossipingPropertyFileSnitch

  2. Open the cassandra-rackdc.properties file and specify the Data Center and Rack names:

    Example

    dc=dc1
    rack=rack1 

  3. Open the cassandra-topology.properties file.
    Under the Cassandra Node IP address, specify the IP address of the node to the respective Rack and Data center.

    Example

    192.168.1.73=DC1:RAC1
    192.168.1.74=DC1:RAC1

  4. Start the Cassandra server on every node in the cluster using the command below:

    sudo service cassandra start
    
  5. Set Replication Factor using the command below:

    If Cassandra servers are running on the same Data Center

     cqlsh> ALTER KEYSPACE api WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'dc1' : 2 };
    

    If Cassandra servers are running on a different Data Center

     cqlsh> ALTER KEYSPACE api WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2};
    

    The replication factor should be set on each node and must be equal to the number of Cassandra servers running.

  6. After Replication factor is set, run the nodetool repair command below in every node in the cluster:

    cqlsh> nodetool repair
    
  7. By this, the cluster setup must be ready. To check the status of a particular node, run the nodetool status command below:

    cqlsh> nodetool status api
    

If Cassandra server is running, stop the server and clear the data:

 

  1. Stop Cassandra:

    sudo service cassandra stop
    
  2. Clear the data:

    sudo rm -rf CASSANDRA_LOCATION/data/system/*