service mongod stop [failed]

3,489 views
Skip to first unread message

Howard

unread,
Dec 14, 2010, 8:29:38 AM12/14/10
to mongodb-user
Running mongo v1.6.4 successfully on Centos. Installed using yum. When
I try to stop the service it fails leaving the process running. I have
to kill -9 the process to stop MongoDB which leaves it unable to start
again without manually removing the lock file in the data folder.

This came about because I added an index to a collection, but my
cursor would time out on query. Running explain showed the cursor was
using the index but it would not return results. Restarting mongod
fixed the issue.

H

Eliot Horowitz

unread,
Dec 14, 2010, 10:07:51 AM12/14/10
to mongod...@googlegroups.com
If you tried to shutdown while it was building an index it would try
to finish first.
Could that be what happened?

> --
> 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.
>
>

Howard

unread,
Dec 14, 2010, 10:29:52 AM12/14/10
to mongodb-user
Don't think the two are connected. The shell had returned after
building the index and I can reproduce the shutdown issue everytime I
issue the service stop command.

Eliot Horowitz

unread,
Dec 14, 2010, 10:33:32 AM12/14/10
to mongod...@googlegroups.com
can you send the mongo logs from shutdown?

Howard

unread,
Dec 14, 2010, 11:13:54 AM12/14/10
to mongodb-user
I checked /var/log/mongo/mongod.log after I issued the service mogod
stop command, and there was no reference to the shutdown command
being issued.

H

Eliot Horowitz

unread,
Dec 14, 2010, 11:22:08 AM12/14/10
to mongod...@googlegroups.com
Well that would certainly be a problem.
Did you try issuing shutdown through the shell or a regular "kill" (not -9)

Howard

unread,
Dec 14, 2010, 11:32:12 AM12/14/10
to mongodb-user
If I issue

service mongod stop

it returns

service mongod stop [failed]

no reference in the logs to the stop command being issued and ps -A
showed that process was still running

killed the process using kill -9

I'm then unable to start mongod without removing the lock file
manually.

Howard

unread,
Dec 14, 2010, 11:38:35 AM12/14/10
to mongodb-user
Just re read your response. I'll try an issue a db.shutdownServer() or
kill -2 PID and see what happens

Howard

unread,
Dec 15, 2010, 11:03:42 AM12/15/10
to mongodb-user
Eliot,

ok 'db.shutdownServer()' worked for me and from the log seems to have
shut the mongod down coreectly, but confusingly outputted the
following. Seems like the client tries to reconnect immediately to
the shutdown server.

> use admin
switched to db admin
> db.shutdownServer()
Wed Dec 15 16:00:16 query failed : admin.$cmd { shutdown: 1.0 } to:
127.0.0.1
server should be down...
Wed Dec 15 16:00:16 trying reconnect to 127.0.0.1
Wed Dec 15 16:00:16 reconnect 127.0.0.1 failed couldn't connect to
server 127.0.0.1
Wed Dec 15 16:00:16 MessagingPort say send() errno:9 Bad file
descriptor 127.0.0.1:27017
Wed Dec 15 16:00:16 Error: error doing query: unknown (anon):1526

Eliot Horowitz

unread,
Dec 15, 2010, 12:29:51 PM12/15/10
to mongod...@googlegroups.com
Yes - that's an issue in the shell.
But looks like the shutdown was fine.

Berik Moldashev

unread,
Aug 11, 2014, 11:22:44 AM8/11/14
to mongod...@googlegroups.com
Mongo 2.6.3. same problem on Centos.
Easy fix:

vim /etc/init.d/mongod

look for stop() function and remove quotes around $PIDFILE in the following line.

killproc -p $PIDFILE -d 300 /usr/bin/mongod

That's it.

Asya Kamsky

unread,
Aug 12, 2014, 5:04:19 PM8/12/14
to mongod...@googlegroups.com
I'm not sure that this is the same problem, considering the message you're replying to is from 3.5 years ago...
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.

To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/8e70b311-21b0-45e3-bd4f-d983e5104756%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Frank Li

unread,
Sep 3, 2014, 11:04:54 AM9/3/14
to mongod...@googlegroups.com
thanks! this works perfectly....
Reply all
Reply to author
Forward
0 new messages