Mongodb – Can’t start mongodb in ArchLinux

mongodb

I have installed mongodb using sudo pacman -S mongodb in my 32-bit arch .
At first I run this sudo mkdir -p /data/db to create /data/db ,and then run $ mongod ,then I got the following message :

mongod --help for help and startup options
Sat Oct  6 11:45:29 
Sat Oct  6 11:4
5:29 warning: 32-bit servers don't have journaling enabled by default. Please use --           journal if you want durability.
Sat Oct  6 11:45:29 
Sat Oct  6 11:45:29 [initandlisten] MongoDB starting : pid=1146 port=27017    dbpath=/data/db/ 32-bit host=ftp
Sat Oct  6 11:45:29 [initandlisten] 
Sat Oct  6 11:45:29 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Sat Oct  6 11:45:29 [initandlisten] **       see    http://blog.mongodb.org/post/137788967/32-bit-limitations
Sat Oct  6 11:45:29 [initandlisten] **       with --journal, the limit is lower
Sat Oct  6 11:45:29 [initandlisten]  
Sat Oct  6 11:45:29 [initandlisten] db version v2.2.0, pdfile version 4.5
Sat Oct  6 11:45:29 [initandlisten] git version: nogitversion
Sat Oct  6 11:45:29 [initandlisten] build info: Linux brynhild 3.5.3-1-ARCH #1 SMP   PREEMPT Sun Aug 26 09:14:51 CEST 2012 i686 BOOST_LIB_VERSION=1_49
Sat Oct  6 11:45:29 [initandlisten] options: {}
Sat Oct  6 11:45:29 [initandlisten] exception in initAndListen: 10309 Unable to   create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance  already running?, terminating
Sat Oct  6 11:45:29 dbexit: 
Sat Oct  6 11:45:29 [initandlisten] shutdown: going to close listening sockets...
Sat Oct  6 11:45:29 [initandlisten] shutdown: going to flush diaglog...
Sat Oct  6 11:45:29 [initandlisten] shutdown: going to close sockets...
Sat Oct  6 11:45:29 [initandlisten] shutdown: waiting for fs preallocator...
Sat Oct  6 11:45:29 [initandlisten] shutdown: closing all files... 
Sat Oct  6 11:45:29 [initandlisten] closeAllFiles() finished
Sat Oct  6 11:45:29 [initandlisten] shutdown: removing fs lock...
Sat Oct  6 11:45:29 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Sat Oct  6 11:45:29 dbexit: really exiting now

what does exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating mean?

Best Answer

You ran sudo mkdir -p /data/db as not yourself. Now that directory is owned by root.

You need to chown the directory back to yourself before starting mongod otherwise mongod cannot access the directory write the files into it that are needed.

Please also find a 64-bit platform to run mongo - it's not really a very good idea to run it on 32-bit system unless this is just for playing around with.