Im trying to run mongodb, as a service, in a different folder than the default one, located at /var/lib/mongodb in a kubuntu 20.04. I can run mongodb in a different folder but not as a service with the command mongod --dbpath /my-desired-path/
to run it in a custom folder, and I want to set this behavior running mongodb as a service. What Ive tried:
Setting the dbpath in the config file of mongodb and after changing the permissions of the folder given in dbpath to user mongodb and group mongodb. It doesn't works.
Moving the actual folder /var/lib/mongodb to my desired location and after putting a symlink to it in the original location. It neither works.
These two are the unique "solutions" that I found googling around but neither works. To run mongodb as a service I used sudo systemctl start mongod
, what executes silently, after checking it status using sudo systemctl start mongod
it throws the following error when I used the "solution" described in 1. above:
mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2020-09-27 13:05:52 CEST; 4s ago
Docs: https://docs.mongodb.org/manual
Process: 17895 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=1/FAILURE)
Main PID: 17895 (code=exited, status=1/FAILURE)
sep 27 13:05:52 buba-System systemd[1]: Started MongoDB Database Server.
sep 27 13:05:52 buba-System mongod[17895]: {"t":{"$date":"2020-09-27T11:05:52.978Z"},"s":"F", "c":"CONTROL", "id":20574, "ctx":"main","msg":>
sep 27 13:05:52 buba-System systemd[1]: mongod.service: Main process exited, code=exited, status=1/FAILURE
sep 27 13:05:52 buba-System systemd[1]: mongod.service: Failed with result 'exit-code'.
Using the "solution" 2. it throws a similar non-informative error. However passing this config file running mongod not as a service as mongod --config /etc/mongod.conf
it works with no error. I need some help.
0 Answers