Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodb startup warnings after update

Tags:

mongodb

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] 
like image 701
hello world Avatar asked Apr 03 '15 08:04

hello world


2 Answers

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
like image 140
hello world Avatar answered Oct 18 '22 11:10

hello world


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.

like image 6
vladzam Avatar answered Oct 18 '22 09:10

vladzam