cassandra启动时报内存不足处理

一、问题描述

这是之前遇到的问题,这里把它记下来。在启动cassandra时,报错,输出:

Java HotSpot(TM) 64-Bit Server VM warning: MaxNewSize (204800k) is equal to or greater than the entire heap (204800k).  A new max generation size of 204736k will be used

二、问题分析
错误很明显,jvm中,young generation(新生代)配置使用的最大内存(MaxNewSize)大于或等于了 jvm整个堆大小。
需要调高jvm堆的大小或者调低MaxNewSize大小。
再查看cassandra中关于内存的配置,位于cassandra安装目录下的conf/jvm.options:

#################
# HEAP SETTINGS #
#################

# Heap size is automatically calculated by cassandra-env based on this
# formula: max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB))
# That is:
# - calculate 1/2 ram and cap to 1024MB
# - calculate 1/4 ram and cap to 8192MB
# - pick the max
#
# For production use you may wish to adjust this for your environment.
# If that's the case, uncomment the -Xmx and Xms options below to override the
# automatic calculation of JVM heap memory.
#
# It is recommended to set min (-Xms) and max (-Xmx) heap sizes to
# the same value to avoid stop-the-world GC pauses during resize, and
# so that we can lock the heap in memory on startup to prevent any
# of it from being swapped out.
#-Xms4G
#-Xmx4G

# Young generation size is automatically calculated by cassandra-env
# based on this formula: min(100 * num_cores, 1/4 * heap size)
#
# The main trade-off for the young generation is that the larger it
# is, the longer GC pause times will be. The shorter it is, the more
# expensive GC will be (usually).
#
# It is not recommended to set the young generation size if using the
# G1 GC, since that will override the target pause-time goal.
# More info: http://www.oracle.com/technetwork/articles/java/g1gc-1984535.html
#
# The example below assumes a modern 8-core+ machine for decent
# times. If in doubt, and if you do not particularly want to tweak, go
# 100 MB per physical CPU core.
#-Xmn800M

可以发现cassandra的jvm内存默认是自动计算的。

三、问题解决

原因清晰了,问题就好解决了。将jvm内存配置从自动改为自己设置。

进入cassandra根目录

修改conf/jvm.options文件, 即:vim conf/jvm.options
#调低堆的初始值和最大值:
-Xms200m
-Xmx200m


————————————————
版权声明:本文为CSDN博主「panda-star」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/chinabestchina/article/details/97176131