Josh Elias
Josh Elias

Reputation: 3290

MongoDB Readahead warning

I'm receiving this warning when starting my MongoDB shell:

Wed Mar 20 22:40:49.850 [initandlisten]

Wed Mar 20 22:40:49.850 [initandlisten] ** WARNING: Readahead for /data is set to 2048KB

Wed Mar 20 22:40:49.850 [initandlisten] ** We suggest setting it to 256KB (512 sectors) or less

Wed Mar 20 22:40:49.850 [initandlisten] ** http://dochub.mongodb.org/core/readahead

I've used:

df /data

To find where the drive is that my data is mounted and subsequently used:

sudo blockdev --setra 256 /dev/mapper/vg0-data

to set the readahead to the 256 that was specified. I've confirmed this has worked with:

sudo blockdev --getra /dev/mapper/vg0-data

I'm still however getting the same error when starting my shell?

UPDATE

I've restarted the mongodb server instance and am still receiving this error.

UPDATE 2

My linux server is hosted on AWS and therefore uses virtual volumes. I have set the readahead value for all those volumes to 256 and still receive this error.

UPDATE 3

This is a blockdev --report of the Primary instance of MongoDB

RO    RA   SSZ   BSZ   StartSec            Size   Device
rw   256   512  4096          0      8589934592   /dev/xvda1
rw   256   512  4096          0     10737418240   /dev/xvdh8
rw   256   512  4096          0     10737418240   /dev/xvdh7
rw   256   512  4096          0     10737418240   /dev/xvdh6
rw   256   512  4096          0     10737418240   /dev/xvdh5
rw   256   512  4096          0     10737418240   /dev/xvdh4
rw   256   512  4096          0     10737418240   /dev/xvdh3
rw   256   512  4096          0     10737418240   /dev/xvdh2
rw   256   512  4096          0     10737418240   /dev/xvdh1
rw  4096   512  4096          0     42944430080   /dev/md127
rw  4096   512  4096          0     38646317056   /dev/dm-0
rw  4096   512  4096          0      2143289344   /dev/dm-1
rw  4096   512  4096          0      2143289344   /dev/dm-2

This is a blockdev --report of the Secondary instance of MongoDB

RO    RA   SSZ   BSZ   StartSec            Size   Device
rw   256   512  4096          0      8589934592   /dev/xvda1
rw   256   512  4096          0     10737418240   /dev/xvdh8
rw   256   512  4096          0     10737418240   /dev/xvdh7
rw   256   512  4096          0     10737418240   /dev/xvdh6
rw   256   512  4096          0     10737418240   /dev/xvdh5
rw   256   512  4096          0     10737418240   /dev/xvdh4
rw   256   512  4096          0     10737418240   /dev/xvdh3
rw   256   512  4096          0     10737418240   /dev/xvdh2
rw   256   512  4096          0     10737418240   /dev/xvdh1
rw  4096   512  4096          0     42944430080   /dev/md127
rw  4096   512  4096          0     38646317056   /dev/dm-0
rw  4096   512  4096          0      2143289344   /dev/dm-1
rw  4096   512  4096          0      2143289344   /dev/dm-2

This is a blockdev --report of the Arbiter instance of MongoDB

RO    RA   SSZ   BSZ   StartSec            Size   Device
rw   256   512  4096          0      8589934592   /dev/xvda1

Upvotes: 10

Views: 16731

Answers (5)

Mark V
Mark V

Reputation: 195

Ive written an init script to set/unset this for me:

readahead initscript

Upvotes: -1

Johnny Cage
Johnny Cage

Reputation: 6380

modify readahead value inside to 128 on /usr/lib/tuned/throughput-performance/tuned.conf

on centos7

Upvotes: 4

DmitrySemenov
DmitrySemenov

Reputation: 10345

You can do this:

echo 'ACTION=="add", KERNEL=="xvdb", ATTR{bdi/read_ahead_kb}="64"' | sudo tee -a /etc/udev/rules.d/85-ebs.rules
echo 'ACTION=="add", KERNEL=="xvdc", ATTR{bdi/read_ahead_kb}="64"' | sudo tee -a  /etc/udev/rules.d/85-ebs.rules
echo 'ACTION=="add", KERNEL=="xvdd", ATTR{bdi/read_ahead_kb}="64"' | sudo tee -a /etc/udev/rules.d/85-ebs.rules
echo 'ACTION=="add", KERNEL=="xvde", ATTR{bdi/read_ahead_kb}="64"' | sudo tee -a   /etc/udev/rules.d/85-ebs.rules
echo 'ACTION=="add", KERNEL=="dm-0", ATTR{bdi/read_ahead_kb}="64"' | sudo tee -a /etc/udev/rules.d/85-ebs.rules
echo 'ACTION=="add", KERNEL=="dm-1", ATTR{bdi/read_ahead_kb}="64"' | sudo tee -a /etc/udev/rules.d/85-ebs.rules
echo 'ACTION=="add", KERNEL=="dm-2", ATTR{bdi/read_ahead_kb}="64"' | sudo tee -a /etc/udev/rules.d/85-ebs.rules
echo 'ACTION=="add", KERNEL=="md127", ATTR{bdi/read_ahead_kb}="64"' | sudo tee -a /etc/udev/rules.d/85-ebs.rules

where KERNEL=="" is your HDD device

then on restart everything will be set properly

rw   256   512  4096          0     42949672960   /dev/xvda1
rw   128   512  4096          0    214748364800   /dev/xvdc
rw   128   512  4096          0    214748364800   /dev/xvde
rw   128   512  4096          0    214748364800   /dev/xvdd
rw   128   512  4096          0    214748364800   /dev/xvdb
rw   128   512  4096          0    429227769856   /dev/md127
rw   128   512  4096          0    343379279872   /dev/dm-0
rw   128   512  4096          0     42920312832   /dev/dm-1
rw   128   512  4096          0     42920312832   /dev/dm-2

Upvotes: 4

Josh Elias
Josh Elias

Reputation: 3290

The answer was to run blockdev --setra in a startup script. Every time the system reboots the read-ahead values revert back to default.

In my case I just figured out what my logical drives were with blockdev --report, I then run blockdev --setra on every drive in the "start" section of the MongoDB startup script in init.d.

Hope this helps anybody else having similar issues.

Upvotes: 8

Tyler Brock
Tyler Brock

Reputation: 30136

If the data files are in /data but those files are no on the device specified, setting the proper read ahead on /dev/mapper/vg0-data will have no effect.

The blockdev command should be run against the device /data is mounted from: sudo blockdev --setra 256 /dev/<dev where data lives>

Upvotes: 3

Related Questions