Follow

How to "change the default Cassandra data store directory"

Question

How do I change the default Cassandra data store directory?

Summary

By default, the Cassandra data store directory is not defined and it writes to the default location (/var/lib/cassandra). In many instances, it is recommended that the data store directory is defined. This is because the default directory location is generally not sized accordingly to accommodate the Cassandra data. The data store directory can be changed at anytime, but it is preferable to defined it immediately after installation.

The steps below outlines the “How To” steps on how to define the Cassandra data store directory. The high-level steps are outlined below:

  • Step 1 - Create data store directory and modifying cassandra.yaml
  • Step 2 - Move Cassandra files, and start Cassandra
  • Step 3 - Restart Endpoint node components

Steps

NOTE: Please perform all the steps in sequence on a single Endpoint node before moving to the next node

Step 1 - Create data store directory and modifying elasticsearch.yml

  1. SSH to the ENDPOINT NODE(s) as the Interset User
  2. Create a new data store directory for Cassandra in a desired location, and it is sized appropriately to accommodate the Cassandra data. Below is an example command:
    • EXAMPLE: sudo mkdir /data/cassandra
  3. Under the new Cassandra directory, create the follow directories:
    • data
      • EXAMPLE: sudo mkdir /data/cassandra/data
    • commitlog
      • EXAMPLE: sudo mkdir /data/cassandra/commitlog
    • saved_caches
      • EXAMPLE: sudo mkdir /data/cassandra/saved_caches
  4. Ensure the new directories are set with the appropriate permissions for the Cassandra user and group. Below is example command:
    • EXAMPLE: sudo chown -R cassandra:cassandra /data/cassandra/
  5. Please type in the follow command to stop Cassandra:
    • For EL6
      • sudo service cassandra stop
    • For EL7
      • sudo systemctl stop cassandra
  6. Once Cassandra is stopped, type in the following command to edit the cassandra.yaml file:
    • sudo vi /etc/cassandra/conf/cassandra.yaml
  7. In the cassandra.yaml file, look for the following parameters:
    • data_file_directories
    • commitlog_directory
    • saved_caches_directory
  8. Change each the value for each parameter to the new Cassandra data store directory. Below is an example of the parameters and their corresponding values:
    • EXAMPLE: 
      • data_file_directories:
        • - /data/cassandra/data
      • commitlog_directory: /data/cassandra/commitlog
      • saved_caches_directory: /data/cassandra/saved_caches
  9. Once the values are updated for their respective parameters, save and exit the cassandra.yaml file.

Step 2 - Move Cassandra data and start Cassandra

  1. SSH to the ENDPOINT NODE(s) as the Interset User
  2. Type in the following commands to move the existing Cassandra data to the new Cassandra data store directory:
    • sudo mv /var/lib/cassandra/data/* <new_ES_data_store_path>/data/
    • sudo mv /var/lib/cassandra/commitlog/* <new_ES_data_store_path>/commitlog/
    • sudo mv /var/lib/cassandra/saved_caches/* <new_ES_data_store_path>/saved_caches/
  3. Once the Cassadra data is copied to the new data store directory, please ensure that the permission is set to Cassandra for user and group.
  4. Type in the following command to start Elasticsearch:
    • For EL6
      • sudo service cassandra start
    • For EL7
      • sudo systemctl start cassandra
  5. Type in the following command, and output parts of the Cassandra system.log file:
    • sudo tail -f /var/log/cassandra/system.log
  6. If Cassandra starts up properly, the last the several lines should be similar to the following:
    • INFO  [main] XXXX-XX-XX 12:34:52,377 Server.java:194 - Starting listening for CQL clients on <ENDPOINT_FQDN>/<IP_ADDRESS>:9042...
    • INFO  [main] XXXX-XX-XX 12:34:52,822 ThriftServer.java:119 - Binding thrift service to <ENDPOINT_FQDN>/<IP_ADDRESS>:9160
    • INFO  [Thread-2] XXXX-XX-XX 12:34:52,830 ThriftServer.java:136 - Listening for thrift clients...

Step 3 - Restart Endpoint node components

  1. SSH to the ENDPOINT NODE(s) as the Interset User
  2. Type in the following command to stop nginx:
    • For EL6
      • sudo server nginx stop
    • For EL7
      • sudo systemctl stop nginx
  3. Type in the following to stop endpoint:
    • sudo monit -g endpoint stop
      • NOTE: If monit does not stop properly, please locate, and kill the monit PID, then re-run step 3. Command listed below to locate the monit PID:
        • sudo ps -ef | grep monit
        • sudo kill -9 <monit_PID>
  4. Type in the following command to start endpoint:
    • sudo monit -g endpoint start
  5. Type in the following command to start nginx:
    • For EL6
      • sudo server nginx start
    • For EL7
      • sudo systemctl start nginx
  6. Once Endpoint and nginx is started, open up a web browser, go navigate to the Endpoint node webadmin URL:
  7. Log in to the Webadmin page with the admin credentials

Rinse and repeat Step 1, 2, and 3 on each Cassandra node.

Applies To

  • Cassandra 2.1.13
  • Interset 5.4.x, 5.5.x
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments