2

I recently installed MongoDB on an AWS EC2 instance running Ubuntu.
When I'm starting the MongoDB service, I get some warnings:

$ mongo
MongoDB shell version: 3.0.11
connecting to: test
Server has startup warnings: 
2016-04-01T07:28:10.926+0000 I CONTROL  [initandlisten] 
2016-04-01T07:28:10.926+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-04-01T07:28:10.926+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-04-01T07:28:10.926+0000 I CONTROL  [initandlisten] 
2016-04-01T07:28:10.926+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-04-01T07:28:10.926+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-04-01T07:28:10.926+0000 I CONTROL  [initandlisten] 
> 

I think that this is what prevents the migration from Parse.com, as I posted on this question.

How can I ignore these warnings and disable it?

2

You need to apply what MongoDB Docs say:

https://docs.mongodb.org/manual/tutorial/transparent-huge-pages/

I installed MongoDB 3.0.8 as couple of months ago and got the same warnings. This setting was set by Amazon. First thing to do is create a script that can enable and disable Transparent Pages. Documentation gives this:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          disable-transparent-hugepages
# Required-Start:    $local_fs
# Required-Stop:
# X-Start-Before:    mongod mongodb-mms-automation-agent
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description:       Disable Linux transparent huge pages, to improve
#                    database performance.
### END INIT INFO

case $1 in
  start)
    if [ -d /sys/kernel/mm/transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/transparent_hugepage
    elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/redhat_transparent_hugepage
    else
      return 0
    fi

    echo 'never' > ${thp_path}/enabled
    echo 'never' > ${thp_path}/defrag

    unset thp_path
    ;;
esac

I use CentOS. I had this script made and I chkconfig'd it as a service so THP is disabled at startup.

In your case, you will have to run the script, restart MongoDB (service mongod restart), login to mongo and that warning should be gone. You need to follow the docs for Ubuntu as it says to install using:

sudo update-rc.d disable-transparent-hugepages defaults
  • Don't forget to give permission to the file sudo chmod 755 /etc/init.d/disable-transparent-hugepages – gus Aug 13 '16 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.