Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the following error: 13279:can't find self in the replset config when configuring replica sets

Tags:

linux

mongodb

I am configuring a 3 node mongodb replica set on linux. I am using the following config

fork = true
bind_ip = 127.0.0.1
port = 27017
verbose = true
dbpath =  /opt/mongoDB/data/db
logpath = /opt/mongoDB/log/mongod.log
logappend = true
journal = true
replSet = rs1
keyFile = /opt/mongoDB/mongodb/bin/conf/keyfile

to start the server. I started the server and when I run connected to the server using mongo command line tool.

When I did rs.initiate() I get

{
    "info2" : "no configuration explicitly specified -- making one",
    "me" : "host-ip:27017",
    "ok" : 0,
    "errmsg" : "couldn't initiate : can't find self in the replset config"
}

I tried providing the cfg to initiate() and still get the same error.

This is what shows up in the log file.

Mon Oct 14 13:27:33.218 [rsStart] replSet info no seed hosts were specified on the --replSet command line
Mon Oct 14 13:27:34.118 [conn1] run command admin.$cmd { replSetInitiate: { _id: "rs1", members: [ { _id: 0.0, host: "host-ip:27017" } ] } }
Mon Oct 14 13:27:34.118 [conn1] replSet replSetInitiate admin command received from client
Mon Oct 14 13:27:34.118 [conn1] replSet replSetInitiate config object parses ok, 1 members specified
Mon Oct 14 13:27:34.118 [conn1] getallIPs("host-ip"): [ip address]
Mon Oct 14 13:27:34.118 BackgroundJob starting: ConnectBG
Mon Oct 14 13:27:34.118 [conn1] User Assertion: 13279:can't find self in the replset config
Mon Oct 14 13:27:34.119 [conn1] replSet replSetInitiate exception: can't find self in the replset config
Mon Oct 14 13:27:34.119 [conn1] command admin.$cmd command: { replSetInitiate: { _id: "rs1", members: [ { _id: 0.0, host: "host-ip:27017" } ] } } ntoreturn:1 keyUpdates:0 locks(micros) W:230 reslen:107 1ms

When should I do to resolve this error?

like image 793
user2704732 Avatar asked Oct 14 '13 20:10

user2704732


2 Answers

I could not initiate Replica Set of MongoDB on CentOS machine.

http://docs.mongodb.org/manual/tutorial/deploy-replica-set

mongodb replset

rs.initiate()


{
    "errmsg":"couldn't initiate : can't find self in the replset config on port 27011"
}

Then I just used JSON object parameter to rs.initiate(rsconfig)

var rsconfig = {"_id":"rs1","members":[{"_id":1,"host":"127.0.0.1:27011"}]}

then rs.add(..) or just all at once

var rsconfig = {"_id":"rs1","members":[{"_id":1,"host":"127.0.0.1:27011"},{"_id":2,"host":"127.0.0.1:27012"},{"_id":3,"host":"127.0.0.1:27013"}]}

check with print(JSON.stringify(rsconfig)) then

rs.initiate(rsconfig)

after several seconds check

rs.status()

enter image description here

like image 172
Paul Verest Avatar answered Oct 14 '22 09:10

Paul Verest


Don't set 127.0.0.1 to bind_ip, change the bind_ip to the machine's name or ip address (such as 192.168.0.1).

like image 27
Robin Avatar answered Oct 14 '22 07:10

Robin