When I tried starting MongoDB service using "systemctl start mongodb
" command nothing happens.
But when I use mongod command in terminal. The server starts so what should I do to start MongoDB as a service
The output result of mongod and mongo command are in the image link
https://i.stack.imgur.com/jsGZT.png
I also tried to get the status before using mongod command using "systemctl status mongodb" command in the terminal and below is the output result
root#lc-1gb-blr1-01:~# systemctl status mongodb
● mongodb.service - High-performance, schema-free document-oriented database
Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2019-07-01 10:49:50 UTC; 3h 49min ago
Main PID: 8695 (code=exited, status=100)
Related
I have created a mongod configuration in /home/cluster1.conf with the same port I used previously for etc/mongod.conf.
I used to run etc/mongod.conf as a sudo user but expect to run cluster1.conf as user.
when I run cluster1.conf as user, the process starts. I accessed it from mongo shell and did operations. But when I'm trying to access it from another vm from the same VPC, it failed.
I checked for systemctl status mongod and it shows service is not running.
Why does systemctl status shows it not running when it really does? How can I resolve this to create a replica set??
"when I run cluster1.conf as user, the process starts." does not make much sense. cluster1.conf is a configuration file, it does not start anything.
When you run systemctl status mongod, then it typically shows
● mongod.service - MongoDB Database Server
Loaded: loaded (/etc/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2021-08-27 09:44:26 CEST; 2 weeks 3 days ago
Docs: https://docs.mongodb.org/manual
Main PID: 38710 (mongod)
Tasks: 28
Memory: 270.8M
CGroup: /system.slice/mongod.service
└─38710 /usr/bin/mongod -f /etc/mongod.conf
Check the service file /etc/systemd/system/mongod.service there you see entry like
Environment="OPTIONS=-f /etc/mongod.conf"
EnvironmentFile=-/etc/sysconfig/mongod
ExecStart=/usr/bin/mongod $OPTIONS
Which means, config file /etc/mongod.conf is used (rather than /home/cluster1.conf)
mongoDB compass doesn't work!
installed on this site
before that there was also a problem, I had to reinstall ubuntu in Russian
[23114:0923/070140.222706:FATAL:gpu_data_manager_impl_private.cc(894)] The display compositor is frequently crashing. Goodbye.
Additional Information
sudo systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor>
Active: active (running) since Thu 2021-09-23 06:44:41 EEST; 18s ago
Docs: https://docs.mongodb.org/manual
Main PID: 18125 (mongod)
Memory: 60.7M
CPU: 685ms
CGroup: /system.slice/mongod.service
└─18125 /usr/bin/mongod --config /etc/mongod.conf
sep 23 06:44:41 d991 systemd[1]: Started MongoDB Database Server.
Here are the logs for my mongodb status which show in it is in running status
ubuntu#ip-172-31-9-130:/etc$ sudo service mongod status
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset:
Active: active (running) since Fri 2018-09-28 09:50:43 UTC; 37min ago
Docs: https://docs.mongodb.org/manual
Main PID: 28315 (mongod)
CGroup: /system.slice/mongod.service
└─28315 /usr/bin/mongod --config /etc/mongod.conf
Sep 28 09:50:43 ip-172-31-9-130 systemd[1]: Started MongoDB Database Server.
Sep 28 09:50:43 ip-172-31-9-130 mongod[28315]: 2018-09-28T09:50:43.848+0000 I CO
lines 1-10/10 (END)
But when I connect it with robomongo it throws error
Failed to connect to the server
Please help!!!
I just installed MongoDB v4.0.2 and after I try to start the service:
sudo systemctl start mongodb
and then get its status:
sudo systemctl status mongodb
I get this:
mongodb.service - High-performance, schema-free document-oriented database
Loaded: loaded (/etc/systemd/system/mongodb.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2018-09-21 15:00:05 UTC; 1s ago
Process: 3460 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (code=exited, status=100)
Main PID: 3460 (code=exited, status=100)
What's happening?
EDIT: I STORAGE [initandlisten] exception in initAndListen: DBPathInUse: Unable to lock the lock file: /var/lib/mongodb/mongod.lock (Unknown error). Another mongod instance is already running on the /var/lib/mongodb directory, terminating
command mongo gives the interactive shell on command but when this command is executed as sudo systemctl enable mongod.service, it gives following output.
Failed to enable unit: Unit file mongod.service does not exist.
I am using ubuntu 17 machine.
also sudo systemctl start mongodb doesn't give any output.
on running sudo service mongodb status
it gives output as
● mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2018-02-15 23:08:02 IST; 1min 37s ago
Docs: man:mongod(1)
Process: 19137 ExecStart=/usr/bin/mongod --unixSocketPrefix=${SOCKETPATH} --config ${CONF} $DAEMON_OPTS (code=exited, status=100)
Main PID: 19137 (code=exited, status=100)
Feb 15 23:08:02 gd systemd[1]: Started An object/document-oriented database.
Feb 15 23:08:02 gd systemd[1]: mongodb.service: Main process exited, code=exited, status=100/n/a
Feb 15 23:08:02 gd systemd[1]: mongodb.service: Unit entered failed state.
Feb 15 23:08:02 gd systemd[1]: mongodb.service: Failed with result 'exit-code'.
how can I solve this problem?
Your mongo service is called mongodb, pretty sure it should called mongod like you tried! Similar question here.
If your service is called mongodb you could so try:
sudo systemctl enable mongodb.service
When starting a service it wont give you any output and just returns back to the prompt. You can use systemctl status like you’ve done or you look st journalctl
If you’re using systemctl then you can check the service status by running:
sudo systemctl status mongodb.service