Perform essential Cassandra operations

Tip   A new guide is available in the latest release of API Gateway that includes information on Apache Cassandra best practices and tuning, setting up high availability, and backup and restore. Much of the information in this guide also applies to API Gateway 7.5.3. See the API Gateway 7.6.2 Apache Cassandra Administrator Guide.

This section describes the minimum essential operations that are required to maintain a healthy Cassandra HA cluster.

Perform anti-entropy repair

Cassandra is inherently HA, so when a node is absent from a cluster for a time, it can be brought back into the cluster and becomes eventually consistent by design. Node repair is required after reintegration into the cluster.

The nodetool repair command repairs inconsistencies across all Cassandra replica nodes for a given range of data. Most importantly, it ensures that deleted data remains deleted in a distributed system. You should execute this command at least weekly, at off-peak times, and stagger execution on different nodes.

For example, the following crontab commands execute nodetool repair on specified schedules in test and production environments:

# Every 10 mins. NB: TEST ONLY, not for production.
$ crontab
*/10 * * * * /home/cassandra/bin/nodetool repair >> /home/cassandra/logs/repair.log

# Every week at 3am on a Sunday
$ crontab
0 2 * 0 /home/cassandra/bin/nodetool repair >> /home/cassandra/logs/repair.log

On Windows, you can use Windows Task Scheduler.

Note   If a node is down for more than 10 days, it must not join the existing cluster. It should be replaced instead. See Replace dead nodes.

For more details on nodetool repair, see Manual repair: Anti-entropy repair documentation.

Replace dead nodes

If a node is down for more than 10 days, it should be replaced. For details on replacing dead Cassandra nodes, see Replacing a dead node or dead seed node documentation.

Back up and restore Cassandra data

To backup and restore Cassandra data (online and HA), follow the instructions on Backing up and restoring data documentation.

Back up configuration and data for disaster recovery

You must back up the following API Gateway and Cassandra configuration and data for disaster recovery:

  • API Gateway group configuration data
  • Back up the API Gateway group configuration data in apigateway/groups/<group-name>/conf. This contains the API Gateway, API Manager and KPS configuration data. Ensure that you back up these important files.
  • API Gateway KPS data
  • Ensure that you back up KPS data regularly on all nodes using the kpsadmin tool. This backs up API Manager and customer KPS data to simple, portable JSON files. These are also independent of Cassandra and Cassandra versions. For more details, see the API Gateway Key Property Store User Guide.
  • Cassandra configuration
  • Ensure that you back up the CASSANDRA_HOME/conf directory on all nodes.
  • Cassandra data
  • With Cassandra, any node in the system can act as a live backup when replacing a dead node. Data can be restored without affecting availability using Cassandra HA backup and restore. However, it still makes sense to make a regular hard file system backup of the data on all nodes for disaster recovery use cases. Cassandra data resides in CASSANDRA_HOME/data. You should back up this directory on all nodes.
Note   You must stop the Cassandra server before taking a file system backup. This ensures that files are not locked and that all data is flushed to disk. For details, see Install an Apache Cassandra database.

Ensure time is in sync across the Cassandra cluster

You should use a time service such as NTP to ensure that time is in sync in the cluster. For example, OAuth Tokens are removed by Cassandra when expired, based upon the time-to-live value set when created. If Cassandra nodes run on servers that are not synchronized, the tokens are removed at different times, and the data is no longer fully synchronized.

Note   You must ensure that the NTP server is on a physical machine, and not a virtual machine, in the datacenter.

For more details, see

Reconfigure an existing Cassandra installation from scratch

There is no need to reinstall Cassandra from scratch. You can just move Cassandra data files and restore the cassandra.yaml configuration file if necessary. Preform the following steps:

  1. Stop Cassandra. For details, see Install an Apache Cassandra database.
  3. Restore cassandra.yaml in CASSANDRA_HOME/conf if necessary.

Enable Cassandra debug logging

You can enable Cassandra debug logging using any of the following approaches:

  • logback.xml
  • You can specify a logger in the cassandra/conf/logback.xml configuration file as follows:

<logger name "org.apache.cassandra.transport" level=DEBUG/>"

  • nodetool
  • You can use the nodetool setlogginglevel command as follows:

nodetool setlogginglevel org.apache.cassandra.transport DEBUG

  • JConsole
  • The JConsole tool enables you to configure Cassandra logging using JMX. For example, you can invoke setLoggingLevel and specify org.apache.cassandra.db.StorageServiceMBean and DEBUG as parameters. For more details, see the next section.

For more details on enabling logging, see the following, which also applies to Cassandra 2.2:

Monitor a Cassandra cluster using JMX

You can use Java Management Extensions to monitor and manage performance in a Cassandra cluster. For details, see Monitoring a Cassandra cluster documentation.

Upgrade your Cassandra version

For details on upgrading your Cassandra version, see Supported Cassandra versions.

Further details

For more details on Cassandra operations, see Apache Cassandra 2.2 documentation

Related Links