Thursday, 30 January 2014

Mongodb service wont start

I recently come accros this situation, when  i start the mognod service, i  was getting the below error.

[root@ip-xx-xx-xxx-xx mongo]# /etc/init.d/mongod start
Starting mongod: about to fork child process, waiting until server is ready for connections.
forked process: 19972
all output going to: /var/log/mongo/mongod.log
ERROR: child process failed, exited with error number 45
                                                           [FAILED]
[root@ip-xx-xx-xxx-xx mongo]# /etc/init.d/mongod restart
Stopping mongod:                                           [FAILED]
Starting mongod: about to fork child process, waiting until server is ready for connections.
all output going to: /var/log/mongo/mongod.log
forked process: 20004
ERROR: child process failed, exited with error number 45
                                                           [FAILED]


To fix this issue, I   got some fixes to repair the mongodb instance.  So in screeen i tried the repair command with the mongodb db path(in my case it is /var/lib/mongo/ ),

[root@ip-xx-xx-xxx-xx mongo]# mongod --dbpath /var/lib/mongo/ --repair

Then i run

[root@ip-xx-xx-xxx-xx mongo]# mongod --dbpath /var/lib/mongo/&



This will fix the issue partially,  mongodb   service will start after this.  But this is not the  actual fix to this issue.

This  is an error due to the permission on the db path of mongodb.

In my case when i check,  the location /var/lib/mongo  it was owned by root and group root.  We need to chnage this to mongod

So i ran this command and  fixed the issue.

[root@ip-xx-xx-xxx-xx mongo]# cd /var/lib/
[root@ lib]# chown -R mongod.mongod mongo

Then you can start the mongod  service.

[root@ip-xx-xx-xxx-xx mongo]# /etc/init.d/mongod start
Starting mongod: Thu Jan 30 18:22:11.350
Thu Jan 30 18:22:11.370 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Thu Jan 30 18:22:11.370
about to fork child process, waiting until server is ready for connections.
all output going to: /var/log/mongo/mongod.log
forked process: 10293
child process started successfully, parent exiting
                                                           [  OK  ]
[root@ip-xx-xx-xxx-xx mongo]#

No comments:

Post a Comment