Linux issues

908 views
Skip to first unread message

Om

unread,
Jul 22, 2011, 2:33:11 AM7/22/11
to mongodb-user
Hi,

I'm trying to run mongodb on Linux. I created the data/db folder at
the root (omkar@omkar-laptop:~/). Then I tried to run mongo but I get
following error.

omkar@omkar-laptop:~/Desktop/mongodb_32$ bin/mongod
bin/mongod --help for help and startup options
Thu Jul 21 23:23:54 [initandlisten] MongoDB starting : pid=15035
port=27017 dbpath=/data/db/ 32-bit

** NOTE: when using MongoDB 32 bit, you are limited to about 2
gigabytes of data
** see http://blog.mongodb.org/post/137788967/32-bit-limitations
** with --dur, the limit is lower

Thu Jul 21 23:23:54 [initandlisten] db version v1.8.2, pdfile version
4.5
Thu Jul 21 23:23:54 [initandlisten] git version:
433bbaa14aaba6860da15bd4de8edf600f56501b
Thu Jul 21 23:23:54 [initandlisten] build sys info: Linux bs-
linux32.10gen.cc 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008
i686 BOOST_LIB_VERSION=1_37
Thu Jul 21 23:23:54 [initandlisten] exception in initAndListen
std::exception: dbpath (/data/db/) does not exist, terminating
Thu Jul 21 23:23:54 dbexit:
Thu Jul 21 23:23:54 [initandlisten] shutdown: going to close listening
sockets...
Thu Jul 21 23:23:54 [initandlisten] shutdown: going to flush
diaglog...
Thu Jul 21 23:23:54 [initandlisten] shutdown: going to close
sockets...
Thu Jul 21 23:23:54 [initandlisten] shutdown: waiting for fs
preallocator...
Thu Jul 21 23:23:54 [initandlisten] shutdown: closing all files...
Thu Jul 21 23:23:54 closeAllFiles() finished
Thu Jul 21 23:23:54 dbexit: really exiting now


It says excption is because dbpath(/data/db) doesn't exist. However, I
created the required directory using mkdir commands. Not sure why it
still giving this error. Please help. Thanks in advance for your
time.

Kaustubh Padegaonkar

unread,
Jul 22, 2011, 2:47:04 AM7/22/11
to mongod...@googlegroups.com
Change the ownership of the folder to mongodb.

sudo chown mongodb:mongodb /data/db

Also, seems you have not installed mongodb, but executing the binaries. Take a look at how tto install mongodb given here.

Also If I am not wrong, the root your shell prompt says, is ~/ which is still your home directory. To create a directory at the root ie "/"

sudo mkdir -p /data/db

Nat

unread,
Jul 22, 2011, 3:03:02 AM7/22/11
to mongod...@googlegroups.com
Try specifying --dbpath <yourowndbpath> when starting up mongod
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Om

unread,
Jul 22, 2011, 3:04:55 AM7/22/11
to mongodb-user
Kaustubh, thanks a lot for the help. However, I'm still having some
issues. The "sudo mkdir -p /data/db" command works fine and creates
the required folders. However, "sudo chown mongodb:mongodb /data/db"
doesn't work. It produces following error: "chown: invalid user:
`mongodb:mongodb'". The mongod generates follwoing message

Thu Jul 21 23:57:44 [initandlisten] db version v1.8.2, pdfile version
4.5
Thu Jul 21 23:57:44 [initandlisten] git version:
433bbaa14aaba6860da15bd4de8edf600f56501b
Thu Jul 21 23:57:44 [initandlisten] build sys info: Linux bs-
linux32.10gen.cc 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008
i686 BOOST_LIB_VERSION=1_37
Thu Jul 21 23:57:44 [initandlisten] exception in initAndListen
std::exception: Unable to create / open lock file for lockfilepath: /
data/db/mongod.lock errno:13 Permission denied, terminating
Thu Jul 21 23:57:44 dbexit:
Thu Jul 21 23:57:44 [initandlisten] shutdown: going to close listening
sockets...
Thu Jul 21 23:57:44 [initandlisten] shutdown: going to flush
diaglog...
Thu Jul 21 23:57:44 [initandlisten] shutdown: going to close
sockets...
Thu Jul 21 23:57:44 [initandlisten] shutdown: waiting for fs
preallocator...
Thu Jul 21 23:57:44 [initandlisten] shutdown: closing all files...
Thu Jul 21 23:57:44 closeAllFiles() finished
Thu Jul 21 23:57:44 [initandlisten] shutdown: removing fs lock...
Thu Jul 21 23:57:44 [initandlisten] couldn't remove fs lock errno:9
Bad file descriptor
Thu Jul 21 23:57:44 dbexit: really exiting now

Now it is having issues with access permissions.

On Jul 21, 11:47 pm, Kaustubh Padegaonkar <thetuxra...@gmail.com>
wrote:
> Change the ownership of the folder to mongodb.
>
> sudo chown mongodb:mongodb /data/db
>
> Also, seems you have not installed mongodb, but executing the binaries. Take
> a look at how tto install mongodb given
> here<http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages>
> .

Kaustubh Padegaonkar

unread,
Jul 22, 2011, 3:12:04 AM7/22/11
to mongod...@googlegroups.com
Thats because you did not install mongodb as a service. Take a look at installing the proper way, in the link i gave you  in the previous answer. In the meantime, you cant try changing the permissions of /data/db to 755 as follows:

chmod 755 -R /data/db




Om

unread,
Jul 22, 2011, 3:10:34 AM7/22/11
to mongodb-user
Kaustubh,

I created the folder successfully. However, the chown doesn't seem to
work. It says "chown: invalid user: `mongodb:mongodb'". The mongodb
now says:


