When using a separate MongoDB with meteor, meteor reset stopped working - mongodb

I have my MONGO_URL set to mongodb://localhost:27017/meteor and have the MongoDB run as a service.
When running my project it seems OK to store data to the separate MongoDB until I tried to run meteor reset.
My assumption is it tried to remove its default database. The error complained that myproject.meteor\local is not empty and pointed to fs.js:456 which goes to files.js:256 (rm_recursive) and so on.
any idea what and how I can fix this?

$ meteor reset only resets the bundled MongoDB. It won't reset an external Mongo database.
(That's something we should explain better in the documentation.)
In your case, try connecting to the Mongo database directly (with the mongo command line shell) and running > db.dropDatabase()

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 to show my users collection with mongodb

I'm sorry for this (peraphs) stupid question ... I install meteor and mongodb in my windows computer and i start to write some apps. I don't understand how to use mongo for shoving my db app ... i open one shell in my app dir and launch mongod, in one more shell in the same folder i start mongo.
show dbs
local
use local
switched to db local
show collections
startup_log
system.indexes
Where are my collections? Where is users collection?
When your app is running use this command on a separate command line mongo 127.0.0.1:3001
Meteor keeps the collections in this server. After you run mongo on this server, by writing use meteor you can use db specific to your running app. And then you can display your collections with db.getCollectionNames()
Meteor uses a library called Minimongo that's why it doesn't display if you run show dbs on your mongo shell.
By default it points to port 3001 hence if you are using Robomongo you can just make the set up to watch that port.
To display all your MongoDB collections using the shell, you may check this answer:
How to list all collections in the mongo shell?
You may also use a MongoDB GUI Tool such Robomongo

Unexpected mongo exit code 100. Restarting

I was trying to run Meteor on my VPS and I was getting this error:
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Can't start Mongo server.
MongoDB had an unspecified uncaught exception.
This can be caused by MongoDB being unable to write to a local database.
Check that you have permissions to write to .meteor/local. MongoDB does
not support filesystems like NFS that do not allow file locking.
I have figured out that the problem is in my user permissions or something like that. It works very smoothly when I try to run meteor with root access. If I try to run meteor with my "custom" user, it fails. Even though I grant him sudo privileges as listed on DigitalOcean. Why is it so? What is the problem behind?
I am on Ubuntu 14.04.1 LTS. Meteor is version 0.8.3 and I am using MongoDB coming with Meteor. I do not have seperated instalation of MongoDB.
Update: Basicly I have found the problem but I still do not now what is causing the problem. I am on DigitalOcean VPS. If I run Meteor over SSH, it fails. If I run Meteor on web Console Access, it works. I do not get it.
Answer https://stackoverflow.com/a/15752736 helped me to find out that Mongo doesn't want to start without properly set locale.
Try to run export LC_ALL="en_US.UTF-8" command before meteor command.
WARNING: This deletes the database and all of the application's data.
rm -rf .meteor/local
Solved it for me when none of the above solutions did.
I would guess that the custom user you created cannot remove the mongod.lock file due to insufficient premissions.
Also check that you have space on your HD, That was my problem.

In Meteor.js, how would I have two development projects use the same Mongo instance?

I would like to have two separate applications use the same Mongo DB instance, and since I am developing them at the same time I would like to be able to share the same development DB instance.
I realize that each instance of Meteor would have to run on it's own port. Is there a way to force meteor or mrt to connect to a local socket like the system version of MongoDB?
Yeah, you can just start meteor with the MONGO_URL parameter like:
$ MONGO_URL="mongodb://localhost:27017/myapp" meteor
or
$ MONGO_URL="mongodb://localhost:27017/myapp" meteor --port 4000
This assumes you have mongodb installed on your system. See this question for ways to make this process a little easier by using environment variables or a start script.
David's answer is in the right direction, but threw me off a little. Instead, we're doing this to start the first app as normal:
$ meteor
Then to start the second app and connect to the database of the first, we're doing:
$ MONGO_URL="mongodb://localhost:3001/meteor" meteor --port 3002
The key here is that meteor starts its own mongo instance on port 3001, and we can connect to that directly from a second meteor instance. David's answer uses your system's mongo for both apps.

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.