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: I have compiled version 3.0.14 and created binaries for Raspbian Jessie for the R-Pi 2 & 3. NEW: I have also created 3.0.14 binaries for the R-Pi 3 running Raspbian Stretch that will also work on the new R-Pi 3B+. I have confirmed that the instructions in this blog entry work with the new binaries.]
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
contains:
- 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
contains:
- 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
UPDATE (18 Mar 2017) You can find MongoDB 3.0.14 binaries in this post
QUICK SETUP INSTRUCTIONS:
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 = 127.0.0.1 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:
[Unit] Description=High-performance, schema-free document-oriented database After=network.target [Service] User=mongodb ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf [Install] WantedBy=multi-user.target
– you are now ready to launch mongodb!
sudo service mongodb start
UPDATE NOTE from Thomas [Thanks!] about latest Raspbian images lacking a needed SSL library!
If you see error status code = 127 This is a libssl1.0.0 error, so you need to reinstall this library to do it: sudo wget http://ftp.nl.debian.org/debian/pool/main/o/openssl/libssl1.0.0_1.0.1e-2%2Bdeb7u20_armhf.deb sudo dpkg -i libssl1.0.0_1.0.1e-2+deb7u20_armhf.deb then run this command: /usr/bin/mongod –version You should see both a DB version (3.0.9) and Git version. If so, you are ready to go...
– check status
sudo service mongodb status
– MAKE SURE YOU SHUTDOWN CLEANLY!
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.
Pingback: MongoDB 3.0.7 on Raspberry Pi 2!
Pingback: MongoDB on the Raspberry Pi 2
Hi Andy! Thanks a lot for this binaries, they are perfect, very usefull 🙂
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 127.0.0.1:27017”
The mongodb is started by user “mongodb” and node app is started by user “pi”
Any idea?
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.
Hi,
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!
Joe
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
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!
Joe,
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
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
Thanks!!!
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
When i run the MongoDB shell it gives the “Failed global initialization” any help ? Thanks
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
Thanks “export LC_ALL=C” did the magic
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
—– BEGIN BACKTRACE —–
{“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]
libc.so.6(__default_rt_sa_restorer_v2+0x0) [0xb6a951a0]
—– END BACKTRACE —–
Can you help?
I am running a raspy with jessie.
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
LMK!
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?
Cheers
AndyS
Quick Solution….I upgraded to a Pi 2
Thanks Anyway
Andys
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 127.0.0.1:27017, reason: errno:111 Connection refused
2016-03-13T19:17:56.613+0000 E QUERY Error: couldn’t connect to server 127.0.0.1:27017 (127.0.0.1), 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?
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”?
Hi,
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.
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.
LMK!
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…
:/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)
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!
a reboot did the trick!!
how do I enable the REST web interface?
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:
wget http://127.0.0.1:28017/local/startup_log/
more index.html
OR, use a browser and URL:
http://127.0.0.1:28017/local/startup_log
You can check out the docs at mongodb.org
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.
Pingback: 在Raspberry Pi 2代和3代(Jessie版Raspbian系統)安裝MongoDB 3.0.9 - 網昱多媒體
Hi Andy:
Thanks for your great work! I translated this article into Traditional Chinese and post it here: http://swf.com.tw/?p=833
Those two MongoDB binary files are uploaded to Google Drive.
Thanks!
Jeffrey
Hi Ying-Chieh (Jeffrey), Very nice! Thanks for sharing.
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 🙂
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 ?
Vincent
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*
Thanks a lot!
Instructions worked like a charm on my new pi 3 running latest version of Jessie.
/Henrik
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
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
LMK!
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
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.
Steven, see above “enable” answer using “systemctl”. To do auto-start at boot and auto-stop at “reboot” or “shutdown”:
sudo systemctl enable mongodb
Excellent! Thanks very much.
Steven
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.
Cheers,
Jeff
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
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. 🙂
Yes, I never followed-up on instructions for tools 🙁 I’ve now added in the blog entry.
You’re a lifesaver. Thanks for doing this!
How do I install mongodb on a external hard drive?
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.
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.
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
ANDsudo 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.
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.
Hi What’s the storage limit of mongodb when running in rpi-2 32 bits and in rpi-3 64bit?
Thanks.
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.
Thanks you Andy.
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)
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”.
Followed all instructions, to the letter and it installed and runs perfectly, first time. Many thanks!
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!
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 https://drive.google.com/folderview?id=0B0TGibzk2B-VOWRYWlZwUjJBMkk&usp=sharing).
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: “0.0.0.0” }, 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 http://dochub.mongodb.org/core/32bit
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 https://drive.google.com/folderview?id=0B0TGibzk2B-VOWRYWlZwUjJBMkk&usp=sharing
Is it happening only to me?
Thank you for your work
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 🙁
LMK,
Andy
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 = 0.0.0.0 (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.
Cristiano, have you tried simplifying? Don’t use replication — and see how that works. Use bind_ip = 0.0.0.0 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?
Andy
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 https://drive.google.com/folderview?id=0B0TGibzk2B-VOWRYWlZwUjJBMkk&usp=sharing
Hope this helps, thank you for your time,
Cristiano
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:
WARNING
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 🙁
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.
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!
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.
Andy
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!
Hi
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?
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
The Percona Engine is based on WiredTiger. Not happening on ARM any time soon 🙁
As per this MongoDB JIRA issue https://jira.mongodb.org/browse/SERVER-1811 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.
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
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.
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
Maybe…
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 … ?
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
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.
Thanks, well done. I success to use your instruction to install mongodb in my nanoPI M2 !
Lewis, Thanks for letting me know about nanoPi M2 compatibility.
This is error I ma getting. Please help me out.
Error:
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.
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.
root@pi:/etc#
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
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?
Andy. Thanks it looks very informative and easy to follow. I have a question if you will permit….
I only need mongo to “play with” as part of a course assessment so I don;t need huge storage but I want to use an old Pi 2 for this install with an 8Gb SD card, is this enough for it?
The Pi in question already has mysql on it – in fact the assessment will be comparing the two – so will they clash or coexist together on it do you know?
Steve, MySQL and MongoDB will happily co-reside as they use different ports and/or sockets. I would recommend Raspbian Lite for an 8GB SD card as full-blown Raspbian and MySQL with moderate amounts of data and associated logs will take up space — or, use a larger SD card 😉
Thats very helpful, thanks
Andy
I think I have followed the instructions and loaded the software onto a Raspberry2 (with Jessie) and 16Gb SD card
The status looks ok when I start mongo but when I run “mongo” from a separate terminal window I get the following, with a lot more after the BACKTRACE. Any suggestions for tracking down where I have gone wrong would be gratefully accepted.
MongoDB shell version: 3.0.9
2017-01-30T21:57:11.071+0000 F – Invalid operation at address: 0x3a523b58
2017-01-30T21:57:11.117+0000 F – Got signal: 4 (Illegal instruction).
0x49e854 0x49df6c 0x49e35c 0xb6a1b1a0
—– BEGIN BACKTRACE —–
Andy
I think I have followed the instructions and loaded the software onto a Raspberry2 (with Jessie) and 16Gb SD card
The status looks ok when I start mongo but when I run “mongo” from a separate terminal window I get the following, with a lot more after the BACKTRACE. Any suggestions for tracking down where I have gone wrong would be gratefully accepted.
MongoDB shell version: 3.0.9
2017-01-30T21:57:11.071+0000 F – Invalid operation at address: 0x3a523b58
2017-01-30T21:57:11.117+0000 F – Got signal: 4 (Illegal instruction).
Andy
I think I have followed the instructions and loaded the software onto a Raspberry2 (with Jessie) and 16Gb SD card
The status looks ok when I start mongo but when I run “mongo” from a separate terminal window I get the following, with a lot more after the BACKTRACE. Any suggestions for tracking down where I have gone wrong would be gratefully accepted.
-MongoDB shell version: 3.0.9
-2017-01-30T21:57:11.071+0000 F – Invalid operation at address: 0x3a523b58-
-2017-01-30T21:57:11.117+0000 F – Got signal: 4 (Illegal instruction).
Andy
I think I have followed the instructions and loaded the software onto a Raspberry2 (with Jessie) and 16Gb SD card
The status looks ok when I start mongo but when I run “mongo” from a separate terminal window I get the following, with a lot more after the BACKTRACE. Any suggestions for tracking down where I have gone wrong would be gratefully accepted.
-MongoDB shell version: 3.0.9
Invalid operation at address: 0x3a523b58-
Got signal: 4 (Illegal instruction).
Whoops, sorry about the multiple postings…..
Seems what I thought was a Pi2 with armv71 was actually a “61” so it never had a chance. Sorted now on a newer Pi. Thanks
//I followed every instruction and successfully installed mongodb on my //raspberry pi 2.
//Then i did a clean shutdown .
//rebooted a day later and i when i tried to start mongodb:
pi@raspberrypi:~ $ mongo
MongoDB shell version: 3.0.9
connecting to: test
2017-02-04T21:59:17.881+0300 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2017-02-04T21:59:17.901+0300 E QUERY Error: couldn’t connect to server 127.0.0.1:27017 (127.0.0.1), 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
////////////////////////
//This happend!
//Then i tried this:
pi@raspberrypi:~ $ sudo service mongodb status
● mongodb.service
Loaded: loaded (/lib/systemd/system/mongodb.service)
Active: failed (Result: exit-code) since Sat 2017-02-04 21:59:12 EAT; 13s ago
Process: 3590 ExecStart=/usr/bin/mongod –quiet –config /etc/mongodb.conf (code=exited, status=14)
Main PID: 3590 (code=exited, status=14)
Feb 04 21:59:11 raspberrypi systemd[1]: Started mongodb.service.
Feb 04 21:59:11 raspberrypi mongod[3590]: 2017-02-04T21:59:11.856+0300 I CONTROL
Feb 04 21:59:11 raspberrypi mongod[3590]: 2017-02-04T21:59:11.857+0300 W CONTROL 32-bit servers don’t ha…lity.
Feb 04 21:59:11 raspberrypi mongod[3590]: 2017-02-04T21:59:11.857+0300 I CONTROL
Feb 04 21:59:12 raspberrypi systemd[1]: mongodb.service: main process exited, code=exited, status=14/n/a
Feb 04 21:59:12 raspberrypi systemd[1]: Unit mongodb.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.
Now when i open the log file:
2017-02-03T18:54:44.667+0000 I CONTROL [initandlisten] MongoDB starting : pid=4229 port=27017 dbpath=/var/lib/mongodb 32-bit host=raspberrypi
2017-02-03T18:54:44.668+0000 I CONTROL [initandlisten] db version v3.0.9
2017-02-03T18:54:44.668+0000 I CONTROL [initandlisten] git version: 20d60d3491908f1ae252fe452300de3978a040c7
2017-02-03T18:54:44.668+0000 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
2017-02-03T18:54:44.668+0000 I CONTROL [initandlisten] allocator: tcmalloc
2017-02-03T18:54:44.668+0000 I CONTROL [initandlisten] options: { config: “/etc/mongodb.conf”, net: { bindIp: “127.0.0.1” }, storage: { dbPath: “/var/lib/mongodb”, engine: “mmapv1” }, systemLog: { destination: “file”, logAppend: true, path: “/var/log/mongodb/mongod.log”, quiet: true } }
[….] *** removed to make log easier to read – AF
2017-02-04T21:33:38.976+0300 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2017-02-04T21:33:38.976+0300 I – [initandlisten] Fatal Assertion 28578
2017-02-04T21:33:38.977+0300 I – [initandlisten]
***aborting after fassert() failure
I cannot tell you enough, how great-full i am for helping all of us newbies install mongodb on our little supercomputers .
Have a great Day.
Tayyab, looks like mongod was run by 2 different users at different times – resulting in the temp socket having wrong owner or permissions. Try “sudo rm /tmp/mongodb-27017.sock” and then do a “sudo service mongodb start”. Check to make sure you created the “mongodb” user correctly.
Thanks, that solved it . hurrahh!!
i know i can google it, but since this isn’t a conventional mongodb install , can you help me install php driver for mongodb. I have already installed php and apache 2.
(PHP Version 5.6.29-0+deb8u1)
thanks for replying so soon.
hiii This is use ful but i got this error
pi@raspberrypi:~ $ sudo service mongodb start
pi@raspberrypi:~ $ 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 Mon 2017-02-06 18:35:53 UTC; 5s ago
Process: 3544 ExecStart=/usr/bin/mongod –quiet –config /etc/mongodb.conf (code=exited, status=2)
Main PID: 3544 (code=exited, status=2)
Feb 06 18:35:53 raspberrypi systemd[1]: Started High-performance, schema-fre….
Feb 06 18:35:53 raspberrypi mongod[3544]: Error parsing INI config file: unr…’
Feb 06 18:35:53 raspberrypi mongod[3544]: try ‘/usr/bin/mongod –help’ for m…n
Feb 06 18:35:53 raspberrypi systemd[1]: mongodb.service: main process exited…T
Feb 06 18:35:53 raspberrypi systemd[1]: Unit mongodb.service entered failed ….
Hint: Some lines were ellipsized, use -l to show in full.
[…..] *********** lines removed by Andy for clarity
Plllzzzzzzzzzzzzzzzzz tel me where is a problem
Sandeep, a couple of possibilities:
1) check the edits to /lib/systemd/system/mongodb.service carefully AND make sure you setup user, “mongodb” correctly.
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
2) Check contents and permissions of /etc/mongodb.conf (read instruction in blog entry)
3) try running “mongod” standalone:
sudo -u mongodb mongod --fork --config /etc/mongodb.conf
Hi Andy:
Thank you for allowing me to use your mongodb 3.0.9 binaries, I was very impressed and save me lots of time and stress.
The install on the raspberry pi 2 & 3 was flawless. However I could not get the
user authentication working. This may be off topic, have you ever setup
validation credentials and validated to a database and a collection? I can
connect, but am refused any CRUD functions.
The following is the code I have been using.
private async void button1_Click(object sender, EventArgs e)
{
mongoCredential = MongoCredential.CreateMongoCRCredential(“MongoDB”, “stan”, “7vT62Xrb”);
mongoClientSettings = new MongoClientSettings
{
Credentials = new[] { mongoCredential },
Server = new MongoServerAddress(“192.168.1.28”, 27017)
};
mongoClient = new MongoClient(mongoClientSettings);
mongoDatabase = mongoClient.GetDatabase(“users”);
var mongoCollection = mongoDatabase.GetCollection(“Users”);
var filter = new BsonDocument();
var count = 0;
/* Following code throws authentication exception. */
using (var cursor = await mongoCollection.FindAsync(filter))
{
while (await cursor.MoveNextAsync())
{
var batch = cursor.Current;
foreach (var document in batch)
{
// process document
count++;
}
}
}
EXECPTION:
opening a connection to the server. —> MongoDB.Driver.MongoAuthenticationException: Unable to authenticate username ‘stan’ on database ‘MongoDB’. —> MongoDB.Driver.MongoCommandException: Command authenticate failed: auth failed.
Hi Stan,
Looks like you are trying to use MongoDB 3.4 security features on the MongoDB 3.0.9 version? The connection class “MongoClient” was introduced in 3.4, I believe? Take a look at the MongoDB 3.0 docs for “Users and Roles”. Working with the mongo shell, I can create a user and use authentication. LMK if this does not make sense to you?
– Andy
Andy thanks for your prompt reply. I also can authenticate a user to a database using the mongo shell. The problem authenticating with VS 2015 does not seem to work.
I am going to try using MONGODB-CR instead of the default SCRAM-SHA-1. Let you know if I get it working.
Hi,
tried a Docker installation on RaspberryPi 3 Modell B for MongoDB with 3.4.2 (which supports ARM)
See Dockerfile below … should be all ARM and no x86 code but unfortunately after the build is completet and a container is started with:
docker run –restart=always -d \
–name mongo-sandbox \
-p 27017:27017 \
-v /mnt/lacie/docker-data/mongo-databases:/data/db \
mongodb-rpi:latest
I still get an
standard_init_linux.go:178: exec user process caused “exec format error”
Any help / advice would be appreciated
Thanks
Harald
[…] — Andy deleted messages
Harald, Looks like you are trying to run 64-bit MongoDB 3.4 on a 32-bit version of Docker & Linux (Ubuntu 16.0.4). Won’t work 🙁 You can find a 32-bit MongoDB 3.0.9 for Raspbian on this blog 😉
– Andy
Hi Andy.
Thanks for sharing your mongodb builds for ARM.
It’s a real pity that the RasPi foundation doesn’t enforce 64 bit. I mean, we could really use a 64 bit version of raspbian…
Too bad that mongodb stopped supporting 32 bit since they’ve moved to 3.4.x…
You and your 3.0.9 – ARM 32 bit build of MongoDB are a real life saviour.
I wonder if we could persuade you to build a new version based on 3.0.14 or even, who knows, based on 3.2.12.
What do you think? 😉
Thanks in advance.
Cheers
Hi, IIRC building 3.2 needed a new Javascript engine that was propblematic to build on R-Pi. I believe I could build 3.0.14. I’ll look around for my old scripts and recipe 😉
Thanks, Andy. 🙂
Binaries for MongoDB 3.0.14 are available: http://andyfelong.com/2017/03/mongodb-3-0-14-binaries-for-raspberry-pi-3/ — 18 Mar 2017
Pingback: MongoDB 3.0.14 binaries for Raspberry Pi 3
Thanks a bunch, Andy.
We’ll make good use of it.
Cheers mate.
Awesome job! Thanks for the binaries. Have you asked the MongoDB people for help in building these?
Jorge, I haven’t asked the MongoDB folks to help with my builds as their focus is elsewhere (Atlas, cloud hosting, big DBs, etc.). They ARE supporting ARM with the latest versions (3.4+), though. Of course you need 64-bit Linux 😉 I think that Raspberry Pi will get an officially supported 64-bit Raspbian (or something besides SUSE) – soon, I hope.
Great tutorial. I have installed version 3.0.14 and everything works fine. Thank you for sharing!
you can try this below command
$> sudo apt-get install mongodb
Doing “sudo apt-get install mongodb” will install version 2.4 of MongoDB — i.e. OLD version 😉 You can install version 3.0.14 using my instructions and binaries. There are significant feature additions to version 3 🙂
Hi Andy,
I noticed that the instructions for mongodb tools do not move ‘bsondump’ to /usr/bin.
Hope it helps,
Andrea
Hi Andy,
Thank you for the great tutorial. It took me a couple of tries to get it running. I found all the answers i needed in your support of other people’s issues. This is a great way to get hands on experience with Mongo and Linux.
Regards,
Jason
Pingback: MongoDB 3.0.14 for Raspbian Stretch
Andy – Superb site, great content! I particular like the radio application 🙂 Quick question – was there a specific reason why your complied mongodb binaries were tested only on r-Pi 2 and 3? Will the binaries work on r-Pi (4.9.35+, armv6l)?
Regards,
Graeme
Graeme, my binaries were created using “armv7l” flags. There is some assembly code linked in that requires armv7l architecture for the V8-3.25 javascript engine. So, the binaries here, only work on Raspberry Pi 2 and 3. You can do an “apt-get install mongodb” to get mongodb 2.4.14 (I believe). The repository version runs on the Raspberry Pi 1st gen and Zero (armv6). — Andy
Thanks Andy, it’s appreciated.
Andy – this is a great deal of information on this topic. Is there a way for me to get the latest mon(3.2x or 3.4x) on pi3?
MongoDB 3.2 and above need 64-bit OS support 🙁 Raspbian is 32-bit.
Thanks Andy. Very useful.
Hi Andy,
Thank you very much for doing this.
I’ve just one question related to the config file,
it is possible to use YAML? And in any case in the format you used how can I enable Jouranl
I tried Journal = true but it seems not working,
Thanks in advance,
Andrea, have you tried the flag, “
--journal
” — launching mongod from the command line? LMK if that works for you…Pingback: Raspberry PI 3にMongoDB 3.xを入れる | よっしーネット
Hello!
Hmm, I followed the instructions to the letter and I’m getting this error:
mongodb.service – High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2018-06-04 02:05:54 EDT; 4s ago
Process: 682 ExecStart=/usr/bin/mongod –quiet –config /etc/mongodb.conf (code=exited, status=127)
Main PID: 682 (code=exited, status=127)
Jun 04 02:05:54 rpi systemd[1]: Started High-performance, schema-free document-oriented database.
Jun 04 02:05:54 rpi systemd[1]: mongodb.service: Main process exited, code=exited, status=127/n/a
Jun 04 02:05:54 rpi systemd[1]: mongodb.service: Unit entered failed state.
Jun 04 02:05:54 rpi systemd[1]: mongodb.service: Failed with result ‘exit-code’.
Running a RPI 3 model B
which OS are you running? Raspbian Jesse or Stretch? Also look for updated 3.0.14 binaries in other blog posts. Try to execute “mongod” from the command line and also check permissions on DB and log directories.
Trying both of files “Raspbian Jesse or Stretch”.
Getting errors
mongodb.service – High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2018-06-04 02:05:54 EDT; 4s ago
Process: 682 ExecStart=/usr/bin/mongod –quiet –config /etc/mongodb.conf (code=exited, status=127)
Main PID: 682 (code=exited, status=127)
Running a RPI 3 model B
OK, a couple of things to try. One, is mongod where you think it is? At command prompt, type, “/usr/bin/mongod – -version” and see if you get info. Two, the service may be disabled. Enter these two lines: “sudo systemctl unmask mongodb; sudo systemctl enable mongodb”
LMK…
Hey,
I have a problem with the database and need help if possible, I also have a question, is it wise to install this version now?
I only want to use the server internally.
root@home-pi:/home/pi/tools# sudo service mongodb status
● mongodb.service – High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2018-08-10 13:21:58 CEST; 2s ago
Process: 1953 ExecStart=/usr/bin/mongod –quiet –config /etc/mongodb.conf (code=exited, status=127)
Main PID: 1953 (code=exited, status=127)
Heiko, I need more information to diagnose. What version of R-Pi (Model 2, 3, 3B+ — run “lscpu”), What specific version of OS (which raspbian — “cat /etc/os-release”) and which MongoDB binaries did you download/try?
Hi Andy
Your work and explanation is really excellent and very helpful. Thanks a lot. 🙂
I installed mongodb according to your description on a Rasbian stretch in april/may this year and it worked very well. Today I installed the latest Raspbian stretch on an other Rapspberry Pi3 and I ran into problem. I could not start the service and after lot of searching and trials I found that giving permission to the data folder in this way worked:
sudo chown -R mongodb:root /var/lib/mongodb
I do not understand fully why I had to use -R option, but it worked.
Kind regards
Svein
Thanks for the info and hint, Svein. The “-R” means recurse into directory for the “chown” – I’m wondering if you had “old” (different) permissions that needed to be tweaked.
hey I get an error mongo: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory
i have a dpi 3b+ with armv7 .. I need MongoDB with node js .. any idea?
Kind regards
Ferhat
Ferhat, this is a known issue as Jessie includes updated SSL libraries. Use the 3.0.14 binaries found here: https://andyfelong.com/downloads/core_mongodb_3_0_14.tar.gz – tools here: https://andyfelong.com/downloads/tools_mongodb_3_0_14.tar.gz
For every one have the error status code = 127
This is a libssl1.0.0 error, so you need to reinstall this library to do it:
sudo wget http://ftp.nl.debian.org/debian/pool/main/o/openssl/libssl1.0.0_1.0.1e-2%2Bdeb7u20_armhf.deb
sudo spkg -i libssl1.0.0_1.0.1e-2+deb7u20_armhf.deb
then if you do this command:
/usr/bin/mongod –version
you need to have a db version and a git version
Then you can run:
sudo service mongod start
sudo service mondod status
and everything should be green
THANKS, Thomas!
Hi! I can’t wget the ftp://ftp.nl.debian.org/debian/pool/main/o/openssl/libssl1.0.0_1.0.1e-2+deb7u20_armhf.deb
Ricardo, please try this file – I have not yet tried:
http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u11_armhf.deb
LMK…
Very nice tutorial!
Helped me a lot… worked perfect.
Just on install libssl1.0… “sudo dpkg -i lib…” =)
Thanks
Andy,
I can’t thank you enough for saving my ass. I have been working on a small .Net Core app which used MongoDB on CentOS. This was running on a proper server and I claimed I can set this up on Raspberry Pi. Little did I know that the latest R-Pi is still using 32 bit kernel and the only official version supported is 2.4. None of the .Net drivers supported anything before 2.6.
I had almost written a sorry mail to my PM for the unnecessary spending on the R-Pi (though small it was matter of principle). I used your binaries for 3.0.14 and they worked without any code change for my app. I am now testing all scenarios but I believe most of them will go through as I am using latest driver to connect.
Once again thanks a ton. Keep up the good work.
Thanks Andy,
I finally get the file through browser and successfully installed it. Now my mongodb works.
Sorry for the repeated posts.
Good day!
Pingback: _Ressources – Buildeo Wiki
If someone is looking for libssl, it can be found here: https://ftp.sjtu.edu.cn/sites/archive.debian.org/debian/pool/main/o/openssl/libssl1.0.0_1.0.1e-2%2Bdeb7u20_armhf.deb
Also, prior to sudo dpkg -i libssl1.0.0_1.0.1e-2+deb7u20_armhf.deb you need “sudo apt install multiarch-support”