Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've been running mongodb as a replica set, and have recently attempted to move to a sharded cluster.

One thing I'm a little unsure about is how I should be starting the mongos process. Previously I had used the 10gen rpms when installing mongodb, which installed an init.d script for the mongod service. I'd like to have mongos run in a similar way, but am unsure about how I should be doing this really. Is it a case of writing a custom init script?

I'm on Debian 6, and Mongodb 2.4

[I'd previously posted this quesion in the mongodb google group, but am copying here as I didn't get any response - I'll add any responses here too]

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You have linked the relevant official request for this in your answer and SERVER-3748 does explain some of the reasons why these don't currently exist.

The most basic reason is that you cannot start mongos without at least one config server being up and working, otherwise it will refuse to start, which makes it a poor candidate for an init script (external dependencies). Generally you want to avoid having services that are going to fail to start when there is no good way to check the reason for failure.

However, it would still be beneficial to give people a script rather than having them modify/write one themselves, hence the Jira issue exists.

The way I would recommend to do this is to base any script off of the existing mongod init script and simply modify it to replace mongod with mongos where appropriate. Here is the current version of that script for Debian:

https://github.com/mongodb/mongo/blob/master/debian/init.d

Things you will need to change:

> DAEMON=/usr/bin/mongos
> DESC=mongos-router
> 
> NAME=mongos
> 
> CONF=/etc/mongos.conf 
> PIDFILE=/var/run/$NAME.pid 
> ENABLE_MONGODB=yes

The advantage to doing this, after you have installed the 10gen package, is that the users will already be set up and you have the mongod script for reference on the system.

You will need to create the config file with appropriate values for your mongos, and there might be a couple of other things you need to tweak - the key is to test before you make anything permanent.

Once you confirm via testing that you have the script working as you wish, then you can add it permanently with update-rc.d

share|improve this answer
    
Thanks for the detailed reply Adam, I've now implemented something along these lines. –  UpTheCreek Apr 22 '13 at 14:24
add comment

Hmm, looks like there's an open ticket requesting just this, so I guess it's not provided officially. I'll update this answer if I find any user contributed script or write my own.

https://jira.mongodb.org/browse/SERVER-3748

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.