Using an existing MongoDB instance during development

354 views
Skip to first unread message

Hongli Lai

unread,
Jan 6, 2014, 3:42:51 PM1/6/14
to meteo...@googlegroups.com
Is it possible to use an existing MongoDB instance during development, instead of letting the 'meteor' script manage its own MongoDB instance? I'm trying to make Phusion Passenger in multi-process mode work: https://github.com/phusion/passenger/wiki/Phusion-Passenger%3A-Meteor-tutorial#process-spawning

I hoped that setting MONGO_URL would do the trick, but unfortunately it doesn't. If I run MongoDB like this:

~/.meteor/tools/latest/mongodb/bin/mongod --bind_ip 127.0.0.1 --smallfiles --nohttpinterface --port 4176 --dbpath .meteor/local/db --oplogSize 8 --replSet meteor

and then set MONGO_URL to this:

mongodb://localhost:4176/meteor

then running 'meteor run' results in the following error:

I20140106-21:40:21.199(1)? Exception in queued task: MongoError: not master and slaveOk=false
I20140106-21:40:21.248(1)?     at Object.Future.wait (/Users/hongli/.meteor/tools/09b63f1ed5/lib/node_modules/fibers/future.js:326:15)
I20140106-21:40:21.248(1)?     at _.extend._nextObject (packages/mongo-livedata/mongo_driver.js:803)
I20140106-21:40:21.248(1)?     at _.extend.forEach (packages/mongo-livedata/mongo_driver.js:835)
I20140106-21:40:21.248(1)?     at _.extend.getRawObjects (packages/mongo-livedata/mongo_driver.js:884)
I20140106-21:40:21.248(1)?     at _.extend._pollMongo (packages/mongo-livedata/polling_observe_driver.js:145)
I20140106-21:40:21.249(1)?     at Object.task (packages/mongo-livedata/polling_observe_driver.js:86)
I20140106-21:40:21.250(1)?     at _.extend._run (packages/meteor/fiber_helpers.js:150)
I20140106-21:40:21.250(1)?     at packages/meteor/fiber_helpers.js:128
I20140106-21:40:21.250(1)?     - - - - -
I20140106-21:40:21.250(1)?     at Object.toError (/Users/hongli/.meteor/packages/mongo-livedata/133ed3e7a3/npm/node_modules/mongodb/lib/mongodb/utils.js:110:11)
I20140106-21:40:21.250(1)?     at /Users/hongli/.meteor/packages/mongo-livedata/133ed3e7a3/npm/node_modules/mongodb/lib/mongodb/cursor.js:642:54
I20140106-21:40:21.250(1)?     at Cursor.close (/Users/hongli/.meteor/packages/mongo-livedata/133ed3e7a3/npm/node_modules/mongodb/lib/mongodb/cursor.js:912:5)
I20140106-21:40:21.251(1)?     at commandHandler (/Users/hongli/.meteor/packages/mongo-livedata/133ed3e7a3/npm/node_modules/mongodb/lib/mongodb/cursor.js:642:21)
I20140106-21:40:21.251(1)?     at /Users/hongli/.meteor/packages/mongo-livedata/133ed3e7a3/npm/node_modules/mongodb/lib/mongodb/db.js:1670:9
I20140106-21:40:21.251(1)?     at Server.Base._callHandler (/Users/hongli/.meteor/packages/mongo-livedata/133ed3e7a3/npm/node_modules/mongodb/lib/mongodb/connection/base.js:382:41)
I20140106-21:40:21.251(1)?     at /Users/hongli/.meteor/packages/mongo-livedata/133ed3e7a3/npm/node_modules/mongodb/lib/mongodb/connection/server.js:472:18
I20140106-21:40:21.251(1)?     at MongoReply.parseBody (/Users/hongli/.meteor/packages/mongo-livedata/133ed3e7a3/npm/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
I20140106-21:40:21.252(1)?     at null.<anonymous> (/Users/hongli/.meteor/packages/mongo-livedata/133ed3e7a3/npm/node_modules/mongodb/lib/mongodb/connection/server.js:430:20)
I20140106-21:40:21.252(1)?     at EventEmitter.emit (events.js:95:17)

Abigail Watson

unread,
Jan 6, 2014, 5:57:29 PM1/6/14
to meteo...@googlegroups.com
Your replica set isn't initiated correctly, and Meteor is trying to connect to a secondary.  You need to initiate your replica set, and make sure you're connecting to a primary.  If you're specifically trying to get Meteor to read of a secondary, you need to run a rs.slaveOk();  

> rs.initiate()
> rs.add("mongo-b")
> rs.add("mongo-c")
> rs.slaveOk()

You also need to set up your MONGO_URL properly to connect to a replicaSet, and specify the multiple addresses, like so (be sure to set up host files correctly):  

MONGO_URL='mongodb://mongo-a,mongo-b,mongo-c:4176/?replicaSet=meteor'

Alternatively, skip the --replSet meteor flag in your mongod command.

Hongli Lai

unread,
Jan 7, 2014, 4:44:39 PM1/7/14
to meteo...@googlegroups.com
Ah I see. I needed to run 'meteor run' without MONGO_URL first, to
initialize the development database. I didn't do that and I got the
error.

Thanks for helping me on my way.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "meteor-talk" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/meteor-talk/4zLH4HeoqRg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> meteor-talk...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Phusion | Ruby & Rails deployment, scaling and tuning solutions

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)
Reply all
Reply to author
Forward
0 new messages