I updated the mongodb using
sudo apt-get install mongodb-org
mongodb is updated from 2.4 to 3.0. Soon after I connected to mongo shell, it is displaying the below start up warnings. I am unaware of fixing it. Suggest me how to fix these warnings?
MongoDB shell version: 3.0.1
connecting to: test
Server has startup warnings:
2015-04-03T13:37:53.536+0530 I CONTROL [initandlisten]
2015-04-03T13:37:53.536+0530 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-04-03T13:37:53.536+0530 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-04-03T13:37:53.536+0530 I CONTROL [initandlisten]
2015-04-03T13:37:53.537+0530 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-04-03T13:37:53.537+0530 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-04-03T13:37:53.537+0530 I CONTROL [initandlisten]
Adding the following lines preceding exit 0 in /etc/rc.local file with root privileges did the magic. Rebooted the OS after saving the file.Then warnings disappeared in the mongo shell.
Source: MongoDB documentation(http://docs.mongodb.org/manual/reference/transparent-huge-pages/#transparent-huge-pages-thp-settings)
if test -f /sys/kernel/mm/transparent_hugepage/khugepaged/defrag; then
echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
Those warnings pop up due to Transparent Huge Pages (THP) settings.
As stated in the official MongoDB documentation:
However, THP is known to perform poorly under database workloads, which tend to have sparse rather than contiguous memory access patterns. You must disable THP on Linux machines used to run MongoDB instances to ensure best performance.
There is a similar thread on StackOverflow where you can find a possible solution that recommends updating the mongod.conf
file so that you overwrite the THP properties indicated by MongoDB.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With