How to solve ConfigurationException: Missing required directive CommitLogSync while configuring a multi node Cassandra cluster on Centos7

cassandracentos7

Aim: to configure a multi node Cassandra cluster on Centos7


Method

This documentation is used to configure a multi node Cassandra cluster.

[user@cassandra01 ~]$ cat /etc/cassandra/conf/cassandra.yaml
cluster_name: 'MyCassandraCluster'
num_tokens: 256
seed_provider:
  - class_name: org.apache.cassandra.locator.SimpleSeedProvider
    parameters:
      - seeds: "<ipaddress_cassandra01>,<ipaddress_cassandra02>"
listen_address:
rpc_address: 0.0.0.0
endpoint_snitch: GossipingPropertyFileSnitch

Problem

When the first Cassandra node has been started by issuing:

sudo systemctl start cassandra

the node does not seem to start and the /var/log/cassandra/cassandra.log indicates that:

 INFO 12:56:38,057 Loading settings from file:/etc/cassandra/default.conf/cassandra.yaml
 INFO 12:56:40,073 Data files directories: null
 INFO 12:56:40,089 Commit log directory: null
ERROR 12:56:40,097 Fatal configuration error
org.apache.cassandra.exceptions.ConfigurationException: Missing required directive CommitLogSync
        at org.apache.cassandra.config.DatabaseDescriptor.applyConfig(DatabaseDescriptor.java:148)
        at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:112)
        at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:213)
        at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:554)
        at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:643)
Missing required directive CommitLogSync
Fatal configuration error; unable to start. See log for stacktrace.

Attempt to solve the issue

According the error message it looks like that there is a configuration issue or certain directories do not exist.

1) Missing required directive CommitLogSync:

According this documentation there is a default commitlog_sync, i.e.:

commitlog_sync
(Default: periodic ) The method that Cassandra uses to acknowledge writes in milliseconds:

    periodic : Used with commitlog_sync_period_in_ms (Default: 10000 - 10 seconds ) to control how often the commit log is

synchronized to disk. Periodic syncs are acknowledged immediately.
batch : Used with commitlog_sync_batch_window_in_ms (Default: disabled **) to control how long Cassandra waits for other writes
before performing a sync. When using this method, writes are not
acknowledged until fsynced to disk.

2) Data files directories: null:

data_file_directories
(Default: /var/lib/cassandra/data ) The directory location where table data (SSTables) is stored.

Issuing ls /var/lib/cassandra/data returns a 0 and indicates that the directory exists.

3) Commit log directory: null:

commitlog_directory
(Default: /var/lib/cassandra/commitlog ) The directory where the commit log is stored. For optimal write performance, it is recommended
the commit log be on a separate disk partition (ideally, a separate
physical device) from the data file directories.

Confirmed that the /var/lib/cassandra/commitlog directory exists as well.


Question

What is causing this issue and how to solve it?

Best Answer

Although the documentation indicates that there are default settings, the software itself requires that these are defined in the cassandra.yaml. Defining the following in /etc/cassandra/conf/cassandra.yaml:

data_file_directories:
  - /var/lib/cassandra/data
commitlog_directory: /var/lib/cassandra/commitlog
saved_caches_directory: /var/lib/cassandra/saved_caches

and restarting cassandra solved the issue.