问题描述
首先我为集合的 3 个成员设置了配置文件,并尝试像这样启动它:
First I set the config file for the 3 members of the set and try to initiate it like this:
它抱怨 --replSet
缺少实际的 mongod
进程.这就是为什么我尝试在不同的终端上启动副本集并收到以下错误:
It complains about the lack of an actual mongod
process with --replSet
. That's why I try to start a replica set on a different terminal and get the following error:
C:\Users\GeoMash>mongod -replSet m101 -port 27001 -dbpath \data\rs0 -smallfiles
2015-02-15T21:24:46.910+0800 [initandlisten] MongoDB starting : pid=10864 port=27001 dbpath=\data\rs0 64-bit host=GeoMash-PC
2015-02-15T21:24:46.912+0800 [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2015-02-15T21:24:46.912+0800 [initandlisten] db version v2.6.7
2015-02-15T21:24:46.912+0800 [initandlisten] git version: a7d57ad27c382de82e9cb93bf983a80fd9ac9899
2015-02-15T21:24:46.913+0800 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49
2015-02-15T21:24:46.913+0800 [initandlisten] allocator: system
2015-02-15T21:24:46.913+0800 [initandlisten] options: { net: { port: 27001 }, replication: { replSet: "m101" }, storage: { dbPath: "\data\rs0", smallFiles: true } }
2015-02-15T21:24:46.916+0800 [initandlisten] exception in initAndListen: 13627 Unable to create/open lock file: \data\rs0\mongod.lock The process cannot access the file because it is being used by another process.. Is a mongod instance already running?, terminating
2015-02-15T21:24:46.916+0800 [initandlisten] dbexit:
2015-02-15T21:24:46.916+0800 [initandlisten] shutdown: going to close listening sockets...
2015-02-15T21:24:46.917+0800 [initandlisten] shutdown: going to flush diaglog...
2015-02-15T21:24:46.917+0800 [initandlisten] shutdown: going to close sockets...
2015-02-15T21:24:46.917+0800 [initandlisten] shutdown: waiting for fs preallocator...
2015-02-15T21:24:46.918+0800 [initandlisten] shutdown: lock for final commit...
2015-02-15T21:24:46.918+0800 [initandlisten] shutdown: final commit...
2015-02-15T21:24:46.918+0800 [initandlisten] shutdown: closing all files...
2015-02-15T21:24:46.918+0800 [initandlisten] closeAllFiles() finished
2015-02-15T21:24:46.919+0800 [initandlisten] dbexit: really exiting now
推荐答案
您的问题是您正在使用另一个 mongod 进程正在使用的 dbPath 启动 mongod.正如错误消息所说:
Your problem is that you are starting a mongod with a dbPath which is being used by another mongod process. As the error message says:
exception in initAndListen: 13627 Unable to create/open lock file: \data\rs0\mongod
查看您正在运行的进程,并确保您没有将 mongod 藏在某处.停止进程后,然后使用正确的 replSet 选项启动三个 mongod
Take a look at your running processes and make sure you haven't got an mongod hiding somewhere. The after you have stopped the processes then start your three mongod's with the correct replSet option
这篇关于无法启动 MongoDB 副本集:各种错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!