当我启动mongo db时,它会立即崩溃并返回到正常的命令行。如果有帮助,我在Mac上运行MEAN堆栈。以下是错误:
$ sudo mongod
Sun Jun 1 21:01:01.728 [initandlisten] MongoDB starting : pid=47937 port=3000 dbpath=/usr/local/var/mongodb 64-bit host=NoHax4You
Sun Jun 1 21:01:01.728 [initandlisten]
Sun Jun 1 21:01:01.729 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Sun Jun 1 21:01:01.729 [initandlisten] db version v2.4.9
Sun Jun 1 21:01:01.729 [initandlisten] git version: nogitversion
Sun Jun 1 21:01:01.729 [initandlisten] build info: Darwin minimavericks.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Sun Jun 1 21:01:01.729 [initandlisten] allocator: tcmalloc
Sun Jun 1 21:01:01.729 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/usr/local/etc/mongod.conf", dbpath: "/usr/local/var/mongodb", logappend: "true", logpath: "/usr/local/var/log/mongodb/mongo.log", port: 3000 }
Sun Jun 1 21:01:01.729 [initandlisten] exception in initAndListen: 10310 Unable to lock file: /usr/local/var/mongodb/mongod.lock. Is a mongod instance already running?, terminating
Sun Jun 1 21:01:01.729 dbexit:
Sun Jun 1 21:01:01.729 [initandlisten] shutdown: going to close listening sockets...
Sun Jun 1 21:01:01.729 [initandlisten] shutdown: going to flush diaglog...
Sun Jun 1 21:01:01.729 [initandlisten] shutdown: going to close sockets...
Sun Jun 1 21:01:01.729 [initandlisten] shutdown: waiting for fs preallocator...
Sun Jun 1 21:01:01.729 [initandlisten] shutdown: lock for final commit...
Sun Jun 1 21:01:01.729 [initandlisten] shutdown: final commit...
Sun Jun 1 21:01:01.729 [initandlisten] shutdown: closing all files...
Sun Jun 1 21:01:01.729 [initandlisten] closeAllFiles() finished
Sun Jun 1 21:01:01.729 dbexit: really exiting now
谢谢, 伊万
答案 0 :(得分:48)
首先,使用古老的命令查找在系统上运行的mongod的其他实例:
ps ax | grep mongod
如果您看到像
这样的行98555 ?? S 4:40.89 mongod --dbpath /Volumes/ComputerName/data/db
-PID- -name- -------------path------------
然后有一个mongod进程已经运行。如果是这样的话就杀了它然后再次启动mongod。
要杀死PID = 0000的进程,在Unix环境中使用 -
kill -9 0000
如果您的控制台返回类似-bash: kill: (98555) - Operation not permitted
的内容,请使用
sudo !!
到repeat the command as super user。这应该让你去。
PS:如果尚未在数据库中存储任何数据,请删除/data
,然后再次创建/data/db
目录。做一个sudo mongod
它应该有效。
答案 1 :(得分:0)
我遇到了同样的问题,而这个班轮解决了我的问题
killall mongod
在终端
中运行上述命令希望有帮助!
答案 2 :(得分:-2)
我首先打开/data/db/mongod.lock文件,在那里找到我的进程号,然后用kill -9 <processnumber>
将其杀死。这对我有用。