Pregunta

I've always been testing replicasets by starting multiple mongod processes on the same server (because using multiple serves is more expensive, and I'm merely testing at this point).

However, since I've updated mongo to version v2.0.5 I'm getting the following when I try to start mongod again (on another port, with another database folder, etc.):

mongod already running

Why is this so? Is there a flag to skip this check?

Update: for some reason this only happens when I run mongod like so:

sudo start-stop-daemon --start -c mainuser --exec /usr/local/bin/mongod -- --journal --nohttpinterface --dbpath /home/mainuser/data/db-secondary --logpath /home/mainuser/data/logs/mongodb-secondary.log --logappend --replSet appname --port 30001

It does not happen when I run it like so:

sudo /usr/local/bin/mongod --journal --nohttpinterface --dbpath /home/mainuser/data/db-secondary --logpath /home/mainuser/data/logs/mongodb-secondary.log --logappend --replSet appname --port 30001

Unfortunately I have to use the start-stop-daemon for use in my upstart script on Ubuntu 10.04 LTS. Why would it cause this issue?

After reading the manpage for start-stop-daemon it becomes clear that it is purposely not trying to start the process again because it recognizes it as being the same "service". However, I'm only using start-stop-daemon so that I can run as a different user with Upstart. Is it possible to bypass the check, or run as a non-sudo user in upstart in a different way?

¿Fue útil?

Solución 2

This turned out to be a feature of start-stop-daemon, which I used with upstart to run as another user.

By not using start-stop-daemon, this issue was resolved. Inside my upstart script, I now run as mainuser using sudo:

sudo -u mainuser /usr/local/bin/mongod --journal --nohttpinterface --dbpath /home/mainuser/data/db-secondary --logpath /home/mainuser/data/logs/mongodb-secondary.log --logappend --replSet appname --port 30001

Otros consejos

Possible solution: You need to use start-stop-daemon's key --name to give diffeent names to different processes. For example for node.js:

start-stop-daemon --name node-charts --start --exec /usr/bin/node -- someapp.js

and

start-stop-daemon --name node-web --start --exec /usr/bin/node -- someotherapp.js

without name it will not start because of it has same /usr/bin/node process name.

This is because a pid file already exists for the running mongod.

Just use a different pid with start-stop-daemon. For example,

sudo start-stop-daemon --start --pid=/var/run/mongodb2.pid --chuid mongodb --exec  /usr/bin/mongod -- --config /etc/mongodb2.conf

So it won't complain about "/usr/bin/mongod already running"

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top