Thu Jul 21 23:57:44 [initandlisten] db version v1.8.2, pdfile version
4.5
Thu Jul 21 23:57:44 [initandlisten] git version:
433bbaa14aaba6860da15bd4de8edf600f56501b
Thu Jul 21 23:57:44 [initandlisten] build sys info: Linux bs-
linux32.10gen.cc 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008
i686 BOOST_LIB_VERSION=1_37
Thu Jul 21 23:57:44 [initandlisten] exception in initAndListen
std::exception: Unable to create / open lock file for lockfilepath: /
data/db/mongod.lock errno:13 Permission denied, terminating
Thu Jul 21 23:57:44 dbexit:
Thu Jul 21 23:57:44 [initandlisten] shutdown: going to close listening
sockets...
Thu Jul 21 23:57:44 [initandlisten] shutdown: going to flush
diaglog...
Thu Jul 21 23:57:44 [initandlisten] shutdown: going to close
sockets...
Thu Jul 21 23:57:44 [initandlisten] shutdown: waiting for fs
preallocator...
Thu Jul 21 23:57:44 [initandlisten] shutdown: closing all files...
Thu Jul 21 23:57:44 closeAllFiles() finished
Thu Jul 21 23:57:44 [initandlisten] shutdown: removing fs lock...
Thu Jul 21 23:57:44 [initandlisten] couldn't remove fs lock errno:9
Bad file descriptor
Thu Jul 21 23:57:44 dbexit: really exiting now

Thanks
-- Om


On Jul 21, 11:47 pm, Kaustubh Padegaonkar <thetuxra...@gmail.com>
wrote:
> Change the ownership of the folder to mongodb.
>
> sudo chown mongodb:mongodb /data/db
>
> Also, seems you have not installed mongodb, but executing the binaries. Take
> a look at how tto install mongodb given
> here<http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages>
> .

Kaustubh Padegaonkar

unread,
Jul 22, 2011, 3:18:05 AM7/22/11
to mongod...@googlegroups.com
Oh, forgot to mention. There is an old lockfile, the result of a bad termination. Remove the mongod.lock file in the /data/db file, and you should be golden.

Kaustubh Padegaonkar,
thetu...@gmail.com
http://about.me/thetuxracer

Om

unread,
Jul 22, 2011, 3:24:46 AM7/22/11
to mongodb-user
Kaustubh,

I see no such file or directory. The 755 trick didn't work. I guess
I'll have to install it properly using the info provided in the link.

On Jul 22, 12:18 am, Kaustubh Padegaonkar <thetuxra...@gmail.com>
wrote:
> Oh, forgot to mention. There is an old lockfile, the result of a bad
> termination. Remove the mongod.lock file in the /data/db file, and you
> should be golden.
>
> Kaustubh Padegaonkar,
> thetuxra...@gmail.comhttp://about.me/thetuxracer
>
> On Fri, Jul 22, 2011 at 12:42 PM, Kaustubh Padegaonkar <
>
> thetuxra...@gmail.com> wrote:
> > Thats because you did not install mongodb as a service. Take a look at
> > installing the proper way, in the link i gave you  in the previous answer.
> > In the meantime, you cant try changing the permissions of /data/db to 755 as
> > follows:
>
> > chmod 755 -R /data/db
>

Om

unread,
Jul 22, 2011, 3:27:48 AM7/22/11
to mongodb-user
It seems that the installation instructions are for the packages
provided by 10-gen. What about the packages obtained form the download
page of the mongodb website?

