java 如何减少 cassandra 虚拟内存使用量?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26908159/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How reduce cassandra virtual memory usage?
提问by Cherry
Is there a settings in cassandra to reduce it memory usage? I understand that cassandra manages memory well, but for testing purposes I do not want to spent 6Gb memory only when cassandra service running on my windows mchine.
cassandra 中是否有设置可以减少内存使用?我知道 cassandra 可以很好地管理内存,但是出于测试目的,我不想仅在我的 Windows 机器上运行 cassandra 服务时才使用 6Gb 内存。
UPDATED
更新
I have tired setting disk_access_mode: standart
instead of disk_access_mode: auto
. It was not help. Also I pay attention that in cassandra 2.0.9 cassandra.yaml
file do not contains disk_access_mode
by default. So it seems (but I not sure) that disk_access_mode
was removed from cassandra.
我已经厌倦了设置disk_access_mode: standart
而不是disk_access_mode: auto
. 这没有帮助。另外我注意在 cassandra 2.0.9cassandra.yaml
文件中disk_access_mode
默认不包含。所以它似乎(但我不确定)disk_access_mode
已从 cassandra 中删除。
回答by Gyuri
As @catpaws points out the key is in the documentation at Tuning Java resourcesand cassandra-env.sh (on my mac I found it in /usr/local/etc/cassandra/cassandra-env.sh) but she falls short of answering the question.
正如@catpaws 指出的那样,关键在于Tuning Java resources和 cassandra-env.sh的文档中(在我的 Mac 上,我在 /usr/local/etc/cassandra/cassandra-env.sh 中找到了它)但她没有回答问题。
So here is what I did and what happened: I looked at my Activity Monitor and noticed the java (cassandra) memory usage being ~4GB. Then I read the docs and found that the ~4GB is around the same as the allocated heap using the formula
所以这就是我所做的和发生的事情:我查看了我的活动监视器并注意到 java (cassandra) 内存使用量为 ~4GB。然后我阅读了文档,发现 ~4GB 与使用公式分配的堆大致相同
max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB)
Then I edited cassandra-env.shwhere it says "Override these to set the amount..." and set
然后我编辑了cassandra-env.sh,它说“覆盖这些以设置数量......”并设置
MAX_HEAP_SIZE="2GB"
form the original 4GB. I also set
形成原来的4GB。我也设置
HEAP_NEWSIZE="400M"
HEAP_NEWSIZE="400M"
but that is not necessary to reduce the memory usage.
但这不是减少内存使用所必需的。
I restarted cassandra and checked the Activity Monitor. It said the Memory usage java (cassandra) was now only ~2GB.
我重新启动了 cassandra 并检查了活动监视器。它说内存使用 java (cassandra) 现在只有 ~2GB。
回答by catpaws
The conf/cassandra-env.sh file control environment settings for Cassandra. See comments in the file and docs: http://www.datastax.com/documentation/cassandra/2.1/cassandra/operations/ops_tune_jvm_c.html
conf/cassandra-env.sh 文件控制 Cassandra 的环境设置。请参阅文件和文档中的注释:http: //www.datastax.com/documentation/cassandra/2.1/cassandra/operations/ops_tune_jvm_c.html
回答by Jose Martinez Poblete
After some trial and error, we found disk_access_mode: mmap_index_only
provides the best results. Also helps to stay out of the Linux OOM killer radar
经过一些试验和错误,我们发现disk_access_mode: mmap_index_only
提供了最好的结果。也有助于远离 Linux OOM 杀手雷达