无法在windows上部署MongoDB副本集



我想从配置文件中部署一个mongodb副本集,其中有1个主副本和2个辅助副本,如下所示:

主节点的第一个配置文件

#primary node
#===============
dbpath = C:datars01
directoryperdb = true
bind_ip = 192.168.2.104
port = 27017
logpath = C:mongodb2.5.3logsprimary.log
logappend = true
noauth = true
replSet = rs0
rest = true

辅助节点的第二个配置文件

#secondary node
#===============
dbpath = C:datars02
directoryperdb = true
bind_ip = 192.168.2.104
port = 27018
logpath = C:mongodb2.5.3logssecondary1.log
logappend = true
noauth = true
replSet = rs0
rest = true

以及辅助节点的第三个配置文件

#secondary node
#===============
dbpath = C:datars03
directoryperdb = true
bind_ip = 192.168.2.104
port = 27019
logpath = C:mongodb2.5.3logssecondary2.log
logappend = true
noauth = true
replSet = rs0
rest = true

但是我得到了这个错误

 ....
    2013-11-28T16:26:59.734+0700 [initandlisten] options: { bind_ip: "192.168.2.104", config: "configmongorep.conf", dbpath: "C:datars01", directoryperdb: true, logappend: true, logpath: "C:mongodb2.5.3logsprimary.log", noauth: true, port: 27017, replSet: "rs0", rest: true }
2013-11-28T16:26:59.742+0700 [FileAllocator] allocating new datafile C:datars01locallocal.ns, filling with zeroes...
2013-11-28T16:26:59.742+0700 [FileAllocator] creating directory C:datars01local_tmp
2013-11-28T16:26:59.835+0700 [FileAllocator] done allocating datafile C:datars01locallocal.ns, size: 16MB,  took 0.092 secs
2013-11-28T16:26:59.836+0700 [FileAllocator] allocating new datafile C:datars01locallocal.0, filling with zeroes...
2013-11-28T16:27:00.101+0700 [FileAllocator] done allocating datafile C:datars01locallocal.0, size: 64MB,  took 0.265 secs
2013-11-28T16:27:00.102+0700 [initandlisten] command local.$cmd command: { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0  reslen:37 360ms
2013-11-28T16:27:00.102+0700 [initandlisten] waiting for connections on port 27017
2013-11-28T16:27:00.103+0700 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
2013-11-28T16:27:00.103+0700 [rsStart] replSet info you may need to run replSetInitiate -- rs.initiate() in the shell -- if that is not already done
2013-11-28T16:27:00.104+0700 [websvr] admin web console waiting for connections on port 28017
2013-11-28T16:27:01.103+0700 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
2013-11-28T16:27:02.103+0700 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
2013-11-28T16:27:03.103+0700 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
2013-11-28T16:27:04.103+0700 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
2013-11-28T16:27:05.103+0700 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)

当我做同样的事情时,这个指南http://docs.mongodb.org/manual/tutorial/deploy-replica-set-for-testing/

我也得到了相同的错误

replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)

我不知道我需要做什么来解决这个问题,请帮助我,非常感谢。

在配置文件中添加/更改replSet的值后,在mongo控制台中运行rs.initiate()

您可以在一行中同时写入startset和initiate,它将确保在startset完成后立即启动initiate。

replicaSet.startSet();replicaSet.initiate()

你在EC2上是偶然的吗?当我运行rs.initiate()时,我遇到了同样的问题,我得到了"无法启动:在replset配置中找不到自己"

我在某个地方读到,在EC2上,它总是得到错误的localhost IP,所以我在/etc/mongo.conf 中明确添加了EC2私有IP

例如

bind_ip=10.1.1.12 127.0.0.1

这为我解决了这个问题。rs.initiate()现在可以使用