无法在Windows上部署MongoDB副本集?

时间:2013-11-28 09:45:39

标签: mongodb replication

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

主节点的第一个配置文件

#primary node
#===============
dbpath = C:\data\rs0\1
directoryperdb = true
bind_ip = 192.168.2.104
port = 27017
logpath = C:\mongodb2.5.3\logs\primary.log
logappend = true
noauth = true
replSet = rs0
rest = true

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

#secondary node
#===============
dbpath = C:\data\rs0\2
directoryperdb = true
bind_ip = 192.168.2.104
port = 27018
logpath = C:\mongodb2.5.3\logs\secondary1.log
logappend = true
noauth = true
replSet = rs0
rest = true

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

#secondary node
#===============
dbpath = C:\data\rs0\3
directoryperdb = true
bind_ip = 192.168.2.104
port = 27019
logpath = C:\mongodb2.5.3\logs\secondary2.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: "config\mongorep.conf", dbpath: "C:\data\rs0\1", directoryperdb: true, logappend: true, logpath: "C:\mongodb2.5.3\logs\primary.log", noauth: true, port: 27017, replSet: "rs0", rest: true }
2013-11-28T16:26:59.742+0700 [FileAllocator] allocating new datafile C:\data\rs0\1\local\local.ns, filling with zeroes...
2013-11-28T16:26:59.742+0700 [FileAllocator] creating directory C:\data\rs0\1\local\_tmp
2013-11-28T16:26:59.835+0700 [FileAllocator] done allocating datafile C:\data\rs0\1\local\local.ns, size: 16MB,  took 0.092 secs
2013-11-28T16:26:59.836+0700 [FileAllocator] allocating new datafile C:\data\rs0\1\local\local.0, filling with zeroes...
2013-11-28T16:27:00.101+0700 [FileAllocator] done allocating datafile C:\data\rs0\1\local\local.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)

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

3 个答案:

答案 0 :(得分:5)

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

答案 1 :(得分:1)

你可以在一行中写入startset和launch,它将确保在startSet完成后立即启动。

replicaSet.startSet();replicaSet.initiate()

答案 2 :(得分:0)

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

我在某处看过,在EC2上它总是让localhost IP出错,所以我在/etc/mongo.conf中明确添加了EC2私有IP

e.g

bind_ip = 10.1.1.12,127.0.0.1

这解决了我的问题。 rs.initiate()现在有效了

相关问题