无法启动mongod

时间:2015-02-12 10:27:59

标签: mongodb

当我尝试启动Mongod时,出现以下错误

sai@saip:~/js_learning$ mongod
mongod --help for help and startup options
Thu Feb 12 15:50:54 [initandlisten] MongoDB starting : pid=8671 port=27017 dbpath=/data/db/ 64-bit host=saip
Thu Feb 12 15:50:54 [initandlisten] db version v2.0.4, pdfile version 4.5
Thu Feb 12 15:50:54 [initandlisten] git version: nogitversion
Thu Feb 12 15:50:54 [initandlisten] build info: Linux lamiak 2.6.42-37-generic #58-Ubuntu SMP Thu Jan 24 15:28:10 UTC 2013 x86_64 BOOST_LIB_VERSION=1_46_1
Thu Feb 12 15:50:54 [initandlisten] options: {}
Thu Feb 12 15:50:54 [initandlisten] exception in initAndListen: 10296 dbpath (/data/db/) does not exist, terminating
Thu Feb 12 15:50:54 dbexit: 
Thu Feb 12 15:50:54 [initandlisten] shutdown: going to close listening sockets...
Thu Feb 12 15:50:54 [initandlisten] shutdown: going to flush diaglog...
Thu Feb 12 15:50:54 [initandlisten] shutdown: going to close sockets...
Thu Feb 12 15:50:54 [initandlisten] shutdown: waiting for fs preallocator...
Thu Feb 12 15:50:54 [initandlisten] shutdown: lock for final commit...
Thu Feb 12 15:50:54 [initandlisten] shutdown: final commit...
Thu Feb 12 15:50:54 [initandlisten] shutdown: closing all files...
Thu Feb 12 15:50:54 [initandlisten] closeAllFiles() finished
Thu Feb 12 15:50:54 dbexit: really exiting now

如果我尝试运行mongoid --repair

,我会得到同样的错误

1 个答案:

答案 0 :(得分:1)

1)创建文件夹/ data / db,并通过发出命令

启动服务器
./mongod

如果需要写入权限,请使用

sudo ./mongod

2)如果要使用自定义路径,请在任意位置创建文件夹。 然后,您可以通过下面的命令

启动服务器

在Linux中,让我们说创建的文件夹是'/ home / mongo / db'

./mongod --bpath /home/mongo/db

在Windows中,让我们说创建的文件夹是'd:\ mongodb \ data'

C:\mongodb\bin\mongod.exe --dbpath d:\mongodb\data