content_image/690472.jpg
Kernel and File Systems When running MongoDB in production on Linux, it is recommended that you use Linux kernel version 2.6.36 or later. 

With the MMAPv1 storage engine, MongoDB preallocates its database files before using them and often creates large files. As such, you should use the XFS and EXT4 file systems. If possible, use XFS as it generally performs better with MongoDB. 

With the WiredTiger storage engine, use of XFS is strongly recommended to avoid performance issues found when using EXT4 with WiredTiger. 

• In general, if you use the XFS file system, use at least version 2.6.25 of the Linux Kernel. 

• In general, if you use the EXT4 file system, use at least version 2.6.23 of the Linux Kernel. 

• Some Linux distributions require different versions of the kernel to support using XFS and/or EXT4: 

<img src='content_image/690472.jpg'>

## fsync() on Directories 

Important: MongoDB requires a filesystem that supports fsync() on directories . For example, HGFS and Virtual Box’s shared folders do not support this operation. 

Recommended Configuration For the MMAPv1 storage engine and the WiredTiger storage engines, consider the following recommendations: 

• Turn off atime for the storage volume containing the database files . 

• Set the file descriptor limit, -n , and the user process limit (ulimit), -u , above 20,000, according to the sug- gestions in the ulimit (page 287) document. A low ulimit will affect MongoDB when under heavy use and can produce errors and lead to failed connections to MongoDB processes and loss of service. 

• Disable Transparent Huge Pages, as MongoDB performs better with normal (4096 bytes) virtual memory pages. See Transparent Huge Pages Settings (page 221). 

• Disable NUMA in your BIOS. If that is not possible, see MongoDB on NUMA Hardware (page 200). 

• Configure SELinux on Red Hat. For more information, see Configure SELinux for MongoDB (page 9) and Configure SELinux for MongoDB Enterprise (page 35). 

For the MMAPv1 storage engine: 

• Ensure that readahead settings for the block devices that store the database files are appropriate. For random access use patterns, set low readahead values. A readahead of 32 (16kb) often works well. 

For a standard block device, you can run sudo blockdev --report to get the readahead settings and sudo blockdev --setra <value> <device> to change the readahead settings. Refer to your spe- cific operating system manual for more information. 

For all MongoDB deployments: 

• Use the Network Time Protocol (NTP) to synchronize time among your hosts. This is especially important in sharded clusters. 

