0

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?

snapcrack
  • 1,761
  • 3
  • 20
  • 40

1 Answers1

0

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

General Zod
  • 27
  • 1
  • 5