找到你要的答案

Q:Failing to run mongodb installed on Ubuntu

Q:无法运行安装在Ubuntu的MongoDB

I am having problems running mongodb on Ubuntu 14.0.4, after installing it using sudo apt-get install mongodb. Here is the output at my console. The problem seems to be file permission related, but I have already given ownership of the /data/db to user mongodb

$ mongod
mongod --help for help and startup options
Sat May  2 10:16:36.056 [initandlisten] MongoDB starting : pid=11456 port=27017 dbpath=/data/db/ 64-bit host=Nefertiti
Sat May  2 10:16:36.060 [initandlisten] db version v2.4.9
Sat May  2 10:16:36.060 [initandlisten] git version: nogitversion
Sat May  2 10:16:36.060 [initandlisten] build info: Linux orlo 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 BOOST_LIB_VERSION=1_54
Sat May  2 10:16:36.060 [initandlisten] allocator: tcmalloc
Sat May  2 10:16:36.060 [initandlisten] options: {}
Sat May  2 10:16:36.060 [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 May  2 10:16:36.060 dbexit: 
Sat May  2 10:16:36.061 [initandlisten] shutdown: going to close listening sockets...
Sat May  2 10:16:36.061 [initandlisten] shutdown: going to flush diaglog...
Sat May  2 10:16:36.061 [initandlisten] shutdown: going to close sockets...
Sat May  2 10:16:36.061 [initandlisten] shutdown: waiting for fs preallocator...
Sat May  2 10:16:36.061 [initandlisten] shutdown: lock for final commit...
Sat May  2 10:16:36.061 [initandlisten] shutdown: final commit...
Sat May  2 10:16:36.061 [initandlisten] shutdown: closing all files...
Sat May  2 10:16:36.061 [initandlisten] closeAllFiles() finished
Sat May  2 10:16:36.061 [initandlisten] shutdown: removing fs lock...
Sat May  2 10:16:36.061 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Sat May  2 10:16:36.061 dbexit: really exiting now

$ ls -la /data/db
total 8
drwxr-xr-x 2 mongodb root 4096 May  2 10:03 .
drwxr-xr-x 4 root    root 4096 May  2 09:57 ..

What am I doing wrong?

我有问题14.0.4 MongoDB运行Ubuntu,安装后使用sudo apt-get install MongoDB。这是我控制台的输出。这个问题似乎是文件权限的相关,但是我已经给予的/数据/数据库MongoDB所有用户

$ mongod
mongod --help for help and startup options
Sat May  2 10:16:36.056 [initandlisten] MongoDB starting : pid=11456 port=27017 dbpath=/data/db/ 64-bit host=Nefertiti
Sat May  2 10:16:36.060 [initandlisten] db version v2.4.9
Sat May  2 10:16:36.060 [initandlisten] git version: nogitversion
Sat May  2 10:16:36.060 [initandlisten] build info: Linux orlo 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 BOOST_LIB_VERSION=1_54
Sat May  2 10:16:36.060 [initandlisten] allocator: tcmalloc
Sat May  2 10:16:36.060 [initandlisten] options: {}
Sat May  2 10:16:36.060 [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 May  2 10:16:36.060 dbexit: 
Sat May  2 10:16:36.061 [initandlisten] shutdown: going to close listening sockets...
Sat May  2 10:16:36.061 [initandlisten] shutdown: going to flush diaglog...
Sat May  2 10:16:36.061 [initandlisten] shutdown: going to close sockets...
Sat May  2 10:16:36.061 [initandlisten] shutdown: waiting for fs preallocator...
Sat May  2 10:16:36.061 [initandlisten] shutdown: lock for final commit...
Sat May  2 10:16:36.061 [initandlisten] shutdown: final commit...
Sat May  2 10:16:36.061 [initandlisten] shutdown: closing all files...
Sat May  2 10:16:36.061 [initandlisten] closeAllFiles() finished
Sat May  2 10:16:36.061 [initandlisten] shutdown: removing fs lock...
Sat May  2 10:16:36.061 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Sat May  2 10:16:36.061 dbexit: really exiting now

$ ls -la /data/db
total 8
drwxr-xr-x 2 mongodb root 4096 May  2 10:03 .
drwxr-xr-x 4 root    root 4096 May  2 09:57 ..

我做错什么了?

answer1: 回答1:

You can change the ownership of the /data/db with chown http://manpages.ubuntu.com/manpages/precise/en/man1/chown.1.html

You can change the ownership of the /data/db with chown http://manpages.ubuntu.com/manpages/precise/en/man1/chown.1.html

mongodb  ubuntu