Installing MongoDB in a Debian Wheezy LXC-Container

von tobonaut

I currently were trying to install a MongoDB server on my playground linux home-server but it wasn’t that simple one command installtion as I thought it to be or as I’m used to from debian.

Since I wanted to benefit from the advantages of isolation I created a new LXC container db02 on my homeserver and installed the package there.

To get a more recent version of MongoDB (2.4.x instead of 2.0.x) I added a sources.list entry for debian testing and used the -t option to select testing as source. For a production system you should always think about using apt-pinning to prevent accidental upgrades but for my playground system I simply ignored this:

root@db02:~# cat /etc/apt/sources.list
deb http://cdn.debian.net/debian wheezy main
deb http://cdn.debian.net/debian testing main
root@db02:~# apt-get install -t testing mongodb-server

The installation so far went fine but at the end instead of getting a running MongoDB server I got the following error message during the start of the MongoDB daemon which fortunately was easy to google for:

root@db02:~# /usr/bin/mongod
/usr/bin/mongod --help for help and startup options
Mon Nov  3 19:34:11.764 [initandlisten] MongoDB starting : pid=1747 port=27017 dbpath=/data/db/ 64-bit host=db02
Mon Nov  3 19:34:11.765 [initandlisten] db version v2.4.10
Mon Nov  3 19:34:11.765 [initandlisten] git version: nogitversion
Mon Nov  3 19:34:11.765 [initandlisten] build info: Linux julia 3.14-1-amd64 #1 SMP Debian 3.14.4-1 (2014-05-13) x86_64 BOOST_LIB_VERSION=1_55
Mon Nov  3 19:34:11.765 [initandlisten] allocator: tcmalloc
Mon Nov  3 19:34:11.765 [initandlisten] options: {}
Mon Nov  3 19:34:11.780 [initandlisten] exception in initAndListen std::exception: locale::facet::_S_create_c_locale name not valid, terminating
Mon Nov  3 19:34:11.780 dbexit: 
Mon Nov  3 19:34:11.780 [initandlisten] shutdown: going to close listening sockets...
Mon Nov  3 19:34:11.781 [initandlisten] shutdown: going to flush diaglog...
Mon Nov  3 19:34:11.781 [initandlisten] shutdown: going to close sockets...
Mon Nov  3 19:34:11.781 [initandlisten] shutdown: waiting for fs preallocator...
Mon Nov  3 19:34:11.781 [initandlisten] shutdown: lock for final commit...
Mon Nov  3 19:34:11.782 [initandlisten] shutdown: final commit...
Mon Nov  3 19:34:11.782 [initandlisten] shutdown: closing all files...
Mon Nov  3 19:34:11.782 [initandlisten] closeAllFiles() finished
Mon Nov  3 19:34:11.783 [initandlisten] shutdown: removing fs lock...
Mon Nov  3 19:34:11.783 dbexit: really exiting now

To fix this issue (and more locale related problems – like warnings on ssh connect) I had to install the locales package, re-configure and generate the locale files to use:

root@db02:~# apt-get install locales
root@db02:~# dpkg-reconfigure locales

In the shown menu I selected the en_US.UTF-8 and en_US.ISO-8859-1 locales and set the first one as system default.

This fixed my issue and I was able to complete the setup and start the database daemon:

root@db02:~# apt-get install mongodb-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
mongodb-server is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 97 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Setting up mongodb-server (1:2.4.10-2) ...
[ ok ] Starting database: mongodb.

Recap: It can be a bit tricky to get non-stable (doesn’t mean un-stable) software to run but the most problems are minors. I’m now having my NoSQL database up and running and can deploy my rails app to use it.

Advertisements