[SERVER-14054] Mongod service does not respect chkconfig configuration Created: 27/May/14  Updated: 10/Dec/14  Resolved: 09/Jul/14

Status: Closed
Project: Core Server
Component/s: Packaging
Affects Version/s: 2.6.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Dharshan Rangegowda Assignee: Ernie Hershey
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Version: 2.6.1
OS : CentOS 6.x, Amazon linux

I am trying to turn off the mongod service on one of my servers.
#chkconfig mongod off
#chkconfig --list mongod
mongod 0:off 1:off 2:off 3:off 4:off 5:off 6:off

However on reboot i notice that the mongod service is running. Doesn't look like the chkconfig config is respected by the mongod server.



 Comments   
Comment by Ernie Hershey [ 03/Jul/14 ]

Hi dharshanr@scalegrid.net - when you run "ps auwx | grep mongod" it's listing mongos because it's running as the "mongod" user.

As you can see, there's no mongod process so chkconfig did indeed disable starting mongod.

Do you have any other questions or problems that should be addressed in this ticket?

You can generally get more help if you email the user group which has a wider audience of people who can help with issues like this.
https://groups.google.com/forum/#!forum/mongodb-user

Comment by Dharshan Rangegowda [ 13/Jun/14 ]

Here you go

[root@ip-172-31-36-150 ec2-user]# ps auwx | grep mongod
root 1250 0.0 0.0 152344 1540 ? S Jun12 0:00 su -s /bin/bash mongodb-mms-agent -c /usr/bin/mongodb-mms-monitoring-agent -conf /etc/mongodb-mm
config
218 1259 0.0 0.1 488296 8104 ? Ssl Jun12 0:02 /usr/bin/mongodb-mms-monitoring-agent -conf /etc/mongodb-mms/monitoring-agent.config
mongod 1408 0.1 0.1 273692 11852 ? Sl Jun12 0:14 /usr/bin/mongos -f /etc/mongos.conf
root 2548 0.0 0.0 110268 844 pts/0 S+ 00:47 0:00 grep mongod

It's fairly confusing - why is mongos appearing as mongod? I hacked together the /etc/init.d script based on the mongod script. Killing this process and then running "service mongos start" appears to do the trick

Here it my mongos start script
#!/bin/bash

  1. mongos - Startup script for mongos
  1. chkconfig: 35 85 15
  2. description: Mongo is a scalable, document-oriented database.
  3. processname: mongod
  4. config: /etc/mongos.conf
  5. pidfile: /var/run/mongo/mongos.pid

. /etc/rc.d/init.d/functions

  1. things from mongod.conf get there by mongod reading it
  1. NOTE: if you change any OPTIONS here, you get what you pay for:
  2. this script assumes all options are in the config file.
    CONFIGFILE="/etc/mongos.conf"
    OPTIONS=" -f $CONFIGFILE"
    SYSCONFIG="/etc/sysconfig/mongos"
  1. FIXME: 1.9.x has a --shutdown flag that parses the config file and
  2. shuts down the correct running pid, but that's unavailable in 1.8
  3. for now. This can go away when this script stops supporting 1.8.
    DBPATH=`awk -F= '/^dbpath=/ {print $2}' "$CONFIGFILE"`
    PIDFILE=`awk -F= '/^dbpath\s=\s/{print $2}

    ' "$CONFIGFILE"`
    mongos=/usr/bin/mongos

MONGO_USER=mongod
MONGO_GROUP=mongod

if [ -f "$SYSCONFIG" ]; then
. "$SYSCONFIG"
fi

  1. Handle NUMA access to CPUs (SERVER-3574)
  2. This verifies the existence of numactl as well as testing that the command works
    NUMACTL_ARGS="--interleave=all"
    if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS ls / >/dev/null 2>/dev/null
    then
    NUMACTL="numactl $NUMACTL_ARGS"
    else
    NUMACTL=""
    fi

