title: MongoDB fails starting as a service on CentOS 7
body: <p>I've a Google cloud VM with MongoDB server running for many months. Today the VM restarted and MongoDB won't run as a service (i can run it mannualy as a process and starts OK).</p>
  
  <ul>
  <li>OS: CentOS 7 </li>
  <li>MongoDB Verion: 3.2.16</li>
  </ul>
  
  <p><strong>The error thrown</strong>:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&gt;sudo service mongod start
  
  Starting mongod (via systemctl):  Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
                                                             [FAILED]</code></pre>
  </div>
  </div>
  </p>
  
  <p>So if i run "systemctl status mongod.service":</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&gt;sudo systemctl status mongod.service
  
  mongod.service - SYSV: Mongo is a scalable, document-oriented database.
     Loaded: loaded (/etc/rc.d/init.d/mongod; bad; vendor preset: disabled)
     Active: failed (Result: exit-code) since Mon 2018-02-05 18:05:49 UTC; 1min 20s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 3755 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=1/FAILURE)
  
  Feb 05 18:05:49 todoturnos-testing systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
  Feb 05 18:05:49 todoturnos-testing runuser[3762]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
  Feb 05 18:05:49 todoturnos-testing mongod[3755]: Starting mongod: [FAILED]
  Feb 05 18:05:49 todoturnos-testing systemd[1]: mongod.service: control process exited, code=exited status=1
  Feb 05 18:05:49 todoturnos-testing systemd[1]: Failed to start SYSV: Mongo is a scalable, document-oriented database..
  Feb 05 18:05:49 todoturnos-testing systemd[1]: Unit mongod.service entered failed state.
  Feb 05 18:05:49 todoturnos-testing systemd[1]: mongod.service failed.</code></pre>
  </div>
  </div>
  </p>
  
  <p>If i run "journalctl -xe"</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&gt;sudo journalctl -xe
  
  Feb 05 18:09:58 todoturnos-testing sudo[3827]: janokpodelmundi : TTY=pts/0 ; PWD=/usr/lib/tmpfiles.d ; USER=root ; COMMAND=/sbin/service mongod start
  Feb 05 18:09:58 todoturnos-testing polkitd[348]: Registered Authentication Agent for unix-process:3847:870363 (system bus name :1.242 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /or
  Feb 05 18:09:58 todoturnos-testing systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
  -- Subject: Unit mongod.service has begun start-up
  -- Defined-By: systemd
  -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
  -- 
  -- Unit mongod.service has begun starting up.
  Feb 05 18:09:58 todoturnos-testing runuser[3860]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
  Feb 05 18:09:58 todoturnos-testing runuser[3860]: pam_unix(runuser:session): session closed for user mongod
  Feb 05 18:09:58 todoturnos-testing mongod[3853]: Starting mongod: [FAILED]
  Feb 05 18:09:58 todoturnos-testing systemd[1]: mongod.service: control process exited, code=exited status=1
  Feb 05 18:09:58 todoturnos-testing systemd[1]: Failed to start SYSV: Mongo is a scalable, document-oriented database..
  -- Subject: Unit mongod.service has failed
  -- Defined-By: systemd
  -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
  -- 
  -- Unit mongod.service has failed.
  -- 
  -- The result is failed.
  Feb 05 18:09:58 todoturnos-testing systemd[1]: Unit mongod.service entered failed state.
  Feb 05 18:09:58 todoturnos-testing systemd[1]: mongod.service failed.
  Feb 05 18:09:58 todoturnos-testing polkitd[348]: Unregistered Authentication Agent for unix-process:3847:870363 (system bus name :1.242, object path /org/freedesktop/PolicyKit1/AuthenticationAgent,
  Feb 05 18:10:00 todoturnos-testing sudo[3866]: janokpodelmundi : TTY=pts/0 ; PWD=/usr/lib/tmpfiles.d ; USER=root ; COMMAND=/bin/journalctl -xe
  lines 2280-2321/2321 (END)</code></pre>
  </div>
  </div>
  </p>
  
  <p>Where "janokpodelmundi" is my username.</p>
  
  <p>So, i have disabled SELINUX as i know it could be related with this problem, but didn't resolved it.
  I've also changed the "pid" file location to ensure the permissions are OK,and had disabled forking in the config as well.</p>
  
  <p><strong>My mongodb config</strong>:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>systemLog:
    destination: file
    logAppend: true
    path: /var/log/mongodb/mongod.log
  
  # Where and how to store data.
  storage:
    dbPath: /var/lib/mongo
    journal:
      enabled: true
  #  engine:
  #  mmapv1:
  #  wiredTiger:
  
  # how the process runs
  processManagement:
    fork: true  # fork d run in background
    pidFilePath: /var/run/mongo/mongod.pid  # location of pidfile
  
  # network interfaces
  net:
    port: 27017
   bindIp: 0.0.0.0   # Listen to local interface only, comment to listen on all interfaces.</code></pre>
  </div>
  </div>
  </p>
  
  <p>The mongodb log is empty, and it's not generating rows at any time.</p>
  
  <p>I have been trying many alternatives i've found on internet but the problem persists. </p>
  
  <p>Any help would be great.</p>
  
  <p><strong>Solution</strong>:
  After trying the "mongod -f /path-to-config-file" and getting the "incorrect YAML" error at line 29, i pasted from original mongo conf the lines 26-29:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code># network interfaces
  net:
    port: 27017
    bindIp: 0.0.0.0  #</code></pre>
  </div>
  </div>
  </p>
  
  <p>After that i tried again the "mongod -f path-to-config-file" and succeed.</p>