unable to set replica set in mongodb3.2 - mongodb

I am trying to setup a demo replicaset from standalone MongoDB in MongoDB 3.2 with the following options in mongod.conf:
#replication:
oplogSizeMB: 10240
replSetName: "rs0"
But when I am trying to start mongodb it is throwing error:
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]
output of journalctl -xe says:
Jul 02 07:53:56 smartJN3-LTest-Blr1 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.
Jul 02 07:53:56 smartJN3-LTest-Blr1 runuser[29989]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
Jul 02 07:53:56 smartJN3-LTest-Blr1 runuser[29989]: pam_unix(runuser:session): session closed for user mongod
Jul 02 07:53:56 smartJN3-LTest-Blr1 mongod[29982]: Starting mongod: [FAILED]
Jul 02 07:53:56 smartJN3-LTest-Blr1 systemd[1]: mongod.service: control process exited, code=exited status=1
Jul 02 07:53:56 smartJN3-LTest-Blr1 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.
Jul 02 07:53:56 smartJN3-LTest-Blr1 systemd[1]: Unit mongod.service entered failed state.
Jul 02 07:53:56 smartJN3-LTest-Blr1 systemd[1]: mongod.service failed.
Jul 02 07:53:56 smartJN3-LTest-Blr1 polkitd[2089]: Unregistered Authentication Agent for unix-process:29977:8668980 (system bus name :1.114, object path /org
This is on CentOS 7.2 . Thanks
Anyone any help. Thanks

fixed it myself. stupid me, I didn't uncomment the section header replication, which is why the settings were never picked.

Related

Job for mongod.service failed because a fatal signal was delivered to the control process

I installe mongodb following this tutorial https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-red-hat/ but this is the result of sudo systemctl status mongod
[root#ns1 ~]# sudo systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: signal) since Wed 2022-07-06 00:31:55 +03; 14min ago
Docs: https://docs.mongodb.org/manual
Process: 561243 ExecStart=/usr/bin/mongod $OPTIONS (code=killed, signal=ILL)
Process: 561241 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 561239 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 561238 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
Jul 06 00:31:55 ns1.localhost.com systemd[1]: Starting MongoDB Database Server...
Jul 06 00:31:55 ns1.localhost.com systemd[1]: mongod.service: control process exited, code=killed status=4
Jul 06 00:31:55 ns1.localhost.com systemd[1]: Failed to start MongoDB Database Server.
Jul 06 00:31:55 ns1.localhost.com systemd[1]: Unit mongod.service entered failed state.
Jul 06 00:31:55 ns1.localhost.com systemd[1]: mongod.service failed.
journalctl -xe
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/multiseat
--
-- A new session with the ID c15063 has been created for the user root.
--
-- The leading process of the session is 561230.
Jul 06 00:31:55 ns1.localhost.com sudo[561230]: pam_unix(sudo:session): session opened for user root by root
Jul 06 00:31:55 ns1.localhost.com polkitd[458]: Registered Authentication Agent for unix-process:561232:1926
Jul 06 00:31:55 ns1.localhost.com systemd[1]: Starting MongoDB Database Server...
-- 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.
Jul 06 00:31:55 ns1.localhost.com kernel: traps: mongod[561243] trap invalid opcode ip:55b5947535da sp:7ffd0
Jul 06 00:31:55 ns1.localhost.com systemd[1]: mongod.service: control process exited, code=killed status=4
Jul 06 00:31:55 ns1.localhost.com systemd[1]: Failed to start MongoDB Database Server.
-- 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.
Jul 06 00:31:55 ns1.localhost.com systemd[1]: Unit mongod.service entered failed state.
Jul 06 00:31:55 ns1.localhost.com systemd[1]: mongod.service failed.
Jul 06 00:31:55 ns1.localhost.com polkitd[458]: Unregistered Authentication Agent for unix-process:561232:19
Jul 06 00:31:55 ns1.localhost.com sudo[561230]: pam_unix(sudo:session): session closed for user root
Jul 06 00:31:55 ns1.localhost.com systemd-logind[459]: Removed session c15063.
-- Subject: Session c15063 has been terminated
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Cannot start mongodb in ubuntu. "Job for mongodb.service failed because the control process exited with error code."

Tried running mongodb on my ubuntu 20.04
sudo systemctl start mongodb
in the shell returns -
Job for mongodb.service failed because the control process exited with error code.
See "systemctl status mongodb.service" and "journalctl -xe" for details.
And sudo systemctl status mongodb returns -
● mongodb.service - LSB: An object/document-oriented database
Loaded: loaded (/etc/init.d/mongodb; generated)
Active: failed (Result: exit-code) since Fri 2022-03-04 11:18:53 IST; 2s ago
Docs: man:systemd-sysv-generator(8)
Process: 82695 ExecStart=/etc/init.d/mongodb start (code=exited, status=1/FAILURE)
Mar 04 11:18:52 hp systemd[1]: Starting LSB: An object/document-oriented database...
Mar 04 11:18:52 hp mongodb[82695]: * Starting database mongodb
Mar 04 11:18:53 hp mongodb[82695]: ...fail!
Mar 04 11:18:53 hp systemd[1]: mongodb.service: Control process exited, code=exited, status=1/FAILURE
Mar 04 11:18:53 hp systemd[1]: mongodb.service: Failed with result 'exit-code'.
Mar 04 11:18:53 hp systemd[1]: Failed to start LSB: An object/document-oriented database.
what do I do?

Slapd won't start via service

Doing sudo service slapd start throws an error:
-- Unit slapd.service has begun starting up.
Apr 08 08:47:31 mail slapd[31144]: * Starting OpenLDAP slapd Apr 08
08:47:32 mail slapd[31149]: #(#) $OpenLDAP: slapd (Ubuntu) (May 30
2017 19:20:53)
$buildd#lgw01-18:/build/openldap-JXEADB/openldap-2.4.42+dfsg/debian/build/se
Apr 08 08:47:32 mail slapd[31149]: DIGEST-MD5 common mech free
Apr 08 08:47:32 mail slapd[31144]: ...fail!
Apr 08 08:47:32 mail systemd[1]: slapd.service: Control process exited,
code=exited status=1
Apr 08 08:47:32 mail systemd[1]: Failed to start LSB:
OpenLDAP standalone server (Lightweight Directory Access Protoco
-- Subject: Unit slapd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Unit slapd.service has failed.
-- The result is failed.
Apr 08 08:47:32 mail systemd[1]: slapd.service: Unit entered failed state.
Apr 08 08:47:32 mail systemd[1]: slapd.service: Failed with result 'exit-code'.
I did check directory permissions. Fine.
Starting sudo -u openldap slapd -d 1 is working fine, no errors thrown.
Any ideas why it won't start? The journalctl output is not helpful what exactly the error is.

MongoDB fails starting as a service on CentOS 7

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)

Mongodb fails to start -> presents weird error logs

When I moved my environment from my local (mac) to my server (ubuntu) I unzipped my directory and the server installed with npm install with no errors or warnings, but my database was failing so I decided to reinstall it based on this tutorial (well, apt-remove mongo* first)
https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04
but then I get a
Job for mongodb.service failed because the control process exited with error code. See "systemctl status mongodb.service" and "journalctl -xe" for details.
Does anyone know what any of this means?
-- Unit mongodb.service has begun starting up.
Jun 20 03:54:18 ip-172-31-16-163 mongodb[25271]: * Starting database mongodb
Jun 20 03:54:19 ip-172-31-16-163 mongodb[25271]: ...fail!
Jun 20 03:54:19 ip-172-31-16-163 systemd[1]: mongodb.service: Control process exited, code=exited status=1
Jun 20 03:54:19 ip-172-31-16-163 sudo[25268]: pam_unix(sudo:session): session closed for user root
Jun 20 03:54:19 ip-172-31-16-163 systemd[1]: Failed to start LSB: An object/document-oriented database.
-- Subject: Unit mongodb.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mongodb.service has failed.
--
-- The result is failed.
Jun 20 03:54:19 ip-172-31-16-163 systemd[1]: mongodb.service: Unit entered failed state.
Jun 20 03:54:19 ip-172-31-16-163 systemd[1]: mongodb.service: Failed with result 'exit-code'.
Looks familiar. Check ownership of files. Files in dbPath, mongod.run -lock file, keyfile...
Basically all those files what are listed at your /etc/mongod.conf
Run the following command and Its works for me
sudo apt-get install --reinstall mongodb