Hi,

yes I was looking for this config as well.

This is really simple to achieve:

Put the following line into /etc/security/limits.conf

cassandra        -       memlock         32

Then, start Cassandra as the user cassandra, not as root (note there is never a need to run Cassandra as root, all functionality can be achieved from a normal user by changing the right configs).

In the log you will see:

[2011-07-29 13:06:46,491] WARN: Unable to lock JVM memory (ENOMEM). This can result in part of the JVM being swapped out, especially with mmapped I/O enabled. Increase RLIMIT_MEMLOCK or run Cassandra as root. (main CLibrary.java:118)

Done.

If you want enable mlockall again, simply change the above 32(k) value to the size of your RAM (e.g. 17825792 for a 16GB machine).

We also have turned off mmap altogether and never had any memory issues again. swap is happily enabled. We currently prefer stability over performance.

Cheers,

        T.

On 28/07/11 22:17, Stephen Henderson wrote:
Hi,

We’ve started having problems with cassandra and memory swapping on linux which
seems to be a fairly common issue (in our particular case after about a week
all swap space will have been used up and we have to restart the process).

It sounds like the general consensus is to just disable swap completely, but
the recently released “Cassandra High Performance Cookbook” from Packt has
instructions for “Stopping cassandra from using swap without disabling it
system wide”. We’ve tried following the instructions but it refers to a
“memory_locking_policy” variable in cassandra.yaml which throws an “unknown
property” error on startup and I can’t find any reference to it in any of the
cassandra docs.

I’ve copied the summarised instructions below, does anyone know if this is
something that ever worked or is there a different variable to set which does
the same thing? (we’re using 0.7.4 at present and it looks like the book was
written for 0.7.0-beta-1.10 so it might have been something which was abandoned
during beta?)

---

Disabling Swap Memory system-wide may not always be desirable. For example, if
the system is not dedicated to running Cassandra, other processes on the system
may benefit from Swap Memory. This recipe shows how to install the Java Native
Architecture, which allows Java to lock itself in memory making it inevitable.

1. Place the jna.jar and platform.jar in the $CASSANDRA_HOME/lib directory:

2. Enable memory_locking_policy in $CASSANDRA_HOME/conf/cassandra.yaml:
“memory_locking_policy: required”

3. Restart your Cassandra instance.

4. Confirm this configuration has taken effect by checking to see if a large
portion of memory is Unevictable:

$ grep Unevictable /proc/meminfo

Unevictable: 1024 Kb

---

Thanks,

Stephen

*Stephen Henderson – *Lead Developer (Onsite), Cognitive Match

stephen.hender...@cognitivematch.com
<mailto:stephen.hender...@cognitivematch.com> | http://www.cognitivematch.com
<http://www.cognitivematch.com/>

T: +44 (0) 203 205 0004 | F: +44 (0) 207 526 2226


Reply via email to