On Jul 22, 12:18 am, Kaustubh Padegaonkar <thetuxra...@gmail.com>
wrote:
> Oh, forgot to mention. There is an old lockfile, the result of a bad
> termination. Remove the mongod.lock file in the /data/db file, and you
> should be golden.
>
> Kaustubh Padegaonkar,
> thetuxra...@gmail.comhttp://about.me/thetuxracer
>
> On Fri, Jul 22, 2011 at 12:42 PM, Kaustubh Padegaonkar <
>
> thetuxra...@gmail.com> wrote:
> > Thats because you did not install mongodb as a service. Take a look at
> > installing the proper way, in the link i gave you  in the previous answer.
> > In the meantime, you cant try changing the permissions of /data/db to 755 as
> > follows:
>
> > chmod 755 -R /data/db
>

Kaustubh Padegaonkar

unread,
Jul 22, 2011, 3:39:52 AM7/22/11
to mongod...@googlegroups.com
1. The lockfile should be in /data/db/, provided you are running mongodb as

mongod --dbpath /data/db

Also check /var/lib/mongodb/

DO: 
rm /data/db/mongod.lock 

OR

rm /var/lib/mongodb/mongod.lock

2. You have downloaded the binaries, not packages. If you will follow the steps given in the link, and install successfully, you will have to need of the download from the downloads page.

Om

unread,
Jul 22, 2011, 1:28:08 PM7/22/11
to mongodb-user
I followed the instructions given on the page and I think I installed
the packages successfully. Here is the output I got:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
mongodb-10gen
0 upgraded, 1 newly installed, 0 to remove and 374 not upgraded.
Need to get 27.0MB of archives.
After this operation, 68.3MB of additional disk space will be used.
Get:1 http://downloads-distro.mongodb.org dist/10gen mongodb-10gen
1.8.2 [27.0MB]
Fetched 27.0MB in 13s (1947kB/
s)
Selecting previously deselected package mongodb-10gen.
(Reading database ... 97665 files and directories currently
installed.)
Unpacking mongodb-10gen (from .../mongodb-10gen_1.8.2_i386.deb) ...
Setting up mongodb-10gen (1.8.2) ...
Adding system user `mongodb' (UID 112) ...
Adding new user `mongodb' (UID 112) with group `nogroup' ...
Not creating home directory `/home/mongodb'.
Adding group `mongodb' (GID 124) ...
Done.
Adding user `mongodb' to group `mongodb' ...
Adding user mongodb to group mongodb
Done.
start: Unknown job: mongodb

