我正在尝试运行命令
mongod --dbpath=data/db
当我收到此错误时:
mongod --dbpath=data/db
[initandlisten] MongoDB starting : pid=10161 port=27017 dbpath=data/db 64-bit host=anr
[initandlisten] db version v2.4.9
[initandlisten] git version: 52fe0d21959e32a5bdbecdc62057db386e4e029c
[initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
[initandlisten] allocator: tcmalloc
[initandlisten] options: { dbpath: "data/db" }
[initandlisten] exception in initAndListen: 10296
*********************************************************************
ERROR: dbpath (data/db) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
dbexit:
[initandlisten] shutdown: going to close listening sockets...
[initandlisten] shutdown: going to flush diaglog...
[initandlisten] shutdown: going to close sockets...
[initandlisten] shutdown: waiting for fs preallocator...
[initandlisten] shutdown: lock for final commit...
[initandlisten] shutdown: final commit...
[initandlisten] shutdown: closing all files...
[initandlisten] closeAllFiles() finished
dbexit: really exiting now
这是我的/ data / db:
.:
total 4
drwxrwxrwx 3 root root 4096 Mar 26 11:24 db
./db:
total 81928
drwxr-xr-x 2 anr anr 4096 Mar 26 16:07 journal
-rw------- 1 anr anr 67108864 Mar 26 16:07 local.0
-rw------- 1 anr anr 16777216 Mar 26 16:07 local.ns
-rwxr-xr-x 1 anr anr 0 Mar 26 16:07 mongod.lock
./db/journal:
total 3145740
-rw------- 1 anr anr 1073741824 Mar 26 16:07 prealloc.0
-rw------- 1 anr anr 1073741824 Mar 25 17:36 prealloc.1
-rw------- 1 anr anr 1073741824 Mar 25 17:36 prealloc.2
修改了我的/ data / db路径,这是错误:
[initandlisten] allocator: tcmalloc
[initandlisten] options: { dbpath: "/data/db" }
[initandlisten] journal dir=/data/db/journal
[initandlisten] recover : no journal files present, no recovery needed
[initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for
socket: 0.0.0.0:27017
[initandlisten] ERROR: addr already in use
[initandlisten] now exiting
[websvr] ERROR: listen(): bind() failed errno:98 Address already in use for socket:
0.0.0.0:28017
[websvr] ERROR: addr already in use
mongodb 10172 1 0 16:11 ? 00:00:27 /usr/bin/mongod --config
/etc/mongodb.conf
anr 10865 5108 0 17:07 pts/0 00:00:00 grep --colour=auto mongod
答案 0 :(得分:1)
-db-path命令不使用=符号。它只是--db-path,例如:
mongod --db-path /data/db
您可以考虑使用配置文件来简化操作。
根据您的Linux风格,您需要其中一个命令才能从配置文件运行Mongod进程:
mongod --config /etc/mongodb.conf
mongod -f /etc/mongodb.conf
请注意,conf文件的位置可以随意使用,您只需要确保运行Mongod的用户具有相应的权限。
配置文件允许您指定运行该过程所需的大多数选项,包括dbpath的位置,日志路径,端口以及(重要)将进程分配到其自身的背景中线。示例配置文件可能如下所示:
dbpath = /data/db
logpath = /var/logs/mongo.log
logappend = true
#bind ip = 127.0.0.1
port = 27111
fork = true
rest = true
verbose = true
#auth = true
#noauth = true
' auth'和' noauth'注释掉以及绑定只是为了表明那些是你也可以在配置文件中为Mongod启动设置的选项。