Then go into the mongo shell and initiate the replica set, like so:
mongo
> rs.initiate()
PRIMARY> rs.add("mongo-a")
PRIMARY> rs.add("mongo-b")
PRIMARY> rs.add("mongo-c")
PRIMARY> rs.setReadPref('secondaryPreferred')
The replica set will need an oplog user to access the database.
mongo
PRIMARY> use admin
PRIMARY> db.addUser({user:"oplogger",pwd:"YOUR_PASSWORD",roles:[],otherDBRoles:{local:["read"]}});
PRIMARY> show users
Your upstart script will need to be modified to use multiple IP addresses of the replica set.
start on started mountall
stop on shutdown
respawn
respawn limit 99 5
script
# our example assumes you're using a replica set and/or oplog integreation
export MONGO_URL='mongodb://mongo-a...
The --url flag can be tricky to use. There is a 60 second window to authenticate, and then the username/password randomly resets. So be sure to have robomongo open and ready to configure a new connection when you run the command.
# get the MONGO_URL string for your app
meteor mongo --url $METEOR...
Same thing as before, but you have to copy the info into the mongodump command. You have to run the following commands rediculously fast, and it requires hand/eye coordination. Be warned! This is a rediculously hacky! But fun! Think of it as a video game! :D
# get the MONGO_URL string for your app ...
This command will create a /dump directory, and store each collection in a separate BSON blob file. This is the best way to backup or transfer databases between systems.
mongodump --db meteor
The analog to the meteordump command is meteorrestore. You can do a partial import by selecting the specific collection to import. Particularly useful after running a drop command.
# make sure your app is running
meteor
# then import your data
mongorestore --port 3001 --db meteor /path/to/dump...
Importing into a default Meteor instance is fairly easy. Note that you can add a --jsonArray option if your json file is exported as an array from another system.
mongoimport --db meteor --port 3001 --collection foo --file foo.json
Mongo supports database-to-database copying, which is useful if you have large databases on a staging database that you want to copy into a local development instance.
// run mongod so we can create a staging database
// note that this is a separate instance from the meteor mongo and minimongo ins...
Preallocation. Mongo sets aside disk-space in empty containers, so when the time comes to write something to disk, it doesn't have to shuffle bits out of the way first. It does so by a doubling algorithm, always doubling the amount of disk space preallocated until it reaches 2GB; and then each preal...
They're not easily accessible. If you run the 'meteor bundle' command, you can generate a tar.gz file, and then run your app manually. Doing that, you should be able to access the mongo logs... probably in the .meteor/db directory.
If you really need to access mongodb log files, set up a regular mo...
Gotta rotate those log files, or they'll eventually eat up all of your disk space. Start with some research...
mongodb-log-file-growth
rotate-log-files
Log files can be viewed with the following command...
ls /var/log/mongodb/
But to set up log-file rotation, you'll need to do the following.....
db.posts.find().forEach(function(doc){
if(doc.arrayOfObjects){
// the false, true at the end refers to $upsert, and $multi, respectively
db.accounts.update({_id: doc._id}, {$unset: {'arrayOfObjects': "" }}, false, true);
}
});