I'm not sure where these files are installed. It says "Not creating
home directory `/home/mongodb'" in the above output. How do I run
mongo after this?

On Jul 22, 12:39 am, Kaustubh Padegaonkar <thetuxra...@gmail.com>
wrote:
> 1. The lockfile should be in /data/db/, provided you are running mongodb as
>
> mongod --dbpath /data/db
>
> Also check /var/lib/mongodb/
>
> DO:
> rm /data/db/mongod.lock
>
> OR
>
> rm /var/lib/mongodb/mongod.lock
>
> 2. You have downloaded the binaries, not packages. If you will follow the
> steps given in the link, and install successfully, you will have to need of
> the download from the downloads page.
>
> Kaustubh Padegaonkar,
> thetuxra...@gmail.comhttp://about.me/thetuxracer

Om

unread,
Jul 22, 2011, 2:38:08 PM7/22/11
to mongodb-user
Never mind. Mongodb runs. However, it still has access control issues
for /data/db file:

Fri Jul 22 11:35:36 [initandlisten] db version v1.8.2, pdfile version
4.5
Fri Jul 22 11:35:36 [initandlisten] git version:
433bbaa14aaba6860da15bd4de8edf600f56501b
Fri Jul 22 11:35:36 [initandlisten] build sys info: Linux bs-
linux32.10gen.cc 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008
i686 BOOST_LIB_VERSION=1_37
Fri Jul 22 11:35:36 [initandlisten] exception in initAndListen
std::exception: Unable to create / open lock file for lockfilepath: /
data/db/mongod.lock errno:13 Permission denied, terminating
Fri Jul 22 11:35:36 dbexit:
Fri Jul 22 11:35:36 [initandlisten] shutdown: going to close listening
sockets...
Fri Jul 22 11:35:36 [initandlisten] shutdown: going to flush
diaglog...
Fri Jul 22 11:35:36 [initandlisten] shutdown: going to close
sockets...
Fri Jul 22 11:35:36 [initandlisten] shutdown: waiting for fs
preallocator...
Fri Jul 22 11:35:36 [initandlisten] shutdown: closing all files...
Fri Jul 22 11:35:36 closeAllFiles() finished
Fri Jul 22 11:35:36 [initandlisten] shutdown: removing fs lock...
Fri Jul 22 11:35:36 [initandlisten] couldn't remove fs lock errno:9
Bad file descriptor
Fri Jul 22 11:35:36 dbexit: really exiting now

Any suggestions for fixing it?

Thanks

On Jul 22, 10:28 am, Om <omkar.ti...@gmail.com> wrote:
> I followed the instructions given on the page and I think I installed
> the packages successfully. Here is the output I got:
>
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> The following NEW packages will be installed:
>   mongodb-10gen
> 0 upgraded, 1 newly installed, 0 to remove and 374 not upgraded.
> Need to get 27.0MB of archives.
> After this operation, 68.3MB of additional disk space will be used.
> Get:1http://downloads-distro.mongodb.orgdist/10gen mongodb-10gen

Alvin Richards

unread,
Jul 22, 2011, 5:11:04 PM7/22/11
to mongodb-user
Your problem is still permissions

Fri Jul 22 11:35:36 [initandlisten] exception in initAndListen
std::exception: Unable to create / open lock file for lockfilepath: /
data/db/mongod.lock errno:13 Permission denied, terminating
Fri Jul 22 11:35:36 dbexit:

The userid/groupid that you are running mongod as, does not have the
right permissions

Use the command id and groups to find out this info. Then do a chown -
R with the group name provided.

-Alvin

Om

unread,
Jul 22, 2011, 5:34:24 PM7/22/11
to mongodb-user
Alvin,

can you please elaborate? Please explain how this can be done. Thanks

Om

unread,
Jul 22, 2011, 6:00:44 PM7/22/11
to mongodb-user
I did " sudo chown mongodb:mongodb /data/db". I still get the same
error.

Alvin Richards

unread,
Jul 22, 2011, 6:04:27 PM7/22/11
to mongodb-user
please paste the output of
> id
> groups

-Alvin

Om

unread,
Jul 22, 2011, 6:12:34 PM7/22/11
to mongodb-user
id gives:

uid=1000(omkar) gid=1000(omkar) groups=4(adm),20(dialout),24(cdrom),
25(floppy),29(audio),30(dip),44(video),46(plugdev),107(fuse),
109(lpadmin),115(admin),1000(omkar)

groups gives:

omkar adm dialout cdrom floppy audio dip video plugdev fuse lpadmin
admin
> ...
>
> read more »

Alvin Richards

unread,
Jul 22, 2011, 6:57:34 PM7/22/11
to mongodb-user
try

> sudo chown -R omkar:omkar /data/db

-Alvin
> > > > > > > > > > >> > sudo mkdir -p /data/db...
>
> read more »

Om

unread,
Jul 22, 2011, 7:04:18 PM7/22/11
to mongodb-user
It works :D. Thanks Alvin. If you don't mind, can you please explain
what we did here. I understand that we granted access rights for /data/
db to the user omkar. Is that right?
> ...
>
> read more »

Kaustubh Padegaonkar

unread,
Jul 25, 2011, 2:11:55 AM7/25/11
to mongod...@googlegroups.com
Yes, thats correct.
> ...
>
> read more »

Sam Millman

unread,
Jul 25, 2011, 3:18:52 AM7/25/11
to mongod...@googlegroups.com
You change the "owner" to your logged in user and your logged in user only.

This is not an awesome way of making mongod work but it is sufficient for development purposes.

What you would do is make a mongo group:

sudo groupadd mongodb

Then assign your user to that mongo group:

sudo useradd -G mongodb omkar

Then make the group the folder owner:

sudo chgrp mongodb /data/db

That is the proper way of securing your users access to access the folder without sudo and also allowing for multiple unprivileged users (users who are not admins but are db admins) to access your db.

Or the even better way is to have an actually mongodb user and then your own user having to sudo (since it is admin) to the mongod. This stops smudging of user responsibilities.

Alvin Richards

unread,
Jul 25, 2011, 7:44:02 AM7/25/11
to mongodb-user
No problem. The owner of the mongod process (in this case omkar) did
not have the right access rights to the files in /data/db. As Sam
notes, you can set this up to provide separation various log on on the
machine. However, for a simple development environment its ok to have
mongod running as your id.

-Alvin
> > > > > > > > > > > > >> Bad...
>
> read more »

Om

unread,
Jul 26, 2011, 8:55:56 PM7/26/11
to mongodb-user
Thanks a lot to all of you for your time and help :D
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages