Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-16240

RHEL sysvinit script causes error on el6.6

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Duplicate
    • Affects Version/s: 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5
    • Fix Version/s: None
    • Component/s: Packaging
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      1) upgrade RHEL/CentOS/Scientific to 6.6
      2) /etc/init.d/mongod start

      Show
      1) upgrade RHEL/CentOS/Scientific to 6.6 2) /etc/init.d/mongod start

      Description

      Mongo 2.6.x sysv init script for EL6 isn't working correctly on 6u6. This is the output that standard start call returns:

      # /etc/init.d/mongod restart                                                                                                                                                           
      Stopping mongod:                                           [  OK  ]
      Starting mongod: /usr/bin/dirname: extra operand `2>&1.pid'
      Try `/usr/bin/dirname --help' for more information.
                                                                 [  OK  ]

      Problem is that RedHat changed /etc/rc.d/init.d/functions, in a way that function __pids_var_run() contains new entry:

              local pid_dir=$(/usr/bin/dirname $pid_file)

      This is wrongly interpreted in daemon() function that Mongo uses. Problem is that $base is considered complete line:

      "$NUMACTL $mongod $OPTIONS >/dev/null 2>&1"

      This causes side effect:

      + base='null 2>&1'
      + __pids_var_run 'null 2>&1' '' 
      + local 'base=null 2>&1'
      + local 'pid_file=/var/run/null 2>&1.pid'
      ++ /usr/bin/dirname /var/run/null '2>&1.pid'
      /usr/bin/dirname: extra operand `2>&1.pid'
      Try `/usr/bin/dirname --help' for more information.
      + local pid_dir=

      and thus spitting out errors.

      Solution is to use '--check' parameter for daemon() call. Here is proposing patch:

      --- /etc/init.d/mongod  2014-10-08 10:29:50.000000000 -0700
      +++ /tmp/mongod.patched 2014-11-19 10:42:41.000000000 -0800
      @@ -27,6 +27,7 @@
       PIDDIR=`dirname $PIDFILE`
       
       mongod=${MONGOD-/usr/bin/mongod}
      +servicename=mongod
       
       MONGO_USER=mongod
       MONGO_GROUP=mongod
      @@ -63,7 +64,7 @@
         ulimit -u 32000
       
         echo -n $"Starting mongod: "
      -  daemon --user "$MONGO_USER" "$NUMACTL $mongod $OPTIONS >/dev/null 2>&1"
      +  daemon --check $servicename --user "$MONGO_USER" "$NUMACTL $mongod $OPTIONS >/dev/null 2>&1"
         RETVAL=$?
         echo
         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: