I\'ve installed the mongodb 2.0.3, using the mongodb-10gen debian package. Everything went well, except the service which is installed by default is not starting up when com
Remember that when you restart the database by removing .lock files by force, the data might get corrupted. Your server shouldn't be considered "healthy" if you restarted the server that way.
To amend the situation, either run
mongod --repair
or
> db.repairDatabase();
in the mongo shell to bring your database back to "healthy" state.
Recall that according to official MongoDB documentation, the right command to start the service is (@Ubuntu): sudo service mongod start
(06/2018) (no mongodb
or mongo
).
Reference: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
What helped me diagnose the issue was to run mongod
and specify the /etc/mondgob.conf
config file:
mongod --config /etc/mongodb.conf
That revealed that some options in /etc/mongdb.conf were "Unrecognized". I had commented out both options under security:
and left alone only security:
on one line, which caused the service to not start. This looks like a bug.
security:
# authorization: enabled
# keyFile: /etc/ssl/mongo-keyfile
^^ error
#security:
# authorization: enabled
# keyFile: /etc/ssl/mongo-keyfile
^^ correctly commented.
Fixed!
The reason was the dbpath
variable in /etc/mongodb.conf
.
Previously, I was using mongodb 1.8, where the default value for dbpath was /data/db
.
The upstart job mongodb
(which comes with mongodb-10gen package) invokes the mongod
with --config /etc/mongodb.conf
option.
As a solution, I only had to change the owner of the /data/db
directory recursively.
Here's a weird one, make sure you have consistent spacing in the config file.
For example:
processManagement:
timeZoneInfo: /usr/share/zoneinfo
security:
authorization: 'enabled'
If the authorization key has 4 spaces before it, like above and the rest are 2 spaces then it won't work.
This can also happen if the disk is full at your logpath
path (e.g. if you have a dedicated /log/
directory/drive and it is full).
This had me panicking for a good 15 minutes because it also prevents you from reading the mongod.log
when starting the process, so difficult to troubleshoot.