I am using mongodb 3.6.3 on a centos 7 aws ec2 instance.
2 Questions (only one needs to be answered):
sudo mongod --storageEngine etc
sudo service mongod status
showing the failure that it is?When I run the below command, (since currently, sudo service mongod start
isn't working but the below works) it fails when I specify the --logpath
but will run without it. Unfortunately, when I run it without it, all of my logs end up in the /
which is absolutely the wrong location.
sudo mongod --storageEngine wiredTiger --dbpath /data --bind_ip 127.0.0.1,apiIP --logpath /var/log/mongodb/mongod.log --auth --fork
Below is what happens when I try to run that above line as is.
I CONTROL [main] log file "/var/log/mongodb/mongod.log" exists; moved to "/var/log/mongodb/mongod.log.2018-03-16T15-16-01".
From what I can tell, it is conflicting with the currently existent
Just for reference, sudo service mongod status
returns:
mongod.service - mongodb database
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2018-03-16 15:11:53 UTC; 9min ago
Process: 26620 ExecStart=/usr/bin/mongod $OPTIONS run (code=exited, status=2)
Main PID: 26620 (code=exited, status=2)
Mar 16 15:11:53 ip-* systemd[1]: Started mongodb database.
Mar 16 15:11:53 ip-* systemd[1]: Starting mongodb database...
Mar 16 15:11:53 ip-* mongod[26620]: F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open "/var/log/mongodb/mongod.log"
Mar 16 15:11:53 ip-* systemd[1]: mongod.service: main process exited, code=exited, status=1/FAILURE
Mar 16 15:11:53 ip-* systemd[1]: Unit mongod.service entered failed state.
Mar 16 15:11:53 ip-* systemd[1]: mongod.service failed.
/etc/mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /data
# logpath: /log/mongod.log
journal:
enabled: true
engine: wiredTiger
# mmapv1:
# wiredTiger:
# how the process runs
processManagement:
# fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1, apiIP
Thanks to @AlexBlex for noticing the spacing issue in the yaml file.
With that sorted, the status error has this line
Unrecognized option: storage.wiredTiger
mongod is the primary daemon process for the MongoDB system. It handles data requests, manages data access, and performs background management operations.
MongoDB runs as a standard program. You can start MongoDB from a command line by issuing the mongod command and specifying options. For a list of options, see the mongod reference. MongoDB can also run as a Windows service.
cd /var/log
sudo mkdir -m 777 mongodb
sudo service mongod start
sudo service mongod status
Hopefully, that's will do!
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