Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't start mongodb as sudo

Tags:

mongodb

mongodb is returning errors related to access files when trying to start:

root@mongo01:~# sudo service mongodb start
mongodb start/running, process 4118
root@mongo01:~# Mon Jul 25 17:03:54 [initandlisten] MongoDB starting : pid=4118 port=27017 dbpath=/var/lib/mongodb 64-bit 
Mon Jul 25 17:03:54 [initandlisten] db version v1.8.2, pdfile version 4.5
Mon Jul 25 17:03:54 [initandlisten] git version: 433bbaa14aaba6860da15bd4de8edf600f56501b
Mon Jul 25 17:03:54 [initandlisten] build sys info: Linux bs-linux64.10gen.cc 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
Mon Jul 25 17:03:54 [initandlisten] couldn't open /var/lib/mongodb/adrise.ns errno:13 Permission denied
Mon Jul 25 17:03:54 [initandlisten] error couldn't open file /var/lib/mongodb/adrise.ns terminating
Mon Jul 25 17:03:54 dbexit: 
Mon Jul 25 17:03:54 [initandlisten] shutdown: going to close listening sockets...
Mon Jul 25 17:03:54 [initandlisten] shutdown: going to flush diaglog...
Mon Jul 25 17:03:54 [initandlisten] shutdown: going to close sockets...
Mon Jul 25 17:03:54 [initandlisten] shutdown: waiting for fs preallocator...
Mon Jul 25 17:03:54 [initandlisten] shutdown: closing all files...
Mon Jul 25 17:03:54 closeAllFiles() finished
Mon Jul 25 17:03:54 [initandlisten] shutdown: removing fs lock...
Mon Jul 25 17:03:54 dbexit: really exiting now

or

Mon Jul 25 17:03:22 [initandlisten] MongoDB starting : pid=4095 port=27017 dbpath=/var/lib/mongodb 64-bit 
Mon Jul 25 17:03:22 [initandlisten] db version v1.8.2, pdfile version 4.5
Mon Jul 25 17:03:22 [initandlisten] git version: 433bbaa14aaba6860da15bd4de8edf600f56501b
Mon Jul 25 17:03:22 [initandlisten] build sys info: Linux bs-linux64.10gen.cc 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
Mon Jul 25 17:03:22 [initandlisten] journal dir=/var/lib/mongodb/journal
Mon Jul 25 17:03:22 [initandlisten] recover : no journal files present, no recovery needed
Mon Jul 25 17:03:22 [initandlisten] info preallocateIsFaster couldn't run; returning false
Mon Jul 25 17:03:22 [initandlisten] exception in initAndListen std::exception: couldn't open file /var/lib/mongodb/journal/j._0 for writing errno:13 Permission denied, terminating
Mon Jul 25 17:03:22 dbexit: 
Mon Jul 25 17:03:22 [initandlisten] shutdown: going to close listening sockets...
Mon Jul 25 17:03:22 [initandlisten] shutdown: going to flush diaglog...
Mon Jul 25 17:03:22 [initandlisten] shutdown: going to close sockets...
Mon Jul 25 17:03:22 [initandlisten] shutdown: waiting for fs preallocator...
Mon Jul 25 17:03:22 [initandlisten] shutdown: lock for final commit...
Mon Jul 25 17:03:22 [initandlisten] shutdown: final commit...
Mon Jul 25 17:03:22 [initandlisten] shutdown: closing all files...
Mon Jul 25 17:03:22 closeAllFiles() finished
Mon Jul 25 17:03:22 [initandlisten] shutdown: journalCleanup...
Mon Jul 25 17:03:22 [initandlisten] removeJournalFiles
Mon Jul 25 17:03:22 [initandlisten] shutdown: removing fs lock...
Mon Jul 25 17:03:22 dbexit: really exiting now

when I try :

root@mongo01:~# mongodb -f /etc/mongodb.conf

it starts properly, any idea what it causing the issues?

Thanks

like image 596
impfiji Avatar asked Jul 25 '11 17:07

impfiji


People also ask

How do I start MongoDB in terminal?

To open up the MongoDB shell, run the mongo command from your server prompt. By default, the mongo command opens a shell connected to a locally-installed MongoDB instance running on port 27017 . Try running the mongo command with no additional parameters: mongo.

How do I manually start MongoDB?

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.


1 Answers

Mon Jul 25 17:03:54 [initandlisten] couldn't open /var/lib/mongodb/adrise.ns errno:13 Permission denied

It is a permissions issue, run the following command:

sudo chown -R mongodb:mongodb /var/lib/mongodb
like image 116
Jorge Barata Avatar answered Nov 11 '22 16:11

Jorge Barata