Can't start MongoDB v4.0 - mongodb

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

Related

Changing mongo dbpath to external drive causes server failure

I'm trying to use an external drive to store my mongo collections. As per this question, I changed dbPath in /etc/mongod.conf from /var/lib/mongodb to /media/user/drive/mongodb. I also chown'd the new path to the mongodb user.
However, when I sudo service start mongod, I cannot start the server:
mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-12-07 22:27:09 CET; 2s ago
Docs: https://docs.mongodb.org/manual
Process: 63819 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=100)
Main PID: 63819 (code=exited, status=100)
Dec 07 22:27:09 user-ThinkPad-T480s systemd[1]: Started MongoDB Database Server.
Dec 07 22:27:09 user-ThinkPad-T480s systemd[1]: mongod.service: Main process exited, code=exited, status=100/n/a
Dec 07 22:27:09 user-ThinkPad-T480s systemd[1]: mongod.service: Failed with result 'exit-code'.
When I change dbPath back to /var/lib/mongodb it starts again. How can I fix this such that I can use the path on my external drive?
Not sure which OS you run and which version of MongoDB.
On Amazon Linux 2 it's mongod user not mongodb for MongoDB-5.0
Make sure you ran chown with -R flag
-rw-r----- 1 mongod mongod 8.6M Dec 10 00:59 mongod.log
Also check logs for more hints, default location should be under
/var/log/mongodb/mongod.log

mongoDB compass doesn't work! how to make it work .error mongodb-compass

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.

Unable to start MongoDB server on Ubuntu 20.04

I'm installing the latest MongoDB on Ubuntu 20.04 (Focal Fossa), and it's giving the below error. How can I fix it?
sudo systemctl status mongod
mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2020-08-28 23:40:03 IST; 1min 43s ago
Docs: https://docs.mongodb.org/manual
Main PID: 10901 (code=exited, status=217/USER)
systemd[1]: Started MongoDB Database Server.
systemd[10901]: mongod.service: Failed to determine user credentials: No such process
systemd[10901]: mongod.service: Failed at step USER spawning /usr/bin/mongod: No such process
systemd[1]: mongod.service: Main process exited, code=exited, status=217/USER
systemd[1]: mongod.service: Failed with result 'exit-code'.
systemd[1]: /lib/systemd/system/mongod.service:11: PIDFile= references a path below legacy directory >
Changing ownership of "/var/lib/mongodb" directory worked for me.
Command to change ownership:
sudo chown -R mongodb:mongodb /var/lib/mongodb

Connect mongodb 4.0 with robomongo

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!!!

Mongodb service fails to start on Ubuntu 16.04

When I attempt to start the mongodb service using the command sudo service mongod start, it doesn't work. Upon closer inspection with 'sudo service mongod status` the following is found:
● mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2017-09-18 21:00:29 CEST; 7s ago
Docs: https://docs.mongodb.org/manual
Process: 21352 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=1/FAIL
Main PID: 21352 (code=exited, status=1/FAILURE)
Sep 18 21:00:29 zeus systemd[1]: Started High-performance, schema-free document-oriented databas
Sep 18 21:00:29 zeus systemd[1]: mongod.service: Main process exited, code=exited, status=1/FAIL
Sep 18 21:00:29 zeus systemd[1]: mongod.service: Unit entered failed state.
Sep 18 21:00:29 zeus systemd[1]: mongod.service: Failed with result 'exit-code'.
The configuration file has been changed to the following:
# Where and how to store data.
storage:
dbPath: /tank/mongo/mongodb
journal:
enabled: true
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /tank/mongo/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
The mongodb user been given access to the \tank\mongodirectory using the command: sudo chown -R mongodb:users /tank/mongo.
It turns out that I was supposed to give permission to mongodb:mongodb, and not only that; the child folders didn't inherit the permissions, so I had to give the permissions at the folder levels specified in the config /tank/mongo/log/mongodb/, /tank/mongo/mongodb.
I leave the answer in case it might help someone who is in a similar situation.