Running Mongo and Mongo Config Server on Same Machine

741 views
Skip to first unread message

Matt

unread,
Apr 29, 2011, 11:38:39 AM4/29/11
to mongodb-user
I'm attempting to run two instances of the mongod process on the same
machine as per the suggestion in the Simple Initial Sharding
Architecture doc (http://goo.gl/Z85qS). However, I can only get one
mongod process to run at a time. If I start it as the database server
first, then start another process with the --configsvr option (or vice
versa), the latter will start and immediately exit cleanly, with no
log output.

I've confirmed that there is no port conflict, file permissions are ok
and both instances are pointing to unique database directories.

Any idea why I can't run both at the same time?

Scott Hernandez

unread,
Apr 29, 2011, 12:16:19 PM4/29/11
to mongod...@googlegroups.com
What os/distribution are you using? How are the you starting the two processes and what do the logs look for when they start up? Do you have a session log you can post?

(feel free to post the output of commands and logs to gist/pastie/pastebin/etc)


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


Chris Grieger

unread,
Apr 29, 2011, 12:21:35 PM4/29/11
to mongodb-user
Have you changed the port of one of the servers? (--port argument)

Matt

unread,
Apr 29, 2011, 12:34:15 PM4/29/11
to mongodb-user
That's the kicker. There's no log output in the config server's log.
Here's the command I use to start the config server:

sudo su mongodb -c '/usr/bin/mongod --dbpath=/var/lib/mongodb-
configsvr --configsvr --logpath=/var/log/mongodb/configsvr.log'

The only log output generated when I start the config server with that
command is in the syslog, which contains only the following line:

Apr 29 16:23:07 ip-10-160-233-168 init: mongodb-configsvr main
process (12479) terminated with status 1

However, if I start the service as root using the following command,
it appears to start normally and shutting it down produces expected
output in the config server's log.

sudo /usr/bin/mongod --dbpath=/var/lib/mongodb-configsvr --
configsvr --logpath=/var/log/mongodb/configsvr.log


-Matt

PS. I'm not familiar with gist/pastie/pastebin/etc. Is it just a
pastebin like dpaste.de?

Matt

unread,
Apr 29, 2011, 12:39:05 PM4/29/11
to mongodb-user
As I understand it, the config server should start by default on
27019. Though I have tried setting it explicitly to no avail.

Matt

unread,
Apr 29, 2011, 12:56:29 PM4/29/11
to mongodb-user
Amendment:

I created a fresh EC2 instance (Ubuntu 10.10), installed mongo 1.8.1,
stopped the mongod service, and attempted to start the config server
standalone, with the same results.

As best I can tell, the problem is related to trying to run the
process as user 'mongodb' as opposed to root.

Scott Hernandez

unread,
Apr 29, 2011, 1:06:03 PM4/29/11
to mongod...@googlegroups.com
Can you try switch to the user and test interactively?

$sudo su mongodb
$mongod ....

and leave off the logpath and let it log to the console.

Generally we suggest creating/copying an upstart script for each process and managing it that way. It can switch to the correct user and passes in the config file path, or command line args.

Matt

unread,
Apr 29, 2011, 1:15:05 PM4/29/11
to mongodb-user
Ah. There's a clue. It's griping about permissions on the --dbpath
directory. However, I've already chown'd the directory to
mongodb:mongodb. Log output here: http://dpaste.de/ekT4/

Matt

unread,
Apr 29, 2011, 1:19:12 PM4/29/11
to mongodb-user
Here's my upstart script. I've been trying to get things going from
the command line first just to eliminate upstart as a variabile.

http://dpaste.de/MsBG/

On Apr 29, 10:06 am, Scott Hernandez <scotthernan...@gmail.com> wrote:

Scott Hernandez

unread,
Apr 29, 2011, 1:42:42 PM4/29/11
to mongod...@googlegroups.com
On Fri, Apr 29, 2011 at 10:15 AM, Matt <ma...@ziplinegames.com> wrote:
Ah.  There's a clue.  It's griping about permissions on the --dbpath
directory.  However, I've already chown'd the directory to
mongodb:mongodb.  Log output here:  http://dpaste.de/ekT4/

You need to be able to read each directory from the root (/) to that directory, as that user. You also need to be able to create a file in this directory /var/lib/mongodb-configsvr (/var/lib/mongodb-configsvr/mongod.lock), which is what it is complaining about. You might want to check this manually, just so you understand the requirement, by switching to that user and creating a file.

Matt

unread,
Apr 29, 2011, 2:47:02 PM4/29/11
to mongodb-user
Sorry for the red herrings but it seems I'm going around in circles
here. I'm back to the case I started with; I can't run the config
server and the database server at the same time. Though this only
seems to be the case when I start them from upstart.

On Apr 29, 10:42 am, Scott Hernandez <scotthernan...@gmail.com> wrote:

Matt

unread,
Apr 29, 2011, 5:15:55 PM4/29/11
to mongodb-user
Ok. I found the problem but I'm not sure how to address it. The
problem is that upstart uses the full path to the executable to
determine if a service is already running. When a second instance of
mongod is started, upstart sees the first instance and exits.

I found this workaround but it seems like a real hack.
http://serverfault.com/questions/219345/upstart-multiple-instances-of-service-not-working

Any idea how to tell upstart to differentiate between mongod
instances?
Reply all
Reply to author
Forward
0 new messages