It seems to me like there's currently two way to go about this:

  1. https://github.com/skrabban/mongo-nonx86
  2. https://github.com/RickP/mongopi

I settled for the mongo-nonx86 fork. I installed the dependencies as described in Install Mongodb in Raspberry Pi and tried to build MongoDB using scons. But I get the following error:

generate_buildinfo(["build/buildinfo.cpp"], ['\n#include <string>\n#include <boost/version.hpp>\n\n#include "mongo/util/version.h"\n\nnamespace mongo {\n    const char * gitVersion() { return "%(git_version)s"; }\n    std::string sysInfo() { return "%(sys_info)s BOOST_LIB_VERSION=" BOOST_LIB_VERSION ; }\n}  // namespace mongo\n'])
gcc -o build/linux2/normal/third_party/pcre-8.30/pcre_exec.o -c -fPIC -fno-strict-aliasing -Wstrict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Wcast-align -Winvalid-pch -O3 -DBOOST_ALL_NO_LIB -D_SCONS -DMONGO_EXPOSE_MACROS -DSUPPORT_UTF8 -D_FILE_OFFSET_BITS=64 -DJS_C_STRINGS_ARE_UTF8 -DMONGO_HAVE_HEADER_UNISTD_H -DMONGO_HAVE_EXECINFO_BACKTRACE -DHAVE_SYNC_FETCH_AND_ADD -DALIGNMENT_IMPORTANT -DHAVE_BSWAP32 -DHAVE_BSWAP64 -DHAVE_CONFIG_H -Ibuild/linux2/normal/third_party/boost -Isrc/third_party/boost -Ibuild/linux2/normal/third_party/pcre-8.30 -Isrc/third_party/pcre-8.30 -Ibuild/linux2/normal -Isrc -Ibuild/linux2/normal/mongo -Isrc/mongo src/third_party/pcre-8.30/pcre_exec.c
gcc: internal compiler error: Killed (program cc1)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
scons: *** [build/linux2/normal/third_party/pcre-8.30/pcre_exec.o] Error 4
scons: building terminated because of errors.

Compiling mongopi will stop at the exact same file with the same error message.

In the meanwhile, I realized that my system was dramatically outdated. But even upgrading to the latest versions didn't resolve the problem. At this point, I'm assuming that it is indeed an issue with free memory. Given that I only have an early 256 MB model.

  • could be a memory issue - have you configured memory split? How much free memory do you have before you run gcc?
    – abolotnov
    Feb 7 '13 at 13:41
  • @abolotnov: I'll answer those as soon as my compilation of mongopi is complete ;D As I'm exploring that avenue right now Feb 7 '13 at 14:45
  • @abolotnov: Memory split is 224/32. free -m shows 177 free. Feb 7 '13 at 21:28
  • 1
    Mongodb binary is in the community repository on the Arch ARM distro.
    – Jivings
    Feb 8 '13 at 19:12
  • @Jivings: Might be worth a shot to use Arch, because I'm going nowhere with compiling it on the Wheezy release. Feb 8 '13 at 21:15

Please note that this answer only applied to the 256 MB version of the Raspberry Pi. The 512 MB version should have sufficient free memory to compile MongoDB without additional adjustments

While reading about low-memory situation's in general, I found suggestions to simply increase the swap space to remedy the situation.

So, after reading bearbin's answer, I was convinced that this could be a valid option. However, I opted to add swap space without utilizing zRAM.

Because I can never remember the full process for anything, I followed the guide Linux Add a Swap File – Howto by Nixcraft.

  1. Create swap file/storage space:

    sudo dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
  2. Set space up as swap area:

    sudo mkswap /swapfile1
  3. Only allow root to read/write:

    sudo chmod 0600 /swapfile1
  4. Enable swap area:

    sudo swapon /swapfile1

Afterwards, scons completed successfully and I was able to install MongoDB. I used the mongopi fork in the end.

