Readahead for /var/lib/mongo is set to 4096KB

9,136

It's probably /dev/sdb given the sizes you listed, but you can find out by running df -h. I keep my data in /data and here is my relevant output:

> df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1        70G   18G   49G  27% /
/dev/sdc1        932G  682G  250G  74% /data

In my case that means that the one I should be altering for readahead is /dev/sdc1. Figure out where you keep your data and then which block device that corresponds to, then set the readahead on that device. In my case:

sudo blockdev --setra 256 /dev/sdc

To persist through reboots you will need to add this command or similar to a boot script such as rc.local, or perhaps put it into your MongoDB init script to ensure it is set before the MongoDB process is launched (readahead is only read once by the process at start up, hence requires a process restart to affect a change).

Share:
9,136

Related videos on Youtube

pedrommuller
Author by

pedrommuller

Updated on September 18, 2022

Comments

  • pedrommuller
    pedrommuller almost 2 years

    I'm trying to set the readahead for mongo 256 or less as recommended, I looked at the documentation for any guidance and I found this:

    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 specific operating system manual for more information.

    when I do a sudo blockdev --report I get:

    rw  8192   512  4096          0     32212254720   /dev/sda
    rw  8192   512  4096       2048     31162630144   /dev/sda1
    rw  8192   512  4096   60866560      1048576000   /dev/sda2
    rw  8192   512  4096          0     75161927680   /dev/sdb
    rw  8192   512  4096       2048     75159830528   /dev/sdb1
    

    how do I know which is the one that is related to mongo?

  • Pavel
    Pavel over 6 years
    initscript not found. Please revise the link.