How to set Cassandra (>2.0) JVM heap size of 8GB?

 ̄綄美尐妖づ 提交于 2020-01-14 10:46:34

问题


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

回答1:


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.




回答2:


Update cassandra-env.sh

remove / comment out the entire calculate_heap_sizes() function

  • this is the function that is called by cassandra to automatically allocate JVM size.
  • it takes the lower of 1/4 system memory or 8GB. This is why the default max JVM size is 8GB

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

  • this should be the only place you need to do this

Restart

  • Ideally, you'd only need to restart the Cassandra service. However, I've only gotten it to work after restarting the entire machine.

Also see for another example: https://medium.com/@mlowicki/move-cassandra-2-1-to-g1-garbage-collector-b9fb27365509



来源:https://stackoverflow.com/questions/34745419/how-to-set-cassandra-2-0-jvm-heap-size-of-8gb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!