There is a lot of organisations out there that require the /tmp directory be mounted with the noexec flag.  It is mounted in this way to prevent executables from running in /tmp. This is an issue for Cassandra as when /tmp is non-executable, the Cassandra database fails to start with the following error:

java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native
        at org.apache.cassandra.utils.memory.MemoryUtil.allocate( ~[apache-cassandra-2.2.2.jar:2.2.2]
        at<init>( ~[apache-cassandra-2.2.2.jar:2.2.2]

JNA is not able to start if the temp file system is restricted like this.

There are a few ways around this issue
1. Make the /tmp mount point an executable mount.
2. Give Cassandra a new location for the temp files from JNA.

We will proceed with option 2 as its less invasive, we can leave /tmp alone and all the while not hassle the very busy server IT team.

Step 1

Create a new /temp directory in a location of your choosing:

mkdir /home/cassandra/tmp

Step 2

Locate your file.  Usually at $CASSANDRA_HOME/conf/

Step 3

Edit this file and add the following:

JVM_OPTS="$JVM_OPTS -Djna.tmpdir=/home/cassandra/tmp"

Step 4

Restart Cassandra and you should have no more issues. Keep an eye on the log for errors.


Please enter your comment!
Please enter your name here