0
votes

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 problem. I also tried using dpkg.

ubuntu-user@ubuntu-vm:~$ export LC_ALL=C

ubuntu-user@ubuntu-vm:~$ dpkg-reconfigure locales
root@ubuntu-vm:~# dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_US:en",
    LC_ALL = "c",
    LC_PAPER = "nl_NL.UTF-8",
    LC_ADDRESS = "nl_NL.UTF-8",
    LC_MONETARY = "nl_NL.UTF-8",
    LC_NUMERIC = "nl_NL.UTF-8",
    LC_TELEPHONE = "nl_NL.UTF-8",
    LC_IDENTIFICATION = "nl_NL.UTF-8",
    LC_MEASUREMENT = "nl_NL.UTF-8",
    LC_NAME = "nl_NL.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (c)
Generating locales...
  en_AG.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_AU.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_BW.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_CA.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_DK.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_GB.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_HK.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_IE.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_IN.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_NG.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_NZ.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_PH.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_SG.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_US.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_ZA.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_ZM.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
  en_ZW.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
Generation complete.

Apparently, that didn't work properly, so I needed to continue my search. I came up with another solution: edit the /etc/default/grub file with GRUB_CMDLINE_LINUX_DEFAULT="transparent_hugepage=never" and then I got this:

ubuntu-user@ubuntu-vm:~$ mongo
Failed global initialization: BadValue Invalid or no user locale set.
Please ensure LANG and/or LC_* environment variables are set correctly.

ubuntu-user@ubuntu-vm:~$ mongod
2015-03-27T12:56:19.085+0100 F CONTROL  Failed global initialization:
BadValue Invalid or no user locale set. Please ensure LANG and/or LC_*
environment variables are set correctly.

So, practically I have no idea what went wrong. I looked all over the internet and couldn't find the exact answer I am looking for. I did a clean install just like the website said. A few months ago I did the same tutorial and everything was working perfectly, with version 2.6.x, this is 3.0.1.

Could you guys help me out? Any comments/tips/tricks will be sincerely appreciated :)

Edit 1 - Response Fernando

ubuntu-user@ubuntu-vm:~$ mongo
MongoDB shell version: 3.0.1
connecting to: test
Server has startup warnings:
2015-03-27T13:53:25.243+0100 I CONTROL  [initandlisten]
2015-03-27T13:53:25.243+0100 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-03-27T13:53:25.243+0100 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-03-27T13:53:25.243+0100 I CONTROL  [initandlisten]
> LC_ALL=C mongo
2015-03-27T18:54:16.838+0100 E QUERY    SyntaxError: Unexpected identifier
> LC_ALL=C
2015-03-27T18:54:20.061+0100 E QUERY    ReferenceError: C is not defined
    at (shell):1:8
> ^C
bye
2

2 Answers

4
votes

After installing using apt-get, you don't need to start mannually the mongod. You can start and stop de server with

# service mongod start

and

# service mongod stop

The first time you typed mongo and got:

MongoDB shell version: 3.0.1
connecting to: test

the server was up and running.

If you have this error now:

Failed global initialization: BadValue Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly.

You can start the mongo shell declaring the variable LC_ALL, running:

# LC_ALL=C mongo
0
votes

Go to edit the file /etc/default/locale and set

LANG= LANGUAGE= LC_ALL=

to your preferred settings. As an example:

$ vim /etc/default/locale LANG=en_US.UTF-8 LANGUAGE=en_US LC_ALL=en_US.UTF-8