Reputation: 6364
How to set Cassandra (>2.0) JVM heap size of 8GB? When I type in free -m
it gives me the following. How can I set the Cassandra JVM heap size to 8GB?
total used free shared buffers cached
Mem: 16047 11336 4711 0 81 5814
-/+ buffers/cache: 5441 10606
Swap: 0 0 0
Upvotes: 6
Views: 16334
Reputation: 1069
Update cassandra-env.sh
remove / comment out the entire calculate_heap_sizes()
function
Remove/comment out other line with $MAX_HEAP_SIZE
.
The line starts with: "only calcuate the size if..."
delete / keep HEAP_NEWSIZE commented out
set MAX_HEAP_SIZE
to the new value. Ex: 16G
Restart
Also see for another example: https://medium.com/@mlowicki/move-cassandra-2-1-to-g1-garbage-collector-b9fb27365509
Upvotes: 3
Reputation: 57798
As stated in the Tuning Java resources section of the documentation:
If you decide to change the Java heap sizing, both MAX_HEAP_SIZE and HEAP_NEWSIZE should should be set together in conf/cassandra-env.sh.
Inside cassandra-env.sh, search for this line:
#MAX_HEAP_SIZE="4G"
That line in the code happens after the MAX_HEAP_SIZE calculations have happened, so it works as an override. Uncomment it, and set it accordingly.
MAX_HEAP_SIZE="8G"
Be careful going above 8G. For guidance on tuning the JVM, I recommend Amy Tobey's Cassandra 2.1 Tuning Guide. She offers some tips for tuning CMS, as well as a great section on implementing the new G1GC.
Upvotes: 7