【问题标题】:Cannot start a MongoDB replica set: various errors无法启动 MongoDB 副本集:各种错误
【发布时间】:2015-02-15 22:04:41
【问题描述】:

首先我为集合的 3 个成员设置配置文件并尝试像这样启动它:

它抱怨缺少带有--replSet 的实际mongod 进程。这就是为什么我尝试在不同的终端上启动副本集并得到以下错误:

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 实例
  • 解除锁定\data\rs0\mongod.lock并重启

标签: mongodb


【解决方案1】:

您的问题是您正在使用另一个 mongod 进程正在使用的 dbPath 启动 mongod。正如错误消息所说:

exception in initAndListen: 13627 Unable to create/open lock file: \data\rs0\mongod

看看你正在运行的进程,并确保你没有藏在某个地方的 mongod。停止进程后,使用正确的 replSet 选项启动三个 mongod

【讨论】:

  • 好的,现在我运行rs.initiate(config) 并得到"server is not running with --replSet"。我应该尝试运行副本集 mongod 吗?我应该使用与配置中的成员之一相同的端口吗?
  • 你是不是用--replSet开始了所有的mongod?
  • 看起来您正在使用 -replSet 而不是 --replSet 启动 mongod。尝试将-- 与所有选项一起使用。您也可以尝试将它们设置为--replSet=name --dbPath=...。否则写一个配置文件并使用--config
  • 嗯...这可能是您之前的尝试留下的。尝试停止您的 mongod,然后从数据目录中删除 local.* 文件。一旦所有三个 mongod 都在运行,然后在其中一个上执行 rs.initiate
  • 尝试初始化你的副本集而不给它一个配置,即停止你所有的 mongod。启动一个并在其上调用 rs.initialize()。启动另一个 mongod 并将其 rs.add() 到集合中
猜你喜欢
  • 1970-01-01
  • 2017-04-30
  • 1970-01-01
  • 1970-01-01
  • 2018-03-26
  • 2013-05-25
  • 2020-07-20
  • 2020-03-12
  • 1970-01-01
相关资源
最近更新 更多