start()
{
echo -n $"Starting mongos: "
daemon --user "$MONGO_USER" $NUMACTL $mongos $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongos
}

stop()
{
echo -n $"Stopping mongos: "
killproc -p "$PIDFILE" -d 300 /usr/bin/mongos
restart
;;
condrestart)
[ -f /var/lock/subsys/mongos ] && restart || :
;;
status)
status $mongos
RETVAL=$?
;;
*)
echo "Usage: $0

{start|stop|status|restart|reload|force-reload|condrestart}

"
RETVAL=1
esac

exit $RETVAL
~

Comment by Ramon Fernandez Marina [ 10/Jun/14 ]

Hi dharshanr@scalegrid.net,

we still need more information to diagnose this ticket. If this is still an issue for you, can you please provide the information Ernie requested above?

Thanks,
Ramón.

Comment by Ernie Hershey [ 28/May/14 ]

The symlinks under /etc/rc.d look like the chkconfig command did what it was supposed to. Can you run "ps auwx | grep mongod" and show the output?

You can also run this to see if another script under /etc/init.d is starting it:

grep -r mongod /etc/init.d

Can you provide more detail on the MMS agent you have installed? How did you install it? What's the version?

Comment by Dharshan Rangegowda [ 28/May/14 ]

Here are the results after I disable the service and reboot. "service status mongod" says the service is stopped but the mongod process is running.

[root@ip-10-251-86-194 ec2-user]# find /etc/ -name *mongod -ls
11939 4 rw-rr- 1 root root 47 May 16 16:58 /etc/sysconfig/mongod
5776 0 lrwxrwxrwx 1 root root 16 May 28 01:03 /etc/rc.d/rc2.d/K15mongod -> ../init.d/mongod
5808 0 lrwxrwxrwx 1 root root 16 May 28 01:03 /etc/rc.d/rc4.d/K15mongod -> ../init.d/mongod
11935 4 -rwxr-xr-x 1 root root 2342 May 16 16:58 /etc/rc.d/init.d/mongod
11953 0 lrwxrwxrwx 1 root root 16 May 28 00:35 /etc/rc.d/rc6.d/K15mongod -> ../init.d/mongod
11948 0 lrwxrwxrwx 1 root root 16 May 28 00:35 /etc/rc.d/rc1.d/K15mongod -> ../init.d/mongod
5820 0 lrwxrwxrwx 1 root root 16 May 28 01:03 /etc/rc.d/rc5.d/K15mongod -> ../init.d/mongod
5798 0 lrwxrwxrwx 1 root root 16 May 28 01:03 /etc/rc.d/rc3.d/K15mongod -> ../init.d/mongod
11947 0 lrwxrwxrwx 1 root root 16 May 28 00:35 /etc/rc.d/rc0.d/K15mongod -> ../init.d/mongod

[root@ip-10-251-86-194 ec2-user]# pgrep mongod
1179
[root@ip-10-251-86-194 ec2-user]# service mongod status
mongod is stopped

Comment by Ernie Hershey [ 27/May/14 ]

Hm, we've basically done that and can't reproduce the problem yet. We'll keep trying but can you post the output of the command I mentioned? Can you also show the output of "ps" or the command you're using to tell that the process is running?

Comment by Dharshan Rangegowda [ 27/May/14 ]

That would be my guess as well. I have the mongodb monitoring agent installed on the box. If I do "service mongod status" it shows up as "stopped" but the mongod process is running. Is it possible that somehow the MMS agent is trigger the process manually.

It is very simple to repro
1) Install mongod server, mongod shell, tools on box
2) Disable the mongod process - "chkconfig mongod off"
3) Reboot the box

Comment by Ernie Hershey [ 27/May/14 ]

dharshanr@scalegrid.net - is it possible something other than the normal mongod init script is starting up mongod?

To help troubleshoot, can you post the output of this command?

find /etc/ -name \*mongod -ls

Generated at Thu Feb 08 03:33:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.