I want to be able to do sudo service mongod start
with the option of giving it the path to the configuration file /etc/mongod.conf
.
So far I have been able to run mongod as daemon by setting the processManagement.fork
variable in /etc/mongod.conf
to true as such:
# mongod.conf
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
processManagement:
fork: true
then running the command:
>> mongod --config /etc/mongod.conf
However, I think it would be best to run it as a service so I can easily start
and stop
it without having to kill the daemon process every time I want to stop the mongod server.
Try add your mongo bin directory to path
export PATH=$PATH:/path/to/mongodb/bin
copy the content from here mongodb GitHub repo
Now see you service in
service --status-all
PS: you should have access to create file in /etc/init.d folder and make nessesary changes as per your system requirement
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With