Reputation: 2781
I want to deploy a mongodb replica set with 1 primary and 2 secondaries from config file as following:
the first config file for primary node
#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
the second config file for secondary node
#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
And the third config file for secondary node
#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
But i got this error
....
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)
And when i did exactly the same this guide http://docs.mongodb.org/manual/tutorial/deploy-replica-set-for-testing/
I also got the same error
replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
I dont know what esle config i need to do to solve this problem, please help me, thanks a lot.
Upvotes: 4
Views: 7081
Reputation: 121
Are you on EC2 by chance? I had the same problem when I run rs.initiate() I got "couldn't initiate :can't find self in the replset config"
I read somewhere that on EC2 it always gets the localhost IP wrong, so I explicitly added the EC2 private IP in /etc/mongo.conf
e.g
bind_ip=10.1.1.12,127.0.0.1
and that fixed the problem for me. rs.initiate() now works
Upvotes: 0
Reputation: 2354
You could write both startset and initiate in one line, it will make sure that initiate is kicked in as soon as startSet is done.
replicaSet.startSet();replicaSet.initiate()
Upvotes: 1
Reputation: 66
run rs.initiate()
in mongo console after adding/changing the value of replSet
in config file.
Upvotes: 5