I have a CentOS 7 empty VM.
> hostnamectl
...
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.18.26-guest-4-4751b4a-x86_64
Architecture: x86_64
I've installed MongoDB.
> mongod --version
db version v3.0.11
git version: 48f8b49dc30cc2485c6c1f3db31b723258fcbf39
The config file:
> cat /etc/mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /mongo/logs #/var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /mongo/data # (default) /var/lib/mongo
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp:
When I try to start I get this error:
> service mongod start
Starting mongod (via systemctl): Job for mongod.service failed. See 'systemctl status mongod.service' and 'journalctl -xn' for details
and:
> journalctl -xn
-- Subject: Unit mongod.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mongod.service has begun starting up.
avril 02 14:03:06 keystone runuser[30886]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
avril 02 14:03:06 keystone runuser[30886]: pam_unix(runuser:session): session closed for user mongod
avril 02 14:03:06 keystone mongod[30879]: Starting mongod: [FAILED]
avril 02 14:03:06 keystone systemd[1]: mongod.service: control process exited, code=exited status=1
avril 02 14:03:06 keystone 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.
avril 02 14:03:06 keystone systemd[1]: Unit mongod.service entered failed state.
Has anyone encountered the issue "Failed to start SYSV"?
Any help or hint is welcome.
Thanks, Paul
The root issue is selinux permissions, which is enabled by default in CentOS 7. This can be fixed by disabling selinux or adding the correct context to the mongo database path:
chcon -R -t mongod_var_lib_t /var/lib/mongod
Related
I've tried this on CentOS 7 and 8 and I'm getting the same result. Also tried with different versions of MongoDB. I'm trying to run a Pritunl VPN on a hyper-v VM and have followed this tutorial for installing mongodb and this tutorial for setting everything up with the exception that I'm using a VM rather than a VPS.
When I run "systemctl start mongod" I get the error "Job for mongod.service failed because a fatal signal was delivered causing the control process to dump core.
See "systemctl status mongod.service" and "journalctl -xe" for details."
Running journalctl -xe yields something along the lines of the code included below. I tried disabling core dump and the "Process" number changed from 3397 to 4143. Also included the output of systemctl status mongod.service.
This is my first time working with something like this so there's a high possibility I'm missing something simple. I keep seeing mention of directory files in some of the solution posts but according to the mongodb install instructions it should create it's own directories. Any help is appreciated because I am beyond lost.
journalctl -xe:
-- Unit mongod.service has begun starting up.
Dec 22 14:54:12 localhost.localdomain kernel: traps: mongod[33894] trap invalid opcode ip:558aaaedaeda sp:7ffd3f5a6560 error>
Dec 22 14:54:12 localhost.localdomain systemd[1]: Started Process Core Dump (PID 33895/UID 0).
-- Subject: Unit systemd-coredump#8-33895-0.service has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit systemd-coredump#8-33895-0.service has finished starting up.
--
-- The start-up result is done.
Dec 22 14:54:12 localhost.localdomain systemd-coredump[33896]: Resource limits disable core dumping for process 33894 (mongo>
Dec 22 14:54:12 localhost.localdomain systemd-coredump[33896]: Process 33894 (mongod) of user 974 dumped core.
-- Subject: Process 33894 (mongod) dumped core
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- Documentation: man:core(5)
--
-- Process 33894 (mongod) crashed and dumped core.
--
-- This usually indicates a programming error in the crashing program and
-- should be reported to its vendor as a bug.
Dec 22 14:54:12 localhost.localdomain systemd[1]: mongod.service: Control process exited, code=dumped status=4
Dec 22 14:54:12 localhost.localdomain systemd[1]: mongod.service: Failed with result 'core-dump'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- The unit mongod.service has entered the 'failed' state with result 'core-dump'.
Dec 22 14:54:12 localhost.localdomain systemd[1]: Failed to start MongoDB Database Server.
-- Subject: Unit mongod.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit mongod.service has failed.
--
-- The result is failed.
Dec 22 14:54:12 localhost.localdomain systemd[1]: systemd-coredump#8-33895-0.service: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- The unit systemd-coredump#8-33895-0.service has successfully entered the 'dead' state.
status of mongod.service:
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: core-dump) since Wed 2021-12-22 14:54:12 EST; 5min ago
Docs: https://docs.mongodb.org/manual
Process: 33894 ExecStart=/usr/bin/mongod $OPTIONS (code=dumped, signal=ILL)
Process: 33892 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 33890 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 33888 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
Dec 22 14:54:12 localhost.localdomain systemd[1]: Starting MongoDB Database Server...
Dec 22 14:54:12 localhost.localdomain systemd-coredump[33896]: Process 33894 (mongod) of user 974 dumped core.
Dec 22 14:54:12 localhost.localdomain systemd[1]: mongod.service: Control process exited, code=dumped status=4
Dec 22 14:54:12 localhost.localdomain systemd[1]: mongod.service: Failed with result 'core-dump'.
Dec 22 14:54:12 localhost.localdomain systemd[1]: Failed to start MongoDB Database Server.
mongod.conf:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
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:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
"/etc/mongod.conf" 44L, 830C
mongod.service:
[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network-online.target
Wants=network-online.target
[Service]
User=mongod
Group=mongod
Environment="OPTIONS=-f /etc/mongod.conf"
EnvironmentFile=-/etc/sysconfig/mongod
ExecStart=/usr/bin/mongod $OPTIONS
ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb
ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb
ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb
PermissionsStartOnly=true
PIDFile=/var/run/mongodb/mongod.pid
Type=forking
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false
# Recommended limits for mongod as specified in
# https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings
[Install]
WantedBy=multi-user.target
~
I've installed mongodb on centos 7, but I can't start the service with systemctl.
Running mongod starts successfully.
I've followed all the instructions from here: https://mongoing.com/docs/tutorial/install-mongodb-on-red-hat.html
systemctl status mongod returns this:
* mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mongod.service.d
`-override.conf
Active: failed (Result: timeout) since Sun 2020-05-03 14:58:02 CEST; 4min 27s ago
Docs: https://docs.mongodb.org/manual
Process: 528 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS)
Process: 525 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 522 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 519 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
May 03 14:56:32 zakazise systemd[1]: Starting MongoDB Database Server...
May 03 14:56:32 zakazise mongod[528]: about to fork child process, waiting until server is ready for connections.
May 03 14:56:32 zakazise mongod[528]: forked process: 530
May 03 14:56:34 zakazise systemd[1]: Can't open PID file /var/run/mongodb/mongod.pid (yet?) after start: Too many levels of symbolic links
May 03 14:58:02 zakazise systemd[1]: mongod.service start operation timed out. Terminating.
May 03 14:58:02 zakazise systemd[1]: Failed to start MongoDB Database Server.
May 03 14:58:02 zakazise systemd[1]: Unit mongod.service entered failed state.
May 03 14:58:02 zakazise systemd[1]: mongod.service failed.
There is a line in /var/log/mongodb/mongod.log , that I think might be important:
2020-05-03T14:58:02.210+0200 I CONTROL [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
/etc/mongod.conf:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
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:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp:
/etc/systemd/system/multi-user.target.wants/mongod.service:
[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network.target
[Service]
User=mongod
Group=mongod
Environment="OPTIONS=-f /etc/mongod.conf"
EnvironmentFile=-/etc/sysconfig/mongod
ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb
ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb
ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb
ExecStart=/usr/bin/mongod $OPTIONS
PermissionsStartOnly=true
PIDFile=/var/run/mongodb/mongod.pid
Type=forking
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false
# Recommended limits for for mongod as specified in
# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
[Install]
WantedBy=multi-user.target
I didn't change anything in mongod.conf and mongod.service. This is a fully fresh install.
Steps I've tried:
touch /var/run/mongodb/mongod.pid
chown mongod:mongod/var/run/mongodb/mongod.pid
I've checked every path with mongo in it, and they have the right
privileges. (mongod:mongod)
Checked that SELinux is disabled.
Allowed 27017 in ufw.
EDIT
/var/run/mongodb has every rwx.
I'm logged in as root
These two paths are different:
May 02 21:53:44 zakazise systemd[1]: Can't open PID file /var/run/mongodb/mongod.pid (yet?) after start: Too many levels of symbolic links
pidFilePath: /var/run/mongo/mongod.pid # location of pidfile
I'm trying to connect remotely to my Google Cloud Server with Robo 3T to connect too MongoDB v4.0.11 just so I can see the data from windows.
I am running Ubuntu 18.04LTS Minimal. To enable remote connections to MongoDB I have first created both an administrative and root user in my admin database.
My problem is once I add authorization: "enabled" to security: in /etc/mongod.conf and restart MongoDB, I get the following status when running $:systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-08-06 16:43:51 BST; 1min 20s ago
Docs: https://docs.mongodb.org/manual
Process: 6517 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=2)
Main PID: 6517 (code=exited, status=2)
Aug 06 16:43:51 instance-1 systemd[1]: Started MongoDB Database Server.
Aug 06 16:43:51 instance-1 mongod[6517]: Unrecognized option: processManagement.authorization
Aug 06 16:43:51 instance-1 mongod[6517]: try '/usr/bin/mongod --help' for more information
Aug 06 16:43:51 instance-1 systemd[1]: mongod.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Aug 06 16:43:51 instance-1 systemd[1]: mongod.service: Failed with result 'exit-code'.
Example of /etc/mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
authorization: "enabled"
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
It appears there is an invalid argument in /etc/mongod.conf but from what I have read online I can't see the problem.
wrong:
#security:
authorization: "enabled"
correct:
security:
authorization: enabled
For the 4.x release it appears you need to modify the existing security section you have listed
#security:
authorization: "enabled"
And replace it with security.authorization: enabled or
security:
authorization: "enabled"
You should then be able to reload and test authentication is working as expected.
If you dig into the docs you will find the relevant section here.
security.authorization
Type: string
Default: disabled
Enable or disable Role-Based Access Control (RBAC) to govern each user’s access to database resources and operations.
Set this option to one of the following:
Value Description
enabled A user can access only the database resources and actions for which they have been granted privileges.
disabled A user can access any database and perform any action.
In my case the problem was that I used a tab to indent the authorization: enabled line. When I replaced the tab with 2 spaces it worked.
I followed this link to install MongoDB on my machine. Everything was fine and it worked.
Currently, when I run sudo systemctl status mongod, I get this error:
● mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since سه<U+200C>شنبه 2019-05-21 15:50:14 +0430; 25min ago
Docs: https://docs.mongodb.org/manual
Process: 5278 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=1/FAILURE)
Main PID: 5278 (code=exited, status=1/FAILURE)
مه 21 15:50:14 [my-username] systemd[1]: Started High-performance, schema-free document-oriented database.
مه 21 15:50:14 [my-username] systemd[1]: mongod.service: Main process exited, code=exited, status=1/FAILURE
مه 21 15:50:14 [my-username] systemd[1]: mongod.service: Unit entered failed state.
مه 21 15:50:14 [my-username] systemd[1]: mongod.service: Failed with result 'exit-code'.
This is what I have done after it was ok, that might have caused the problem:
I decided to add mongodb extension using pecl.
I was not able to make a new database, neither by MongodDB Compassm, nor by Sell.
I uninstalled it.
I installed it from the same link and ran the same commands, but when I wanted to install it again, after running sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
command, I got gpg: unchanged: 1 at the end, not gpg: imported: 1 (RSA: 1) which I got for the first time.
I even deleted and recreated my dbPath folder (/var/lib/mongodb) which seems that the problem is somehow associated with this parameter which is on /etc/mongod.conf.
When I run sudo systemctl status mongod, I still get Active: failed.
What should I do to run MongoDB properly again and make its status Active: Running?
Update: This is my /etc/mongod.conf file:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
#processManagement:
security:
authorization: "enabled"
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
I solved the problem by uninstalling MongoDB and installing a specific version of MongoDB, not the latest version, using this link. This might not be the actual solution but works for now.
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).
OS: CentOS 7
MongoDB Verion: 3.2.16
The error thrown:
>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]
So if i run "systemctl status mongod.service":
>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.
If i run "journalctl -xe"
>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)
Where "janokpodelmundi" is my username.
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.
My mongodb config:
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.
The mongodb log is empty, and it's not generating rows at any time.
I have been trying many alternatives i've found on internet but the problem persists.
Any help would be great.
Solution:
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:
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 #
After that i tried again the "mongod -f path-to-config-file" and succeed.
YAML files require spaces for indentation and not tabs. Seems that you have a funny character/indent within your conf file. The easiest way to debug this is to start off with a basic conf file and add in options and make sure your indents etc are correct before adding another option
As mentioned above , the issue may be caused because files isn't in Yaml format
run :
mongod -f /etc/mongod.conf
you will get in what line the issue is (fix the extra spaces and issue will be solved)