Sometime the most obvious thing turns out to be the most complicated one. Here’s my small journey to get mongoDB running on one 64bit Debian server.
Like any other reasonable person I started from the
manual.
Everything worked as they said it would and for some time I was quite happy with
it. But at some point for whatever reason I peaked into
/var/log/mongodb/mongodb.log
.
***** SERVER RESTARTED *****
Wed Dec 12 17:34:37 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Wed Dec 12 17:34:37
Wed Dec 12 17:34:37 [initandlisten] MongoDB starting : pid=4281 port=27017 dbpath=/var/lib/mongodb 32-bit host=debian-server
Wed Dec 12 17:34:37 [initandlisten]
Wed Dec 12 17:34:37 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Wed Dec 12 17:34:37 [initandlisten] ** see http://blog.mongodb.org/post/137788967/32-bit-limitations
Wed Dec 12 17:34:37 [initandlisten] ** with --journal, the limit is lower
Wed Dec 12 17:34:37 [initandlisten]
Wed Dec 12 17:34:37 [initandlisten] ** WARNING: You are running on a NUMA machine.
Wed Dec 12 17:34:37 [initandlisten] ** We suggest launching mongod like this to avoid performance problems:
Wed Dec 12 17:34:37 [initandlisten] ** numactl --interleave=all mongod [other options]
Wed Dec 12 17:34:37 [initandlisten]
Wed Dec 12 17:34:37 [initandlisten] db version v2.2.2, pdfile version 4.5
Wed Dec 12 17:34:37 [initandlisten] git version: d1b43b61a5308c4ad0679d34b262c5af9d664267
Wed Dec 12 17:34:37 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_49
Wed Dec 12 17:34:37 [initandlisten] options: { config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", logappend: "true", logpath: "/var/log/mongodb/mongodb.log" }
Wed Dec 12 17:34:37 [initandlisten] Unable to check for journal files due to: boost::filesystem::basic_directory_iterator constructor: No such file or directory: "/var/lib/mongodb/journal"
Wed Dec 12 17:34:37 [websvr] admin web console waiting for connections on port 28017
Wed Dec 12 17:34:37 [initandlisten] waiting for connections on port 27017
2GB limit? That really does not work for me in the long run. So how can I get this running on 64bit?
After spending an hour trying to figure out how to install 64bit binaries via apt I gave up. There just isn’t a way (please let me know if there is).
So I downloaded Linux 64-bit binaries, but:
debian-server:~/mongodb-linux-x86_64-2.4.1/bin# ./mongod
bash: ./mongod: No such file or directory
Obviously the file exists, which means that the binary is not for the correct arch. As I knew little about my server I started to doubt whether I was actually on 64bit arch. Let’s find out:
debian-server:~/mongodb-linux-x86_64-2.4.1/bin# uname -a
Linux debian-server 2.6.32-5-amd64 #1 SMP Sun May 6 05:12:07 UTC 2012 x86_64 GNU/Linux
amd64 definitely looks like 64bit.
debian-server:~/mongodb-linux-x86_64-2.4.1/bin# lscpu
Architecture: x86_64
CPU op-mode(s): 64-bit
...
debian-server:~/mongodb-linux-x86_64-2.4.1/bin# grep flags /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow rep_good pni cmp_legacy
So I have 64bit CPU and 64bit kernel. Did I download the correct binaries?
debian-server:~/mongodb-linux-x86_64-2.4.1/bin# file mongod
mongod: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
Yup. Damn. Why is it not running then?
Quite a few searches later I found a small tip, so I created a file test.c
#include <stdio.h>
int main(){
printf("dafuq?\n");
return 0;
}
And tried to compile it:
debian-server:~/mongodb-linux-x86_64-2.4.1/bin# gcc -m64 test.c
In file included from /usr/include/features.h:378,
from /usr/include/stdio.h:28,
from test.c:1:
/usr/include/gnu/stubs.h:9:27: error: gnu/stubs-64.h: No such file or directory
Now we are getting somewhere. Aparently stubs-64.h is part of a debian package libc6-dev-amd64. Let’s install it and try my test again
debian-server:~/mongodb-linux-x86_64-2.4.1/bin# apt-get install libc6-dev-amd64
debian-server:~/mongodb-linux-x86_64-2.4.1/bin# gcc -m64 test.c
debian-server:~/mongodb-linux-x86_64-2.4.1/bin# ./a.out
dafuq?
Better. How about mongoDB?
debian-server:~/mongodb-linux-x86_64-2.4.1/bin# ./mongod
./mongod: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
Dear mongoDB, why didn’t you start with this? Final fix and it works:
debian-server:~/mongodb-linux-x86_64-2.4.1/bin# apt-get install lib64stdc++6
PS. You may also be interested in mongodb.conf and init scripts for debian