简体   繁体   English

如何减少cassandra虚拟内存的使用?

[英]How reduce cassandra virtual memory usage?

Is there a settings in cassandra to reduce it memory usage? cassandra中是否有设置以减少内存使用量? 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很好地管理内存,但出于测试目的,我不想只在我的Windows机器上运行cassandra服务时花费6Gb内存。

UPDATED 更新

I have tired setting disk_access_mode: standart instead of disk_access_mode: auto . 我已经厌倦了设置disk_access_mode: standart disk_access_mode: auto而不是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. 另外我要注意,在cassandra 2.0.9中, cassandra.yaml文件默认不包含disk_access_mode So it seems (but I not sure) that disk_access_mode was removed from cassandra. 所以似乎(但我不确定) disk_access_mode已从cassandra中删除。

As @catpaws points out the key is in the documentation at Tuning Java resources and 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资源和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. 所以这就是我做了什么以及发生了什么:我查看了我的Activity Monitor,发现java(cassandra)的内存使用量约为4GB。 Then I read the docs and found that the ~4GB is around the same as the allocated heap using the formula 然后我阅读了文档,发现~4GB与使用公式的分配堆大致相同

max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB)

Then I edited cassandra-env.sh where it says "Override these to set the amount..." and set 然后我编辑了cassandra-env.sh ,其中显示“覆盖这些以设置数量......”并设置

MAX_HEAP_SIZE="2GB"

form the original 4GB. 形成原始的4GB。 I also set 我也定了

HEAP_NEWSIZE="400M" HEAP_NEWSIZE = “400M”

but that is not necessary to reduce the memory usage. 但这不是减少内存使用量所必需的。

I restarted cassandra and checked the Activity Monitor. 我重新启动了cassandra并检查了Activity Monitor。 It said the Memory usage java (cassandra) was now only ~2GB. 它说内存使用java(cassandra)现在只有~2GB。

The conf/cassandra-env.sh file control environment settings for Cassandra. cassandra的conf / cassandra-env.sh文件控制环境设置。 See comments in the file and docs: http://www.datastax.com/documentation/cassandra/2.1/cassandra/operations/ops_tune_jvm_c.html 请参阅文件和文档中的注释: http//www.datastax.com/documentation/cassandra/2.1/cassandra/operations/ops_tune_jvm_c.html

After some trial and error, we found disk_access_mode: mmap_index_only provides the best results. 经过一些试验和错误,我们发现disk_access_mode: mmap_index_only提供了最好的结果。 Also helps to stay out of the Linux OOM killer radar 还有助于避开Linux OOM杀手级雷达

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM