HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

MongoDB installation Ubuntu 12.04 LTS errors

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
ubuntultsmongodbinstallationerrors

Problem

I need some help with my MongoDB installation on a clean, fresh Ubuntu 12.04 LTS server with no nonsense installed. I thought it would be a piece of cake, but I got some errors and the Ubuntu-forums didn't had the answer I was looking for.

Before I started with the actual installation of MongoDB, I wanted the server to be up-to-date, so I typed:

$ sudo apt-get clean && sudo apt-get update && sudo apt-get upgrade


I went to to website from MongoDB (http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/) and followed their tutorial, so I typed:

$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
$ echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
$ sudo apt-get update
$ sudo apt-get install -y mongodb-org


At this point I have MongoDB installed. Like we all know, in order to use MongoDB you need to start it using a terminal and after that you'll be able to connect with a seperated terminal/connection.

So, I typed:

ubuntu-user@ubuntu-vm:~$ mongo
MongoDB shell version: 3.0.1
connecting to: test
Server has startup warnings: 
2015-03-27T12:37:30.430+0100 I CONTROL  [initandlisten] 
2015-03-27T12:37:30.430+0100 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-03-27T12:37:30.430+0100 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-03-27T12:37:30.430+0100 I CONTROL  [initandlisten] 
> ^C

ubuntu-user@ubuntu-vm:~$ mongod
2015-03-27T12:38:54.773+0100 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2015-03-27T12:38:54.774+0100 I CONTROL  [initandlisten] dbexit:  rc: 100


Ofcourse, I don't want to use stackoverflow right away, before doing my own investigation first. I went online to look for answers and I noticed that lots of people using "export LC_ALL=C" to fix the variable pro

Solution

There is actually nothing really wrong here, at least not based on what you have included in the question. Go back to this point:

ubuntu-user@ubuntu-vm:~$ mongo

MongoDB shell version: 3.0.1
connecting to: test
Server has startup warnings: 
2015-03-27T12:37:30.430+0100 I CONTROL  [initandlisten] 
2015-03-27T12:37:30.430+0100 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-03-27T12:37:30.430+0100 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-03-27T12:37:30.430+0100 I CONTROL  [initandlisten] 
> ^C


At this point you have a running mongod (the procedure you followed installs it as a service), and you have successfully connected to it using the mongo shell, it just has a hugepages warning - that is something you should fix long-term but it does not prevent MongoDB from running.

You then exited the shell and attemped to start another mongod for some reason (you do not need to, the service is still running). If you run mongod without a config file or any options, it will attempt to start with its defaults (port 27017, data directory = /data/db). In this case /data/db does not exist and so you get the error and it terminates.

To fix the error in terms of the hugepages you can alter grub.conf file, as outlined in this answer but you may have made a mistake or omitted something when you made your changes. It's also possible that you will lose those changes if/when you upgrade your kernel. Hence I would recommend undoing your grub changes and trying the second option listed in the answer above, that is, add the command to your /etc/rc.local file.

if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi


As an added bonus, you can run this from the command line (as root), then restart the mongod service to confirm the changes have been picked up successfully.

Code Snippets

ubuntu-user@ubuntu-vm:~$ mongo

MongoDB shell version: 3.0.1
connecting to: test
Server has startup warnings: 
2015-03-27T12:37:30.430+0100 I CONTROL  [initandlisten] 
2015-03-27T12:37:30.430+0100 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-03-27T12:37:30.430+0100 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-03-27T12:37:30.430+0100 I CONTROL  [initandlisten] 
> ^C
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi

Context

StackExchange Database Administrators Q#96477, answer score: 2

Revisions (0)

No revisions yet.