Where to set mongodb start parameter in a meteor application on nitrous.io? - mongodb

I'm studying meteor and trying some examples on nitrous.io, but the available disk space was soon consumed by the big mongo data files (including the prealloc journal files).
Unfortunately MongoDB is also new to me. I googled around and found that I can start mongoDB with some parameters like --nojournal, but I have no idea where in the nitrous.io app I can pass this parameter to mongodb at startup?
I also can't find any mongodb.conf (even *db.conf) to use the storage.smallFiles setting.
Any help would be appreciated!

Instead of using Meteor's builtin MongoDB instance, you can specify a custom instance (which you can configure the way you want).
To do this Nitrous.IO, you can follow these steps:
Create a box with Meteor template.
Install MongoDB, by running parts install mongodb (Autoparts is Nitrous.IO specific package manager)
Open the MongoDB config located at /home/action/.parts/etc/mongodb.conf
Tweak it to your liking.
Start MongoDB instance by running parts start mongodb
Now you can create a new meteor project - meteor create projectname
Finally, when you're starting meteor on your project specify the MONGO_URL environment variable. eg: MONGO_URL=mongodb://0.0.0.0:27017 meteor.
Hope this would be good enough to get started. You can also upgrade your Nitrous.IO account to increase the storage of your box.
UPDATE: I just noticed that Meteor runs its MongoDB instance with --smallfiles flag set.

Related

Mongo 3.4 in Meteor

Is that possible to use Meteor with Mongo 3.4 for now? And if so, how to manage that?
I've tried to change packages file, but realised that version of mongo package is not a real Mongo's version.
This is indeed possible by taking care of mongodb yourself instead of letting meteor handle it. To do so you will have to fire up a mongod instance and set the MONGO_URL variable when you run meteor in development mode. In production mode you will be running a standalone mongodb instance anyway, so you will not need to change anything there.
As a reference, see this discussion on the meteor forums: https://forums.meteor.com/t/running-mongodb-3-4-locally-with-meteor/34242
To set an environment variable when running meteor in development mode requires the following:
MONGO_URL=mongodb://localhost:27017/meteor meteor
In this case you are accessing the meteor database (/meteor) on the local mongodb instance (localhost) on the standard port (:27017).

How can I query an FS collection in Meteor from the command line?

It is very useful to run meteor mongo and query collections from the command line, for debugging purposes, etc.
Recently, I have added the collectionFS package to enable image storage in the database. However, I am unable to query the database from the command line.
db.fs.collection_name.find() is not doing the trick, and I can't seem to find the correct command anywhere.
Go to the Meteor Mongo console: meteor mongo
See all the collections that are available: show collections
Look for the one that has cfs.collection_name.files
Choose the one that has your collection name. For example, I'm using collectionFS with gridFS for images. When I type show collections, I see cfs_gridfs.images.files so I just do: db.cfs_gridfs.images.files.find() to see those files.
Hope that helps.
If you find it difficult to use the command line or terminal, you have a UI for MongoDB called Robomongo which is easy to install and use. I use Meteor with its default port number and then in Robomongo it is used as 3001.
And the query to view collection here is same as db.collection_name.find().

How to persist mongodb when deploying with meteor?

When I meteor deploy my app, it seems to create an entirely new mongodb instance. I'd like to be able to deploy with the current mongodb have locally.
Same goes the other way -- I'd like to be able to download the mongodb back to my localhost after it has been deployed.
For clarification, I'd really like to know the follow:
1) how to deploy with a fresh mongodb
2) how to deploy to an existing deployed app without overwriting the old mongodb
3) how to download/sync mongodb locally with the existing deployed app
4) how to make local backups of mongodb
You can perform a mongo dump using meteor mongo to export your local database and deploy your app using Meteor Up which should also allow you to automate the database import and deployment process.
"Meteor Up (mup for short) is a command line tool that allows you to deploy any meteor app into your own server."
You can stop the mongodb service and start a mongod instance in a separate terminal, by just typing mongod. This will let you monitor what's happening on the mongodb instance that you just started.
Open another terminal and do export MONGO_URL=mongodb://localhost:27017/nameOfDBgoesHere
This will create a new DB named "nameOfDBgoesHere" and it won't overwrite what you currently have, unless you name it with the same name.
After that just start meteor by typing meteor in your program's folder. In the mongod terminal that you opened you should see some connections opening.
By default mongodb creates it's DB files in /data/db. If you have another meteor app and follow the same steps in another terminal, while keeping the name of the DB you specified in the MONGO_URL you will just connect to it from that app - without overwriting anything.
As for the syncing with a deployed app and the local backups of mongo - it seems like something that the mongodb website covers, but maybe someone can chime in here. Not sure if there is a meteor specific, easy way of doing this.

ideal vm setup for meteor with shared folder

situation
Hello, I run arch Linux for which there is no meteor package and have an Ubuntu server run within virtualbox for web development. There is a shared folder I mount through database. hich means I can code in to the active environment.
However, like many others, I have a problem with mongodb starting up, specifically the exit code 100.
tracing the problem:
I created the /data/DB directory
gave access rights to my user
ran mongod on its own with no problems
Still I have the issue though.
Question
Where is the configuration file for mongodb which is installed with meteor so I can move it and do I need to create rights for a 'mongodb' user?
Question
What would be the ideal virtual machine for running a meteor development environment in the above set up? Having to create the data directory in the first place tells me Ubuntu server isn't ideal. some extra documentation available to answer this second question appearing on the meteor website would be beautiful
MongoDB does not work correctly on virtualbox shared folders. By default, meteor creates a mongo database in your project's directory, however you can override this behavior with the MONGO_URL environment variable. If you set this variable, meteor will not try to start mongo and will instead connect directly to the mongo endpoint you specify. This allows you to setup mongo however you like (eg using the Ubuntu mongodb package), with data somewhere not in the shared folder.

can I use MongoDb in server-less mode?

I'm considering using MongoDb for a backing store for a WPF app that I'm building. Mostly just to get some exposure to NoSQL. Ideally I'd like to make a mongodb database, put it in my application's root folder (or ./data) and connect to it with LINQ -- without having mongo.exe running. I did something similar recently with SQLite and found it to be a great change from XML for data storage.
Is this possible with MongoDb? All the samples that I've seen require mongod.exe to be running when you connect to the database. And the data is always stored in c:\data\db.
Answer, yes. Need to use the --dbpath switch and version 1.5.2 (for "upsert").