This documentation is for older WSO2 products. View documentation for the latest release.
Clustering Cassandra with One Host - Clustering Guide 4.2.0 - WSO2 Documentation
||
Skip to end of metadata
Go to start of metadata

Cassandra cluster design does not allow you to run two nodes in a single host (machine). However, there are alternative methods to simulate two hosts in a single machine by adding virtual ethernet devices to the host on which we plan to run the Cassandra cluster.

This setup includes two virtual ethernet devices on the default ethernet device (e.g., eth0). Since we run two Carbon servers in one machine, some ports may try to bind with the default device and this results in port conflicts. Therefore we are going to offset one WSO2 SS instance by 10.

Users can configure the <PRODUCT_HOME>/repository/conf/carbon.xml file or the -Doffset option to offset a Carbon server. When offsetting takes place, all the nodes are shifted by the offset. It is necessary to set the Cassandra storage port (cluster port) into a common value (7000). Cassandra related port’s base values can be set via system variables as explained in this tutorial.

  1. Create two IP aliases:

    ifconfig eth0:1 192.168.0.2
    ifconfig eth0:2 192.168.0.3
  2. Configure cassandra.yaml in node 0 and node 1.
    1. In node 0:

      - seeds: "192.168.0.2"
      
      listen_address: 192.168.0.2
      
      rpc_address: 192.168.0.2
    2. In node 1:

      - seeds: "192.168.0.2"
      
      listen_address: 192.168.0.3
      
      rpc_address: 192.168.0.3
  3. Update the <PRODUCT_HOME>/repository/conf/etc/hector-config.xml in node 0.

    <HectorConfiguration>
        <Cluster>
            <Name>ClusterOne</Name>
            <Nodes>192.168.0.2:9160</Nodes>
            <AutoDiscovery disable="false" delay="1000"/>
        </Cluster>
    </HectorConfiguration>
  4. Update the <PRODUCT_HOME>/repository/conf/etc/hector-config.xml in node 1.

    <HectorConfiguration>
        <Cluster>
            <Name>ClusterOne</Name>
            <Nodes>192.168.0.3:9160</Nodes>
            <AutoDiscovery disable="false" delay="1000"/>
        </Cluster>
    </HectorConfiguration>
  5. Start the cluster.
    • Node 0 configurations: Use the --start command to start node 0.

      $PRODUCT_HOME/bin/wso2server.sh --start
    • Node 1 configurations:
      1. Update the <PRODUCT_HOME>/bin/wso2server.sh file as follows:

        -Dcassandra.rpc.port=9150 \
        -Dcassandra.storage.port=6990 \
      2. Use the --start command to start node 1.

        $PRODUCT_HOME/bin/wso2server.sh --start
  6. You can verify the status of the cluster using a notetool command.

    ./nodetool -u admin -pw admin -p 9999 ring -h 192.168.0.2
    ./nodetool -u admin -pw admin -p 10009 ring -h 192.168.0.3

    Also you can check the listening port using a netstat command.

    netstat -anl |grep 7000
    tcp6       0      0 192.168.0.3:7000        :::*                    LISTEN     
    tcp6       0      0 192.168.0.2:7000        :::*                    LISTEN
    netstat -anl |grep 9160
    tcp6       0      0 192.168.0.3:9160        :::*                    LISTEN     
    tcp6       0      0 192.168.0.2:9160        :::*                    LISTEN 
  7. You can now connect to the cluster using the cassandra-cli tool.

    ./cassandra-cli -u admin -pw admin -h 192.168.0.2
    
    ./cassandra-cli -u admin -pw admin -h 192.168.0.3
  • No labels