MongoDB 3.0.9 binaries for Raspberry Pi 2 & 3 (Jessie)


I’ve received feedback that some folks are having problems compiling MongoDB 3.0.7 per my instructions AND it takes a long time 😉

MongoDB 3.0.9 just became available but needs quite a few changes to source in order to compile on the Raspberry Pi.  I worked through MongoDB build scripts for ARCH ARM Linux and managed to “translate” for Raspbian (Jessie) Linux on the R-Pi 2.  Rather than creating patch files and writing instructions for building from source, I am providing my compiled binaries.  PLEASE do not post links to my binaries!  Feel free to download for personal use from this site.

NOTE: (08 Mar 2016) I have confirmed binaries and instructions work for the Raspberry Pi 3 using Raspbian Jessie 2016-02-26.

Details are here.

As always make sure you have updated your R-Pi

sudo apt-get update
sudo apt-get upgrade

You can download a gzip file of the MongoDB core binaries v3.0.9 from here.

md5sum:  aebd9f083ca7c56e7e4d61e205d7d379  core_mongodb.tar.gz


  • mongo
  • mongod
  • mongoperf
  • mongos

You can download a gzip file of the MongoDB tools v3.0.9 from here.

md5sum:  ec7774fb1f38a601967961ce5defd417  tools_mongodb.tar.gz


  • mongoexport
  • mongoimport
  • mongorestore
  • mongotop
  • mongodump
  • mongofiles
  • mongooplog
  • mongostat

UPDATE: (31 Jul 2016) I was asked about supporting the SSL option in the tools.  I have compiled tools v3.0.9 with the SSL flag.  You can download a zipped directory from here.

md5sum:  325f070f0337ad7fa0ef3d49bad91b69  mongodb_tools_ssl_3_0_9.tar.gz



These instructions are for base mongodb (mongo, mongod, mongos, mongoperf).  I have recreated from my history file and memory — so you should review carefully — and LMK if you have any issues

– check for mongodb user

grep mongodb /etc/passwd

– if NO mongodb user, create:

sudo adduser --ingroup nogroup --shell /etc/false --disabled-password --gecos "" \
--no-create-home mongodb

– cd to the directory with mongo, mongod, mongos, etc
– ensure appropriate owner & executable permissions
– strip out symbols to reduce file size
– move to /usr/bin which is in PATH

cd dir-with-binaries
sudo chown root:root mongo*
sudo chmod 755 mongo*
sudo strip mongo*
sudo cp -p mongo* /usr/bin

– create log file directory with appropriate owner & permissions

sudo mkdir /var/log/mongodb
sudo chown mongodb:nogroup /var/log/mongodb

– create the DB data directory with convenient access perms

sudo mkdir /var/lib/mongodb
sudo chown mongodb:root /var/lib/mongodb
sudo chmod 775 /var/lib/mongodb

– create the mongodb.conf file in /etc

cd /etc
sudo vi mongodb.conf

– insert into file:

# /etc/mongodb.conf
# minimal config file (old style)
# Run mongod --help to see a list of options

bind_ip =
quiet = true
dbpath = /var/lib/mongodb
logpath = /var/log/mongodb/mongod.log
logappend = true
storageEngine = mmapv1

– create systemd / service entry

cd /lib/systemd/system
sudo vi mongodb.service

– insert into file:

Description=High-performance, schema-free document-oriented database

ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf


– you are now ready to launch mongodb!

sudo service mongodb start

– check status

sudo service mongodb status


sudo service mongodb stop

Please LMK if you have issues and/or success in using these binaries  and instructions 😎

MongoDB Tools install:

unzip the tools tar file after downloading into an empty directory (download link described above).  Strip out symbols to reduce size, change owner and permissions, and move to /usr/bin directory:

tar zxvf tools_mongodb.tar.gz
sudo strip mongo*
sudo chown root:root mongo*
sudo chmod 755 mongo*
sudo mv mongo* /usr/bin

You can now invoke tools from the command line — mongodump, mongoimport, etc.


