{"id":12390,"date":"2016-08-10T08:30:50","date_gmt":"2016-08-10T03:00:50","guid":{"rendered":"http:\/\/blog.taragana.com\/?p=12390"},"modified":"2016-08-10T08:30:50","modified_gmt":"2016-08-10T03:00:50","slug":"possible-causes-solutions-for-mongodb-not-running","status":"publish","type":"post","link":"https:\/\/blog.taragana.com\/possible-causes-solutions-for-mongodb-not-running-12390","title":{"rendered":"Possible causes & solutions for MongoDB not running"},"content":{"rendered":"

Is your MongoDB properly running? A simple way to check it would be with:<\/p>\n

service mongod status<\/pre>\n

On my CentOS 5.x it gave:<\/p>\n

mongod dead but subsys locked<\/pre>\n

There are two possible causes I could find. First is related to disk space. If you do not have enough space for dbpath (database directory) then you may get this message.<\/p>\n

\nTo solve it you can add following to the config file provided when running mongod --config mongod.conf<\/code>
\nFor MongoDB 3.x<\/strong> (latest version)<\/p>\n
storage<\/span>:<\/span>\n   mmapv1<\/span>:<\/span>\n      smallFiles<\/span>:<\/span> true<\/span><\/code><\/pre>\n

For version 2.6+<\/strong><\/p>\n

storage<\/span>:<\/span>\n   smallFiles<\/span>:<\/span> true<\/span><\/code><\/pre>\n

For version 2.4<\/strong> and less<\/p>\n

smallfiles <\/span>=<\/span> true<\/span><\/code><\/pre>\n

Then just execute mongod to accept your config file (here it assumes that location of the config is \/etc\/mongodb.conf<\/em>):<\/p>\n

mongod <\/span>-<\/span>f <\/span>\/<\/span>etc<\/span>\/<\/span>mongodb<\/span>.<\/span>conf<\/span><\/code><\/pre>\n

Documentation<\/a> for smallfiles<\/strong> parameter:<\/p>\n

Set<\/span> to <\/span>true<\/span> to modify <\/span>MongoDB<\/span> to use a smaller <\/span>default<\/span> data file size<\/span>.<\/span>\nSpecifically<\/span>,<\/span> smallfiles reduces the initial size <\/span>for<\/span> data files and\nlimits them to <\/span>512<\/span> megabytes<\/span>.<\/span> The<\/span> smallfiles setting also reduces the\nsize of each journal files from <\/span>1<\/span> gigabyte to <\/span>128<\/span> megabytes<\/span>.<\/span><\/code><\/pre>\n<\/div>\n
Alternatively you can run mongod with --smallfiles parameter like:\nmongod --smallfiles<\/pre>\n

On my machine the problem was different. It was expecting a directory \/var\/lib\/mongod with proper permissions, which was not there. The solution is simple:<\/p>\n

sudo mkdir \/var\/lib\/mongod\nsudo chown -R mongod \/var\/lib\/mongod<\/pre>\n

However how did I find out about the problem(s) in the first place. Again the solution is very simple. I looked in the log file:<\/p>\n

vi \/var\/log\/mongodb\/mongodb.log<\/pre>\n

Always start with the log file.
\nFinally you can verify that your system is running properly with:<\/p>\n

sudo service mongod status<\/pre>\n

After fixing it gave:<\/p>\n

mongod (pid 26194) is running...<\/pre>\n

Now that’s solved, let’s get back to mongodb coding..<\/p>\n","protected":false},"excerpt":{"rendered":"

Is your MongoDB properly running? A simple way to check it would be with: service mongod status On my CentOS 5.x it gave: mongod dead but subsys locked There are two possible causes I could find. First is related to disk space. If you do not have enough space for dbpath (database directory) then you […]<\/p>\n","protected":false},"author":1,"featured_media":12391,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,12],"tags":[72],"_links":{"self":[{"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/posts\/12390"}],"collection":[{"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/comments?post=12390"}],"version-history":[{"count":0,"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/posts\/12390\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.taragana.com\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/media?parent=12390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/categories?post=12390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/tags?post=12390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}