MongoDB 使用过多内存

发布于 2025-01-02 15:06:17 字数 212 浏览 3 评论 0原文

我正在 32 位 CentOS VPS 上使用 MongoDB,内存为 1GB。 大多数时候它工作正常,但时不时内存使用量会激增并使我的服务器崩溃。

有没有办法防止这种情况发生,例如,通过限制 MongoDB 守护进程使用的内存和 CPU?

我正在考虑使用 ionice 运行 Mongo 守护进程并给它一个低优先级,但我不确定这是否可行。

欢迎任何帮助或指点!

I'm working with MongoDB on a 32bits CentOS VPS with 1GB of internal memory.
It works fine most of the time, but every now and then it's memory usage spikes and crashes my server.

Is there a way to prevent this, for example, by limiting the memory and CPU that MongoDB daemon uses?

I was thinking of running the Mongo daemon with ionice and giving it a low priority, but I'm not sure if that would work.

Any help or pointers are welcome!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吃→可爱长大的 2025-01-09 15:06:18

我猜您还在同一台服务器上运行其他所有内容?

实际上,运行 mongo 的最佳方法是将其放在自己的服务器上,这样 apache、mysql 等就不会跳起来并干扰它想要使用的 RAM。我自己也遇到了同样的问题——在大量使用的情况下,服务器每隔一段时间就会进入交换状态并自我阻塞。

您可能会更好地使用两台 512MB 服务器,希望它们的价格具有可比性(一台运行 mongo,一台运行其余的)。我还考虑过尝试在 VPS 中运行带有 mongo 的虚拟机,但这对我来说属于“太多努力”类别。

是的,正如 dcrosta 所说,使用 64 位,除非您想将数据大小限制在 2GB 以下(为什么要这样做?)

I'm guessing you're also running everything else on that same server?

Really, the best way to run mongo is to put it on its own server, where things like apache, mysql, etc. won't jump up and interfere with the RAM it wants to use. I had the same problem myself--the server would go into swap and choke itself every once in a while, with heavy use.

You'd probably be better off with two 512MB servers which is hopefully comparable in price (one running mongo, and one running the rest). I also thought about trying to run a VM with mongo on it within the VPS, but that fell into the "too much effort" category, for me.

And yeah, as dcrosta says, use 64-bit, unless you want to limit your data size to under 2GB (and why would you want to do that?)

你在看孤独的风景 2025-01-09 15:06:18

当我使用大量的map/reduce时,我确实遇到了类似的问题,内存泄漏和崩溃经常发生。我不再使用map/reduce,并且已经好几个月没有出现内存泄漏/崩溃了。

I did have similar problems, when I was using lots of map/reduce where the memory leaks and crashes were often. I don't use map/reduce anymore and there have been no memory leaks / crashes for many months now.

浅忆流年 2025-01-09 15:06:17

目前无法限制内存量。 MongoDB 使用内存映射文件机制来访问数据文件。因此,所使用的内存量由系统控制。您接触的数据越多,需要的 RAM 就越多。

It is not currently possible to limit amount of memory. MongoDB uses memory-mapped file mechanism to access data files. Therefore, amount of used memory is governed by the system. The more data you touch, the more RAM you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文