db level locking enabled: 1
mongod --help for help and startup options
Sun Feb 10 13:05:33
Sun Feb 10 13:05:33 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Sun Feb 10 13:05:33
Sun Feb 10 13:05:33 [initandlisten] MongoDB starting : pid=2182 port=27017 dbpath=/data/db/ 32-bit host=raspberrypi
Sun Feb 10 13:05:33 [initandlisten]
Sun Feb 10 13:05:33 [initandlisten] ** NOTE: This is a development version (2.1.1) of MongoDB.
Sun Feb 10 13:05:33 [initandlisten] **       Not recommended for production.
Sun Feb 10 13:05:33 [initandlisten]
Sun Feb 10 13:05:33 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Sun Feb 10 13:05:33 [initandlisten] **       see http://blog.mongodb.org/post/137788967/32-bit-limitations
Sun Feb 10 13:05:33 [initandlisten] **       with --journal, the limit is lower
Sun Feb 10 13:05:33 [initandlisten]
Sun Feb 10 13:05:33 [initandlisten] db version v2.1.1, pdfile version 4.5
Sun Feb 10 13:05:33 [initandlisten] git version: f457ff42ec37f2562d1a5ff06b4d96a861414c94
Sun Feb 10 13:05:33 [initandlisten] build info: Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l BOOST_LIB_VERSION=1_49
Sun Feb 10 13:05:33 [initandlisten] options: {}
Sun Feb 10 13:05:34 [initandlisten] waiting for connections on port 27017
Sun Feb 10 13:05:34 [websvr] admin web console waiting for connections on port 28017
  • I had the same problem on a model B and this solution worked. Thx Mar 12 '13 at 8:16
  • THANK YOU SO MUCH OLIVER. I would like to point out that Model B did not have sufficient free memory for me and that after following this advice the installation worked. Would you mind altering your note in this answer to consider that two people with Model B needed to follow your steps? Jun 22 '13 at 5:22
  • @MatthewMoisen: I had this issue with a Model B as well. But mine was the first revision with 256 MB RAM. Only the second revision got 512 MB. Jun 22 '13 at 15:47

I have an option that might work. However, it will probably dramatically slow down your compilation process.

You need to set up ZRAM on your Pi. Basically it compresses the used RAM to allow you to use more, but at the cost of more CPU usage.

We will follow the instructions here but I will put them in the post for easy viewing.

So first, you need to be root as lots of these commands require root:

sudo su

Then, make a file called /etc/init.d/zram with the following contents:


#Provides: zram
#Default-Start: 2 3 4 5
#Default-Stop: 0 1 6
#Short-Description: Increased Performance In Linux With zRam (Virtual Swap Compressed in RAM)
#Description: Adapted for Raspian (Rasberry pi) by eXtremeSHOK.com using https://raw.github.com/gionn/etc/master/init.d/zram

start() {
    mem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching '[[:digit:]]+')

    modprobe zram

    sleep 1
    #only using 50% of system memory, comment the line below to use 100% of system memory

    echo $((mem_total_kb * 1024)) > /sys/block/zram0/disksize

    mkswap /dev/zram0

    swapon -p 100 /dev/zram0

stop() {
    swapoff /dev/zram0
    sleep 1
    rmmod zram

case "$1" in
        sleep 3
        echo "Usage: $0 {start|stop|restart}"

If you want an easy way to get it on the Pi: sudo wget http://vps1.berboe.co.uk/zram.sh -O /etc/init.d/zram.

Then, add your script to the start-at-boot list by doing:

chmod +x /etc/init.d/zram
update-rc.d zram defaults

Then reboot and it should all work.

After the reboot, run this command: swapon -s. The output should be somewhat like this:

Filename Type Size Used Priority
/var/swap file 524284 0 -1
/dev/zram0 partition 237900 0 100

Now, ZRAM is installed and if you try to compile like you did before it might work.

  • Thanks for this suggestion! I've simply added additional swap space without utilizing zram for now. Trying to continue compilation now. Feb 9 '13 at 15:27

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.