82 Comments (+add yours?)

  1. Julien Reichardt
    Feb 18, 2016 @ 10:40:07

    Hi Andy! Thanks a lot for this binaries, they are perfect, very usefull 🙂


  2. iMomin
    Feb 23, 2016 @ 07:48:04

    Thanks! saved lots of time.
    I do have a question regarding Mongodb connection.
    When I run “sudo service mongodb status” I get following output, which means the mongodb server is running…
    ● mongod.service – LSB: An object/document-oriented database
    Loaded: loaded (/etc/init.d/mongod)
    Active: active (exited) since Tue 2016-02-23 14:33:29 UTC; 1h 10min ago
    Process: 497 ExecStart=/etc/init.d/mongod start (code=exited, status=0/SUCCESS)

    Feb 23 14:33:29 pibox mongod[497]: Starting database: mongodb.
    Feb 23 14:33:29 pibox systemd[1]: Started LSB: An object/document-oriented database

    However, when I try to connect the mongodb from my Nodejs app within the Rpi, I get following error
    “MongoDB connection error: MongoError: connect ECONNREFUSED”

    The mongodb is started by user “mongodb” and node app is started by user “pi”

    Any idea?


  3. andy
    Feb 23, 2016 @ 21:06:02

    Hmmm, try 2 things to help debug. Just type “mongo” to see if a shell connects. LMK if you see any error message. Also, you can look at /var/log/mongodb/mongod.log to see if there are log entries. You can run “ps -ef | grep mongod” to confirm that mongod is running. Also check /etc/mongodb.conf — if using a static IP, you might add that to the config file.


  4. Joe
    Feb 26, 2016 @ 12:17:31


    I’m getting this runtime error using mongorestore:

    $ ~/mongostuff/mongorestore
    runtime: this CPU has no VFPv3 floating point hard

    Does it look like I’m executing the binary properly? Did you compile the binary specifically for Rasbperry Pi 2 (which is what I’m using)?

    Thanks much!


  5. andy
    Feb 26, 2016 @ 12:57:30

    Joe, I HAVE used mongorestore (3.0.9) without issue.

    First check your OS version. You must be running latest Raspbian Jessie on a Raspberry Pi 2.

    $ uname -a
    Linux raspiMongo 4.1.17-v7+ #838 SMP Tue Feb 9 13:15:09 GMT 2016 armv7l GNU/Linux

    Check your version of mongorestore. Make sure you are pointing at correct binary location:

    $ ./mongorestore --version
    mongorestore version: 3.0.9
    git version: cfa294993db4d981cce7c8d5f7c6bb6f624e6dd6

    Make sure mongod is really running:

    $ ps -ef | grep mongod
    mongodb 10824 1 0 12:45 ? 00:00:02 /usr/bin/mongod --quiet --config /etc/mongodb.conf

    Check mongodb log for any messages at /var/log/mongodb/mongod.log

    LMK what you find or see!

    – Andy


  6. Joe
    Feb 26, 2016 @ 13:26:22

    Thanks for the fast reply!

    Running latest:

    $ uname -a
    Linux raspberrypi 4.1.17+ #838 Tue Feb 9 12:57:10 GMT 2016 armv6l GNU/Linux

    I get the same as when I try to run mongorestore (do have to put this file anywhere special? I’m just running it from a random directory that I created):

    $ ~/mongostuff/mongorestore –version
    runtime: this CPU has no VFPv3 floating point hardware, so it cannot run
    this GOARM=7 binary. Recompile using GOARM=5.

    Mongod is running:

    $ ps -ef | grep mongod
    mongodb 29571 1 0 20:36 ? 00:00:23 /usr/bin/mongod –quiet –config /etc/mongodb.conf

    mongodb/mongo.log (I trimmed it to start from a shutdown command. there was also some lines related to the scanning of empty collections my app created):

    2016-02-26T20:36:41.844+0000 I CONTROL ***** SERVER RESTARTED *****
    2016-02-26T20:36:41.918+0000 I CONTROL [initandlisten] MongoDB starting : pid=29571 port=27017

    [EDITED by Andy to remove a bunch of lines]

    2016-02-26T20:36:42.203+0000 I NETWORK [initandlisten] waiting for connections on port 27017

    I also tried to connect to the pi from mac while passing the host and port parameters, but that also fails with a “no reachable servers” issue.

    Thanks again!


  7. andy
    Feb 26, 2016 @ 13:50:17


    Looks like you are NOT running on a Raspberry Pi 2 B 🙁 You show:

    $ uname -a
    Linux raspberrypi 4.1.17+ #838 Tue Feb 9 12:57:10 GMT 2016 armv6l GNU/Linux

    I show, on my R-Pi 2, quad core, 1GB RAM:

    $ uname -a
    Linux raspiPlusBerry 4.1.17-v7+ #838 SMP Tue Feb 9 13:15:09 GMT 2016 armv7l GNU/Linux

    NOTE the armv6l for you and the armv7l for me

    OR, perhaps you are on a R-Pi 2 but have not done a “dist-upgrade” since Raspbian Jessie was released?

    Check CPU, cores, etc.:

    $ lscpu
    Architecture: armv7l
    Byte Order: Little Endian
    CPU(s): 4
    On-line CPU(s) list: 0-3
    Thread(s) per core: 1
    Core(s) per socket: 4
    Socket(s): 1
    Model name: ARMv7 Processor rev 5 (v7l)
    CPU max MHz: 1000.0000
    CPU min MHz: 600.0000

    LMK what you find!

    — Andy


  8. Joe
    Feb 26, 2016 @ 13:54:00

    Yep! that was it. I thought FOR SURE I was running a 2. Thanks much for the time. I’ll report back when I swap SD cards for an actual RPI 2.

    pi@raspberrypi:~ $ lscpu
    Architecture: armv6l
    Byte Order: Little Endian
    CPU(s): 1
    On-line CPU(s) list: 0
    Thread(s) per core: 1
    Core(s) per socket: 1
    Socket(s): 1
    Model name: ARMv6-compatible processor rev 7 (v6l)
    CPU max MHz: 900.0000
    CPU min MHz: 700.0000


  9. Masinde
    Mar 03, 2016 @ 04:27:10

    sudo service mongodb status
    ● mongodb.service – High-performance, schema-free document-oriented database
    Loaded: loaded (/lib/systemd/system/mongodb.service; disabled)
    Active: active (running) since Thu 2016-03-03 12:13:55 UTC; 15s ago
    Main PID: 952 (mongod)
    CGroup: /system.slice/mongodb.service
    └─952 /usr/bin/mongod –quiet –config /etc/mongodb.conf

    Mar 03 12:13:55 raspberrypi systemd[1]: Started High-performance, schema-free document-oriented database.

    but once I run mongo comand it gives this ” 2016-03-03T12:25:13.052+0000 F CONTROL Failed global initialization: BadValue Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly. ”
    Mar 03 12:13:56 raspberrypi mongod[952]: 2016-03-03T12:13:56.457+0000 I CONTROL
    Mar 03 12:13:56 raspberrypi mongod[952]: 2016-03-03T12:13:56.457+0000 W CONTROL 32-bit servers don’t have journaling enabled by default. Please use –journal if you want durability.
    Mar 03 12:13:56 raspberrypi mongod[952]: 2016-03-03T12:13:56.458+0000 I CONTROL


  10. Masinde
    Mar 03, 2016 @ 04:30:15

    When i run the MongoDB shell it gives the “Failed global initialization” any help ? Thanks


    • andy
      Mar 03, 2016 @ 10:00:32

      Have you set your “Internationalisation Options” using raspi-config? Set all 3 options.

      sudo raspi-config

      Or you could set shell variable:

      export LC_ALL=C

      ALSO, have you rebooted lately? Do that. Are you user “pi”?

      You are up-to-date with “sudo apt-get” update/upgrade? That’s all I have for suggestions 😉

      – Andy


  11. Masinde
    Mar 10, 2016 @ 06:07:11

    Thanks “export LC_ALL=C” did the magic


  12. AndyS
    Mar 12, 2016 @ 12:19:16

    I have followed the script, but I get this when I launch the shell:

    MongoDB shell version: 3.0.9
    2016-03-12T20:17:13.849+0000 F – Invalid operation at address: 0x47723b58
    2016-03-12T20:17:13.866+0000 F – Got signal: 4 (Illegal instruction).

    0x49e854 0x49df6c 0x49e35c 0xb6a951a0
    {“backtrace”:[{“b”:”10000″,”o”:”48E854″,”s”:”_ZN5mongo15printStackTraceERSo”},{“b”:”10000″,”o”:”48DF6C”},{“b”:”10000″,”o”:”48E35C”},{“b”:”B6A66000″,”o”:”2F1A0″,”s”:”__default_rt_sa_restorer_v2″}],”processInfo”:{ “mongodbVersion” : “3.0.9”, “gitVersion” : “20d60d3491908f1ae252fe452300de3978a040c7”, “uname” : { “sysname” : “Linux”, “release” : “4.1.18+”, “version” : “#846 Thu Feb 25 14:11:56 GMT 2016”, “machine” : “armv6l” }

    [EDIT – multiple lines removed by Andy] [0xb6a951a0]

    Can you help?

    I am running a raspy with jessie.


    • andy
      Mar 12, 2016 @ 12:25:46

      Hi AndyS,

      It looks like you are running on an older Raspberry Pi – NOT the R-Pi 2 or R-Pi 3 🙁 My binaries assume “armv7l”, you show in the dump “armv6l”. The supplied binaries will only run on the 2 or 3. You can do a “lscpu” to see what your processor is — for my R-Pi 3:

      $ lscpu
      Architecture: armv7l
      Byte Order: Little Endian
      CPU(s): 4
      On-line CPU(s) list: 0-3
      Thread(s) per core: 1
      Core(s) per socket: 4
      Socket(s): 1
      Model name: ARMv7 Processor rev 4 (v7l)
      CPU max MHz: 1200.0000
      CPU min MHz: 600.0000



  13. AndyS
    Mar 13, 2016 @ 03:45:59

    Hi Andy,

    Thanks for getting back to me so quickly.

    Indeed my Raspi is a few years old.

    lscpu gives me….

    Architecture: armv6l
    Byte Order: Little Endian
    CPU(s): 1
    On-line CPU(s) list: 0
    Thread(s) per core: 1
    Core(s) per socket: 1
    Socket(s): 1
    Model name: ARMv6-compatible processor rev 7 (v6l)
    CPU max MHz: 700.0000
    CPU min MHz: 700.0000

    Is it possible to run mongo on my old raspi?
    Is there something simple I can modify in you procedure above?



  14. AndyS
    Mar 13, 2016 @ 08:34:21

    Quick Solution….I upgraded to a Pi 2
    Thanks Anyway



  15. AndyS
    Mar 13, 2016 @ 12:19:14

    Mongo was working, but after my first reboot it stops running when I launch the shell…

    2016-03-13T19:17:56.596+0000 W NETWORK Failed to connect to, reason: errno:111 Connection refused
    2016-03-13T19:17:56.613+0000 E QUERY Error: couldn’t connect to server (, connection attempt failed
    at Error (native)
    at connect (src/mongo/shell/mongo.js:179:14)
    at (connect):1:6 at src/mongo/shell/mongo.js:179
    exception: connect failed

    Any ideas?


    • andy
      Mar 13, 2016 @ 13:23:36

      Sounds like “mongod” is NOT running. You can check “/etc/var/log/mongodb/mongod.log” for messages. Also try a “ps -ef | grep mongo” to see if the mongod process is running? Do a “sudo service mongodb stop” and try restart. There may be a file in “/var/lib/mongodb” named, “mongod.lock” if mongod is NOT running, you may need to delete this file in order to start again. Do you always shutdown mongodb before shutting-down the Pi? “sudo service mongodb stop”?


  16. Gaurav
    Mar 13, 2016 @ 12:24:26

    I have followed the steps as mentioned.
    i am running pi 2 B
    uname -a :
    Linux raspberrypi 4.1.18-v7+ #846 SMP Thu Feb 25 14:22:53 GMT 2016 armv7l GNU/Linux

    when i do sudo service mongodb start nothing happens,
    when i do sudo service mongodb status :

    mongodb.service – High-performance, schema-free document-oriented database
    Loaded: loaded (/lib/systemd/system/mongodb.service; disabled)
    Active: failed (Result: exit-code) since Sun 2016-03-13 19:08:13 UTC; 20s ago
    Process: 1205 ExecStart=/usr/bin/mongod –quiet –config /etc/mongodb.conf (code=exited, status=1/FAILURE)
    Main PID: 1205 (code=exited, status=1/FAILURE)

    Mar 13 19:08:13 raspberrypi systemd[1]: Started High-performance, schema-free document-oriented database.

    [EDIT: lines removed by Andy to save space]

    Failed global initialization: FileNotOpen Failed to open “/var/log/mongodb/mongod.log”
    Mar 13 19:08:13 raspberrypi systemd[1]: mongodb.service: main process exited, code=exited, status=1/FAILURE
    Mar 13 19:08:13 raspberrypi systemd[1]: Unit mongodb.service entered failed state.
    Hint: Some lines were ellipsized, use -l to show in full.

    what possibly am i doing wrong ?
    I am very new to raspberry pi and linux.


    • andy
      Mar 13, 2016 @ 13:15:26

      Hi Gaurav,

      Your error shows that the log file for mongodb (“/var/log/mongodb/mongod.log”) can not be created or written-to. Have you followed the instructions for creating a “mongodb” user? Did you change permissions and owner as specified above? Check your /etc/mongodb.conf file for any typos, as well.



      • Gaurav
        Mar 13, 2016 @ 13:20:08

        Thanks Andy, i guess i have made some typo…I deleted and recreated the folders, and all started working good. Thanks for quick replay :).
        The blog was a gr8 help…


  17. AndyS
    Mar 13, 2016 @ 12:30:24

    :/etc $ sudo service mongodb status
    ● mongodb.service – High-performance, schema-free document-oriented database
    Loaded: loaded (/lib/systemd/system/mongodb.service; disabled)
    Active: failed (Result: exit-code) since Sun 2016-03-13 19:27:35 UTC; 4s ago
    Process: 1455 ExecStart=/usr/bin/mongod –quiet –config /etc/mongodb.conf (code=exited, status=14)
    Main PID: 1455 (code=exited, status=14)


  18. andy
    Mar 13, 2016 @ 13:25:54

    AndyS, see my reply above for checking to see if “mongod” is running. If not running check for the “mongod.lock” file in the DB dir. Make sure you always stop mongodb cleanly before system shutdown or reboot. LMK!


  19. AndyS
    Mar 13, 2016 @ 14:29:08

    a reboot did the trick!!

    how do I enable the REST web interface?


    • andy
      Mar 13, 2016 @ 15:24:09

      MongoDB does not have a rich built-in REST interface. There are various libraries (Java, Python, Node.js, etc.) that support REST with full support for CRUD, including insert, update, etc. There IS a MongoDB flag “--rest” for simple REST-like HTTP operations. This support is deprecated in MongoDB 3.2, BTW.

      So, stop mongodb

      sudo service mongodb stop

      and then you can invoke mongodb from the command line:

      sudo -u mongodb mongod --rest --fork --config /etc/mongodb.conf

      check it out from a command line from pi’s home dir:

      more index.html

      OR, use a browser and URL:

      You can check out the docs at

      Hope this helps. ANother use case is to add your external IP address to /etc/mongodb.conf in order to access mongodb external to your Pi.


  20. Ying-Chieh (Jeffrey) Chao
    Mar 14, 2016 @ 05:38:03

    Hi Andy:

    Thanks for your great work! I translated this article into Traditional Chinese and post it here:

    Those two MongoDB binary files are uploaded to Google Drive.



  21. andy
    Mar 14, 2016 @ 11:15:19

    Hi Ying-Chieh (Jeffrey), Very nice! Thanks for sharing.


  22. bilen cekic
    Mar 15, 2016 @ 09:21:49

    d**n man 😀 i did exact steps and now it is working ahahah thank you very much million times.
    it is live on my raspberry pi 3 🙂


  23. Vincent
    Mar 15, 2016 @ 09:36:34

    Hi Andy,
    Nice work, the Binaries seems really huge more than 380 MB for the mongod and 173 Mb for the mongo, it must be with debug symbols ?

    is it normal ?


    • andy
      Mar 15, 2016 @ 22:05:22

      Vincent, I think you are right! 😉 I never ran the full install script when I compiled 3.0.9 — that script would do a “strip”. So… you can do a “strip mongod”, as well as “strip” the other binaries to get the sizes down.

      If you have binaries in /usr/bin:

      sudo strip -p /usr/bin/mong*


  24. Henrik Persson
    Mar 25, 2016 @ 10:57:45

    Thanks a lot!
    Instructions worked like a charm on my new pi 3 running latest version of Jessie.


  25. Michael
    Mar 28, 2016 @ 12:53:04

    Hi Andy,

    I think I followed along your instructions, but when I try to start MongoDB as a service (sudo service mongoldb start) I get the following error: Failed to start mongodb.service: Unit mongodb.service is masked.

    Starting via command line using “sudo -u mongodb /usr/bin/mongod –quiet –config /etc/mongodb.conf” works, though. Any idea what went/is wrong or where to look at?

    Thanks in advance 🙂
    – Michael


    • andy
      Mar 28, 2016 @ 13:05:41

      check the edits to /lib/systemd/system/mongodb.service carefully

      You might try systemctl options: “unmask” as this allows a service to be controlled and “enable” starts the service at boot. Try these:

      sudo systemctl unmask mongodb
      sudo systemctl enable mongodb



  26. Michael
    Mar 28, 2016 @ 23:10:52

    Hi Andy,

    yeeees! 🙂 unmask/enable did the job!
    I think maybe it was because I had mongodb installed via apt-get. Though I did a apt-get remove and apt-get purge and apt-get autoremove in the hope to get rid of everything that was done during installation, maybe something was left behind…

    Thanks for the quick response on the work on getting mongodb work on the Raspberry!

    Cheers, Michael


  27. Steven
    Apr 02, 2016 @ 12:33:33

    Thanks for this – it is working well. Just a couple of questions: How can I get the service to automatically start at boot? Is there a way to have the service automatically stop at shutdown or reboot?

    Thanks again.


    • andy
      Apr 02, 2016 @ 13:03:51

      Steven, see above “enable” answer using “systemctl”. To do auto-start at boot and auto-stop at “reboot” or “shutdown”:

      sudo systemctl enable mongodb


  28. Steven
    Apr 02, 2016 @ 14:11:16

    Excellent! Thanks very much.



  29. Jeff
    Apr 04, 2016 @ 14:09:01

    Hi Andy,
    I am a new r-pi user and new to linux. I have one rpi2 adn one rpi3 both running Jessie. I followed (actaully cut and pasted into the cmd line) this tutorial and the data base appears to funciton. I am able to password into my localhost:8080 webpage and the data gets saved. My question to you. How can I set up mongodb to initiate on reboot? I am right now running a crone job to make this happen.


  30. andy
    Apr 04, 2016 @ 15:36:53

    Jeff, I think I answered this a couple of times 😉 If these work for you:

    sudo service mongodb start
    sudo service mongodb status
    sudo service mongodb stop

    then this will start mongodb at boot and stop at system shutdown &/or reboot:

    sudo systemctl enable mongodb


  31. Filipe
    Apr 13, 2016 @ 05:56:31

    Hi Andy,

    Thanks for the tutorial.
    Besides the link for the mongodb tools i didn’t see a “how to use it” part.
    Do you have it somewhere else or could you please say how do we go about using it?

    Appreciate. 🙂


    • andy
      Apr 14, 2016 @ 11:58:20

      Yes, I never followed-up on instructions for tools 🙁 I’ve now added in the blog entry.


  32. Marcello
    Apr 14, 2016 @ 21:00:44

    You’re a lifesaver. Thanks for doing this!


  33. Walter
    Apr 15, 2016 @ 15:16:07

    How do I install mongodb on a external hard drive?


    • andy
      Apr 15, 2016 @ 15:26:36

      Hi Walter,
      I have my MongoDB data on an external USB drive. No need to “install” MongoDB on the drive but great idea to place data on big, fast storage. Look at the /etc/mongodb.conf file, as mentioned in the post. There is a line:

      dbpath = /var/lib/mongodb

      This line configures where the data directory is. On my R-Pi 3 with USB Drive, I have:

      dbpath = /mnt/usbDrive/mongodb

      Make sure mongodb is stopped before editing the conf file or doing the following commands! I mounted my drive to “/mnt/usbDrive” and created the data dir with:

      sudo mkdir /mnt/usbDrive/mongodb
      sudo chown mongodb:root /mnt/usbDrive/mongodb
      sudo chmod 775 /mnt/usbDrive/mongodb

      Change the “dbpath” in the config file and restart mongodb. This wil create new data (and associated) files. You could also move the log file to the external drive — but that’s a different thing 😉 Also, as the log is in “quiet” mode, not much is written to it unless there are errors.


      • Walter
        Apr 16, 2016 @ 17:09:35

        Thanks for the reply andy.

        I followed the steps you mentioned but when I start mongodb I get Permission denied error. Do you know how to fix this?

        mongodb.service – High-performance, schema-free document-oriented database
        Loaded: loaded (/lib/systemd/system/mongodb.service; disabled)
        Active: failed (Result: exit-code) since Sat 2016-04-16 23:45:20 UTC; 9s ago
        Process: 3389 ExecStart=/usr/bin/mongod –quiet –config /etc/mongodb.conf (code=exited, status=203/EXEC)
        Main PID: 3389 (code=exited, status=203/EXEC)

        Apr 16 23:45:20 WhiteBoxPI systemd[1]: Started High-performance, schema-free document-oriented database.
        Apr 16 23:45:20 WhiteBoxPI systemd[3389]: Failed at step EXEC spawning /usr/bin/mongod: Permission denied
        Apr 16 23:45:20 WhiteBoxPI systemd[1]: mongodb.service: main process exited, code=exited, status=203/EXEC
        Apr 16 23:45:20 WhiteBoxPI systemd[1]: Unit mongodb.service entered failed state.


      • andy
        Apr 16, 2016 @ 18:23:37

        Walter, if you had MongoDB working before moving the data dir to your USB drive, then check permissions on the mount point and mongodb directory. I make my mount point 777 (sudo chmod 777 /mnt/usbDrive) and make the mongodb dir owned by mongodb:root with 775 permissions (sudo chown mongodb:root /mnt/usbDrive/mongodb AND sudo chmod 775 /mnt/usbDrive/mongodb). Also, make sure dbpath (in /etc/mongodb.conf) is pointing to the mongodb dir on the USB drive.

        Another thought. If your drive is formatted as “vfat”, try mounting using this command and then change permissions, etc.

        sudo mount -o umask=0,uid=nobody,gid=nobody /dev/sda1 /mnt/My_USB_Drive

        LMK if that helps. I also sent you an email with more info.


  34. Peter
    Apr 30, 2016 @ 16:51:14

    Hi, thanks for this, really useful. I managed to work my way through and installed it successfully. What I most appreciated is you didn’t give everything a newbie would need. ie how to extract and some other simple things we should know if we want to use Linux. Only way to learn is to have a go yourself :-). Thanks for this very useful guide.


  35. Makoy
    May 02, 2016 @ 02:53:43

    Hi What’s the storage limit of mongodb when running in rpi-2 32 bits and in rpi-3 64bit?


    • andy
      May 02, 2016 @ 09:17:09

      R-Pi 2 and 3 are running 32-bit OS and applications. SO, both the 2 & 3 are currently limited to 2 GB databases. It is possible to run a 64-bit OS on the R-Pi 3 BUT, the MongoDB apps would need to be recompiled in 64-bit mode, for ARM. This would require changes to the build scripts — and possibly source code. I “get around” the 2GB limit by having multiple DBs and querying and combing results via Javascript.


      • Makoy
        May 02, 2016 @ 20:29:43

        Thanks you Andy.


  36. Makoy
    May 03, 2016 @ 03:14:34

    Having problem running mongodb
    ● mongodb.service – High-performance, schema-free document-oriented database
    Loaded: loaded (/lib/systemd/system/mongodb.service; disabled)
    Active: failed (Result: exit-code) since Tue 2016-05-03 18:12:51 PHT; 44s ago
    Process: 1031 ExecStart=/usr/bin/mongod –quiet –config /etc/mongodb.conf (code=exited, status=100)
    Main PID: 1031 (code=exited, status=100)


    • andy
      May 03, 2016 @ 17:54:39

      This error usually means that MongoDb was not shutdown gracefully — i.e. with a “sudo service mongodb stop” or system was not shutdown with “sudo shutdown” or “sudo reboot” after service was “enabled”. Take a look at your data directory and see if there is a “lock” file. If the data dir is “/var/lib/mongodb”, look for mongod.lock. If present, delete it, “sudo rm /var/lib/mongodb/mongod.lock” – and then try to start the mongodb service. Look in above comments for how to set auto-start and auto-stop using, “sudo systemctl enable mongodb”.


  37. RabAusten
    Jun 02, 2016 @ 14:41:33

    Followed all instructions, to the letter and it installed and runs perfectly, first time. Many thanks!


  38. Jason
    Jun 05, 2016 @ 19:22:27

    Just want to say that I followed the instructions, exactly and it ran just fine on my Raspberry Pi 3, with the latest Raspbian (Jessie) OS. Thanks a bunch!


  39. Cristiano
    Jul 01, 2016 @ 06:58:35

    Hello Andy, great job.
    I followed your instructions, and all seems working well, but…

    I created a test db, with a test collection. I created two simple indexes, each on a field (db.getCollection(‘test’).createIndex({dev_TS:1}), db.getCollection(‘test’).createIndex({pname:1})). Then I filled it with some data (test data are in

    Mongo stops working after querying (At 2016-07-01T15:34:03): db.getCollection(‘test’).find({dev_TS : { “$gte” : 0 }}).

    Final part of mongodb log is

    2016-07-01T14:46:07.490+0200 I CONTROL ***** SERVER RESTARTED *****
    2016-07-01T14:46:07.523+0200 I CONTROL [initandlisten] MongoDB starting : pid=16159 port=27017 dbpath=/var/lib/mongodb 32-bit host=raspberrypi
    2016-07-01T14:46:07.523+0200 I CONTROL [initandlisten] db version v3.0.9
    2016-07-01T14:46:07.523+0200 I CONTROL [initandlisten] git version: 20d60d3491908f1ae252fe452300de3978a040c7
    2016-07-01T14:46:07.523+0200 I CONTROL [initandlisten] build info: Linux PlusBerryPi 4.1.13-v7+ #826 SMP PREEMPT Fri Nov 13 20:19:03 GMT 2015 armv7l BOOST_LIB_VERSION=1_49
    2016-07-01T14:46:07.523+0200 I CONTROL [initandlisten] allocator: tcmalloc
    2016-07-01T14:46:07.523+0200 I CONTROL [initandlisten] options: { config: “/etc/mongodb.conf”, net: { bindIp: “” }, replication: { replSet: “aurora” }, storage: { dbPath: “/var/lib/mongodb”, engine: “mmapv1”, journal: { enabled: true } }, systemLog: { destination: “file”, logAppend: true, path: “/var/log/mongodb/mongodb.log”, quiet: true } }
    2016-07-01T14:46:07.657+0200 W – [initandlisten] Detected unclean shutdown – /var/lib/mongodb/mongod.lock is not empty.
    2016-07-01T14:46:07.711+0200 I JOURNAL [initandlisten] journal dir=/var/lib/mongodb/journal
    2016-07-01T14:46:07.712+0200 I JOURNAL [initandlisten] recover begin
    2016-07-01T14:46:07.712+0200 I JOURNAL [initandlisten] recover lsn: 915200
    2016-07-01T14:46:07.712+0200 I JOURNAL [initandlisten] recover /var/lib/mongodb/journal/j._0
    2016-07-01T14:46:07.721+0200 I JOURNAL [initandlisten] recover skipping application of section seq:0 < lsn:915200
    2016-07-01T14:46:07.722+0200 I JOURNAL [initandlisten] recover skipping application of section seq:796300 < lsn:915200
    2016-07-01T14:46:07.722+0200 I JOURNAL [initandlisten] recover skipping application of section seq:855743 < lsn:915200
    2016-07-01T14:46:07.785+0200 I JOURNAL [initandlisten] recover cleaning up
    2016-07-01T14:46:07.785+0200 I JOURNAL [initandlisten] removeJournalFiles
    2016-07-01T14:46:08.115+0200 I JOURNAL [initandlisten] recover done
    2016-07-01T14:46:08.115+0200 I JOURNAL [initandlisten] preallocating a journal file /var/lib/mongodb/journal/prealloc.0
    2016-07-01T14:46:11.440+0200 I – [initandlisten] File Preallocator Progress: 115343360/268435456 42%
    2016-07-01T14:46:22.038+0200 I – [initandlisten] File Preallocator Progress: 136314880/268435456 50%
    2016-07-01T14:46:25.171+0200 I – [initandlisten] File Preallocator Progress: 220200960/268435456 82%
    2016-07-01T14:46:28.750+0200 I – [initandlisten] File Preallocator Progress: 241172480/268435456 89%
    2016-07-01T14:46:38.443+0200 I – [initandlisten] File Preallocator Progress: 251658240/268435456 93%
    2016-07-01T14:46:46.776+0200 I JOURNAL [durability] Durability thread started
    2016-07-01T14:46:46.777+0200 I JOURNAL [journal writer] Journal writer thread started
    2016-07-01T14:46:46.802+0200 I CONTROL [initandlisten]
    2016-07-01T14:46:46.802+0200 I CONTROL [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
    2016-07-01T14:46:46.802+0200 I CONTROL [initandlisten] ** 32 bit builds are limited to less than 2GB of data (or less with –journal).
    2016-07-01T14:46:46.803+0200 I CONTROL [initandlisten] ** See
    2016-07-01T14:46:46.803+0200 I CONTROL [initandlisten]
    2016-07-01T14:46:46.920+0200 I NETWORK [initandlisten] waiting for connections on port 27017
    2016-07-01T14:46:46.923+0200 I REPL [ReplicationExecutor] New replica set config in use: { _id: "aurora", version: 1, members: [ { _id: 0, host: "raspberrypi:27017", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 } ], settings: { chainingAllowed: true, heartbeatTimeoutSecs: 10, getLastErrorModes: {}, getLastErrorDefaults: { w: 1, wtimeout: 0 } } }
    2016-07-01T14:46:46.924+0200 I REPL [ReplicationExecutor] This node is raspberrypi:27017 in the config
    2016-07-01T14:46:46.924+0200 I REPL [ReplicationExecutor] transition to STARTUP2
    2016-07-01T14:46:46.924+0200 I REPL [ReplicationExecutor] Starting replication applier threads
    2016-07-01T14:46:46.925+0200 I REPL [ReplicationExecutor] transition to RECOVERING
    2016-07-01T14:46:46.926+0200 I REPL [ReplicationExecutor] transition to SECONDARY
    2016-07-01T14:46:46.926+0200 I REPL [ReplicationExecutor] transition to PRIMARY
    2016-07-01T14:46:47.939+0200 I REPL [rsSync] transition to primary complete; database writes are now permitted
    2016-07-01T15:34:03.510+0200 F – [conn17] Invalid access at address: 0x69942fef
    2016-07-01T15:34:03.569+0200 F – [conn17] Got signal: 7 (Bus error).
    [… many mor lines, here]
    Test data are in
    Is it happening only to me?
    Thank you for your work


    • andy
      Jul 17, 2016 @ 13:24:12

      Wow! Several things going on here. You have a left-over lock file that needs to be removed. Seems like you have a replication set configured but not used? I believe that is your main issue. Check you /etc/mongodb.conf file. Did you mean to use replication? Where/what are primary versus secondary? Are you trying to run multiple mongoldb instances on your R-Pi? There is not enough RAM to do that 🙁




      • Cristiano
        Aug 02, 2016 @ 05:41:12

        Hello Andy,
        excuse me for delay.
        I am using replication without secondary to use oplog as a notifier (like meteor does), my mongodb.conf has only two differences from default file: replSet = replica_name and bind_ip = (obviously I started replica set with rs.initiate() on mongo console). And only one instance of mongod, of course.
        This is the configuration I use on PC, and it works. Is there anything wrong about this configuration?
        Thank you and please forgive my english.


        • andy
          Aug 02, 2016 @ 13:39:02

          Cristiano, have you tried simplifying? Don’t use replication — and see how that works. Use bind_ip = in conf file. Can you use mongoimport to load your test json file? Are you connecting locally or remotely? Can you use mongo shell with or without your replication set-up? Maybe email me your complete error log? I have experienced some bus-errors when my DBs have gotten close to 2GB but that doesn’t seem to be your issue?



          • Cristiano
            Aug 04, 2016 @ 07:48:37

            Hi Andy, thank you for your support.
            Simplifying, i did these activities:
            * sudo service mongodb stop
            * sudo rm -r /var/log/mongodb/*
            * sudo rm -r /var/lib/mongodb/*
            * sudo removed replSet instruction from /etc/mongodb.conf
            * sudo service mongodb start
            * [wait until mongodb worked]
            * mongoimport –db test –collection test –file testData.json
            * mongo [run mongo console, next steps from mongo console]
            ** use test
            ** db.getCollection(“test”).createIndex({dev_TS:1})
            ** db.getCollection(“test”).createIndex({pname:1})
            ** db.getCollection(“test”).find({dev_TS : { “$gte” : 0 }})

            After last instruction mongodb stopped working. You can find testData.json, mongodb.conf and mongodb.log in
            Hope this helps, thank you for your time,

          • andy
            Aug 05, 2016 @ 12:26:07

            Cristiano, this is a bug/issue. I tried to create the index on your field, “dev_TS” and get the seg-fault. I believe the problem is creating an index on a (long, complex) floating-point number. The MongoDB docs have a strong warning about this:

            MongoDB hashed indexes truncate floating point numbers to 64-bit integers before hashing. For example, a hashed index would store the same value for a field that held a value of 2.3, 2.2, and 2.9. To prevent collisions, do not use a hashed index for floating point numbers that cannot be reliably converted to 64-bit integers (and then back to floating point). MongoDB hashed indexes do not support floating point values larger than 253.

            SO, I suggest NOT using an index on these values! Sorry 🙁

          • Cristiano
            Aug 22, 2016 @ 02:57:40

            Thank you Andy, you are great!
            Excuse for delay, my holidays just finished yesterday.
            Yes, it seems being due to a bug on floating point fields indexes. Anyway, the warning you report refers to hashed indexes, but I created a simple index, and I did not expect that aspect being involved.
            Thank you again, at least I can try to set up a workaround.

  40. Manuel
    Jul 30, 2016 @ 12:55:55

    Hi andy!
    Thanks you so much for your help! It saves me a lot of time!
    I have a question for you… I need to use mongoimport with “–ssl” option.
    I find that mongo 3.0 supports this option but it isn’t valid when I try to run it on your compilation. If I run mongoimport –help I can’t see this flag.
    I have found that it is necessary to compile it with this option, but I’m not sure if it is necessary at this version.
    Do you know anything about it?

    Thanks you so much!


    • andy
      Jul 31, 2016 @ 13:22:29

      Hi Manuel, I did not originally compile the MongoDB tools with the “ssl” flag. This makes the executables much larger and is generally (IMHO) not used. I have now compiled the MongoDB 3.0.9 tools with the SSL flag and have uploaded. You can find these (including bsondump which I did not include, before) here — in a zipped file. I have only compiled them, checked the version and the “–help” flag to see that the SSL option is available. I have not extensively tested. Please LMK if these work for you.



  41. Manuel
    Aug 01, 2016 @ 03:44:27

    Hi again Andy!

    Thanks you so much! You are very fast men! =)
    I have tested mongoimport and it works like a charm!
    Help options are ok now also!!

    Thanks you very much again!


  42. Carl
    Aug 11, 2016 @ 20:43:12

    I have installed your binaries thanks for the work you have put in.

    I am trying to switch database storage engine over to wiredTiger as its more memory efficient but it appears to not be supported. My mongodb log outputs

    2016-08-12T13:40:21.863+1000 I CONTROL [initandlisten] options: { config: “/etc/mongodb.conf”, storage: { dbPath: “/diska/mongodb”, engine: “wiredTiger” }, systemLog: { destination: “file”, logAppend: true, path: “/var/log/mongodb/mongod.log”, quiet: true } }
    2016-08-12T13:40:21.996+1000 I STORAGE [initandlisten] exception in initAndListen: 18656 Cannot start server with an unknown storage engine: wiredTiger, terminating

    Any plans on including wiredTiger support in future binaries?


    • andy
      Aug 12, 2016 @ 10:27:54

      Hi Carl, currently WiredTiger only compiles for Intel processor 🙁 No chance for an ARM version unless something major changes with source. That’s why “mmapv1” is explicitly set as database storage engine. I just discovered “Percona Memory Engine for MongoDB” that seems to be Open Source. I need to investigate!



      • andy
        Aug 27, 2016 @ 09:40:45

        The Percona Engine is based on WiredTiger. Not happening on ARM any time soon 🙁


      • Oliver
        Sep 03, 2016 @ 07:00:15

        As per this MongoDB JIRA issue it seams, that there is an early 64bit MongoDB release available for ARMv8 now. Does anybody tried it already on the Raspberry Pi? To me it sounds like it should now be possible to run MongoDB 3.3.11+ on a Raspberry Pi 3 with Ubuntu 16.04 arm64 installed. Can anybody confirm this, because I doesn’t have a R-Pi 3. Also WiredTiger should be explicitly supported.


  43. Rick
    Sep 13, 2016 @ 02:22:58

    Hi Andy,
    Thanks for your work.
    I have just one question : binary 3.0.9 that you delivery here is 32 or 64 bits ?
    Kind regards


    • andy
      Sep 13, 2016 @ 08:48:35

      Rick, binaries are 32-bit under Jessie OS. R-Pi does not yet have a supported 64-bit boot/OS. Also you need a Pi 2 or Pi 3 to run.


      • Rick
        Sep 14, 2016 @ 08:07:09

        Hi Andy,
        Thank you for answers.
        I can explain the context.
        We have built a platform, based on raspberry, to put applications in betâ test.
        On Dev environment we have mongodb 3.2 running in 64 bits.
        The community is not very sure that is a good idea to compile rapsbian in 64 bits
        So we think that it will be great to benefit a low cost platform like pi 3 to test applications especially if there are built around MongoDB
        Yho! You know the entire story … 😃


        • andy
          Sep 14, 2016 @ 10:12:37

          Hey Rick – what boot and OS are you using for R-Pi 3 64-bit? There is a new (official but not yet supported) MongoDB build 3.3.x (Beta) running under Ubuntu Mate that you might try? I.e. get the “deb” package and try an install? If you can point me to instructions on how to create the 64-bit environment, I could try it out?

          – Andy


          • Rick
            Sep 15, 2016 @ 08:40:17

            Hi Andy,

            it’s really nice of you to be interested in our problem. in fact we’re not sure what we will install distribution, maybe do you have any idea about it?
            Dev are started since few months, with MomgoDb 3.2.2 , and we want to ovoid to downgrade this.

  44. Lewis Chan
    Dec 07, 2016 @ 01:06:06

    Thanks, well done. I success to use your instruction to install mongodb in my nanoPI M2 !


    • andy
      Dec 07, 2016 @ 08:39:49

      Lewis, Thanks for letting me know about nanoPi M2 compatibility.


  45. Onkar
    Dec 26, 2016 @ 01:22:45

    This is error I ma getting. Please help me out.


    root@pi:/etc# sudo service mongodb status
    ● mongodb.service – High-performance, schema-free document-oriented database
    Loaded: loaded (/lib/systemd/system/mongodb.service; disabled)
    Active: failed (Result: exit-code) since Thu 2016-12-22 09:27:06 UTC; 22min ago
    Process: 4775 ExecStart=/usr/bin/mongod –quiet –config /etc/mongodb.conf (code=exited, status=217/USER)
    Main PID: 4775 (code=exited, status=217/USER)

    Dec 22 09:27:06 pi systemd[1]: Started High-performance, schema-free docume…e.
    Dec 22 09:27:06 pi systemd[1]: mongodb.service: main process exited, code=e…ER
    Dec 22 09:27:06 pi systemd[1]: Unit mongodb.service entered failed state.
    Hint: Some lines were ellipsized, use -l to show in full.


  46. Onkar
    Dec 26, 2016 @ 01:52:31

    I am getting following error,please help me out:

    pi@pi:~ $ sudo -i
    root@pi:~# cd /etc
    root@pi:/etc# sudo service mongodb start
    root@pi:/etc# sudo service mongodb status
    ● mongodb.service – High-performance, schema-free document-oriented database
    Loaded: loaded (/lib/systemd/system/mongodb.service; disabled)
    Active: failed (Result: exit-code) since Thu 2016-12-22 10:12:47 UTC; 3s ago
    Process: 1217 ExecStart=/usr/bin/mongod –quiet –config /etc/mongodb.conf (code=exited, status=217/USER)
    Main PID: 1217 (code=exited, status=217/USER)

    Dec 22 10:12:47 pi systemd[1]: Started High-performance, schema-free docume…e.
    Dec 22 10:12:47 pi systemd[1]: mongodb.service: main process exited, code=e…ER
    Dec 22 10:12:47 pi systemd[1]: Unit mongodb.service entered failed state.
    Hint: Some lines were ellipsized, use -l to show in full.


    • andy
      Dec 26, 2016 @ 09:10:45

      Onkar, see if you can run mongod directly (i.e. not using “service”), try:
      sudo -u mongodb /usr/bin/mongod --quiet --config /etc/mongodb.conf

      IF that works, review the section in the post on creating the service configuration file and try:
      sudo systemctl unmask mongodb
      sudo systemctl enable mongodb


  47. Onkar
    Dec 26, 2016 @ 21:15:16

    Thanks Andy. Now it is working fine. I have simple application. I need to read RFID tag and display on console. I have to store RFID data on Mongodb. Can anyone please help me out?


Leave a Reply