MongoDB on Raspberry Pi –dbpath not setting

linuxmongodb

I installed MongoDB using this tutorial. I have tried to set --dbpath in /etc/mongodb.conf like this:

dbpath=/path/that/iwant

#where to log
logpath=/var/log/mongodb/mongodb.log

logappend=true

When I mongod I get:

ERROR: dbpath (/data/db/) does not exist.

Further more, if I declare mongodb --dbpath /path/that/iwant i get:

exception in initAndListen: 10309 Unable to create/open lock file
errno:13 Permission denied Is a mongod instance already running?

Q: How do I get mongod to reference the proper path in the config file without specifying.

Bonus: Why is permission being denied from mongo. (I have tried sudo chmod -R 775 /path/that/iwant and sudo chown -R mongodb /path/that/iwant)

I am new to mongo and database admin exchange. As a brother from Stack Overflow I am humbled.

Edit: I added the path /data/db to the pie and chown mongodb on it. If I sudo mongod the server starts. If I try to start it with my user it will not start getting an error Unable to create/open lock file which exists.

Edit: Here is what my /etc/init.d/mongd looks like:

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/mongod
DESC=database

# Default defaults.  Can be overridden by the /etc/default/$NAME
NAME=mongodb
CONF=/etc/mongodb.conf
DATA=/path/that/iwant
LOGDIR=/var/log/mongodb
PIDFILE=/var/run/$NAME.pid
LOGFILE=$LOGDIR/$NAME.log  # Server logfile
ENABLE_MONGODB=yes

…further down

DAEMONUSER=${DAEMONUSER:-mongodb}
DAEMON_OPTS=${DAEMON_OPTS:-"--dbpath $DATA --logpath $LOGFILE run"}
DAEMON_OPTS="$DAEMON_OPTS --config $CONF --rest"

This is what ps aux | grep mongo looks like after i start the server with sudo mongod:

root     10747  0.1  0.3   5124  1612 pts/0    S+   10:41   0:00 sudo mongod
root     10748  1.8  3.8  84896 17416 pts/0    Sl+  10:41   0:00 mongod
1001     10823  0.0  0.1   3544   808 pts/1    S+   10:42   0:00 grep --color=auto mongo

Best Answer

Firstly instead of installing mongodb through apt just get a tar or zip of it.

1)Extract it to your home folder or wherever you would like.

2)Mark the mongod,mongo,mongos executable.

3)make a conf file say mongod.conf and add

 dbpath=conf/data/db
 logpath=conf/log/mongod.log
 logappend=true
 port = 27001
 fork = true

4)Start mongod by

 path/bin/mongod --config path/mongod.conf

"bin" because you will find mongod in bin folder after extract