Cassandra Installation

  1. Install Cassandra packages

    # yum install java-1.8.0-openjdk-headless
    # yum install dsc22
  2. Configure Cassandra

    1. Common Configuration

      Edit the /etc/cassandra/conf/cassandra.yaml file to contain the following:

      # The name of the cluster.
      cluster_name: 'midonet'
      
      ...
      
      # Addresses of hosts that are deemed contact points.
      seed_provider:
          - class_name: org.apache.cassandra.locator.SimpleSeedProvider
            parameters:
                - seeds: "nsdb1,nsdb2,nsdb3"
    2. Node-specific Configuration

      1. NSDB Node 1

        Edit the /etc/cassandra/conf/cassandra.yaml file to contain the following:

        # Address to bind to and tell other Cassandra nodes to connect to.
        listen_address: nsdb1
        
        ...
        
        # The address to bind the Thrift RPC service.
        rpc_address: nsdb1
      2. NSDB Node 2

        Edit the /etc/cassandra/conf/cassandra.yaml file to contain the following:

        # Address to bind to and tell other Cassandra nodes to connect to.
        listen_address: nsdb2
        
        ...
        
        # The address to bind the Thrift RPC service.
        rpc_address: nsdb2
      3. NSDB Node 3

        Edit the /etc/cassandra/conf/cassandra.yaml file to contain the following:

        # Address to bind to and tell other Cassandra nodes to connect to.
        listen_address: nsdb3
        
        ...
        
        # The address to bind the Thrift RPC service.
        rpc_address: nsdb3
  3. Edit the service’s init script

    On installation, the /var/run/cassandra directory is created, but because it is located on a temporary file system it will be lost after system reboot. As a result it is not possible to stop or restart the Cassandra service anymore.

    To avoid this, edit the /etc/init.d/cassandra file to create the directory on service start:

    [...]
    case "$1" in
        start)
            # Cassandra startup
            echo -n "Starting Cassandra: "
            mkdir -p /var/run/cassandra
            chown cassandra:cassandra /var/run/cassandra
            su $CASSANDRA_OWNR -c "$CASSANDRA_PROG -p $pid_file" > $log_file 2>&1
            retval=$?
    [...]
  4. Enable and start Cassandra

    # systemctl enable cassandra.service
    # systemctl start cassandra.service
  5. Verify Cassandra Operation

    After installation of all nodes has been completed, verify that Cassandra is operating properly.

    [Important]Important

    If Cassandra fails to start and prints a "buffer overflow" error message in its log file, you may try associating 127.0.0.1 with the hostname in etc/hosts (so that hostname -i will show 127.0.0.1). This may solve the Cassandra start problem.

    A basic check can be done by executing the nodetool status command. This will reply with UN (Up / Normal) in the first column if the servers are running in a non-error state:

    $ nodetool --host 127.0.0.1 status
    [...]
    Status=Up/Down
    |/ State=Normal/Leaving/Joining/Moving
    --  Address    Load       Tokens  Owns   Host ID                               Rack
    UN  192.0.2.1  123.45 KB  256     33.3%  11111111-2222-3333-4444-555555555555  rack1
    UN  192.0.2.2  234.56 KB  256     33.3%  22222222-3333-4444-5555-666666666666  rack1
    UN  192.0.2.3  345.67 KB  256     33.4%  33333333-4444-5555-6666-777777777777  rack1
Questions? Discuss on Mailing Lists or Chat.
Found an error? Report a bug.