Limits MongoDB memory usage

Source: Internet
Author: User

Limits MongoDB memory usage

Because MongoDB's memory is managed by the system's virtual memory, MongoDB does not interfere with memory management. This can simplify Mongo's work, but the memory usage of Mongo cannot be controlled at the same time.
Is it really uncontrollable? You can useUlimitTo control the virtual address space of a user process.
Ulimit controls the memory size of all processes. How can we control MongoDB? In fact, it can be changed. We use a user in our own Linux to run MongoDB, and other programs run with other users. Because ulimit can restrict specified user resources.

Use ulimit-a to view all the resources that can be modified

118 ~ > Ulimit-A @ Root
-T:CPU
Time(Seconds) Unlimited

-F:FileSize (blocks) Unlimited

-D: Data seg size (Kbytes) Unlimited
-S: stack size (Kbytes) 8192
-C: Core File size (blocks) 0
-M: resIDEnt
SetSize (Kbytes) Unlimited

-U: Processes 1024.
-N: file descriptors 1024
-L: locked-in-memory size (Kb) 64
-V:DdRESS space (Kb) Unlimited

-X: File locks Unlimited
-I: Pending signaLs15661

-Q: bytes in posix msg queues 819200
-E: Max nice 0
-R: Max RT priority 0

Here we modify the ulimit-V: Address Space (Kb) option, that is, the maximum virtual address space of the user process.
We create a new user, CB, before launching mongod.
Ulimit-V 1000000: Change the maximum virtual address space to 1 GB.
Then run mongod port 10000 and execute the data insertion script.
Use the root user again. Do not modify ulimit any more. Enable another mongod port as 20000.

Port 1000 restricts the virtual address space. Port 2000 is unrestricted. The effect is obvious! Http://www.linuxso.com/linuxpeixun/14251.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.