patternMinor
Our replica set config is invalid or we are not a member of it - MongoDB
Viewed 0 times
arereplicamongodbmemberconfiginvalidnotsetour
Problem
I have started the mongodb server with replica set name 'rs01' enabled on port 27001.
Then started another command window to start the mongo db on the same port.
The status says the 'rs0' is not a member of the replica set.
But, if I try to register the member, below error message happens. Any help would be appreciated.
mongodb
Then started another command window to start the mongo db on the same port.
The status says the 'rs0' is not a member of the replica set.
rs0:OTHER> rs.status()
{
"operationTime" : Timestamp(1552575009, 1),
"ok" : 0,
"errmsg" : "Our replica set config is invalid or we are not a member of it",
"code" : 93,
"codeName" : "InvalidReplicaSetConfig",
"$clusterTime" : {
"clusterTime" : Timestamp(1552575009, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}But, if I try to register the member, below error message happens. Any help would be appreciated.
rs0:OTHER> rs.initiate({_id:"rs0",members[{_id:0,host:"localhost:27001"}]})
2019-03-14T22:14:39.840+0530 E QUERY [js] SyntaxError: missing : after property id @(shell):1:30
rs0:OTHER> rsconf={ _id:"rs0", members: [ { _id: 0,host:"localhost:27001"}]}
{
"_id" : "rs0",
"members" : [
{
"_id" : 0,
"host" : "localhost:27001"
}
]
}
rs0:OTHER> rs.initiate(rsconf)
{
"operationTime" : Timestamp(1552575009, 1),
"ok" : 0,
"errmsg" : "already initialized",
"code" : 23,
"codeName" : "AlreadyInitialized",
"$clusterTime" : {
"clusterTime" : Timestamp(1552575009, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}mongodb
Solution
In my situation (a local instance with a single node in the replica set). I ran
I copy/pasted the config to an
I don't know if such a "brute" method will work for different settings.
rs.config() and saw that the members[0].host was incorrect.I copy/pasted the config to an
rs.reconfig command, edited the host id, and had to use {"force":true} as second argument.I don't know if such a "brute" method will work for different settings.
rs.reconfig({
"_id" : "rs0",
"version" : 1.0,
"protocolVersion" : NumberLong(1),
"writeConcernMajorityJournalDefault" : true,
"members" : [
{
"_id" : 0.0,
"host" : "2f0bd979cc69:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1.0,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1.0
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : 2000.0,
"heartbeatTimeoutSecs" : 10.0,
"electionTimeoutMillis" : 10000.0,
"catchUpTimeoutMillis" : -1.0,
"catchUpTakeoverDelayMillis" : 30000.0,
"getLastErrorModes" : {
},
"getLastErrorDefaults" : {
"w" : 1.0,
"wtimeout" : 0.0
},
"replicaSetId" : ObjectId("6033b612985ce53324d7446c")
}
}, {"force":true})Code Snippets
rs.reconfig({
"_id" : "rs0",
"version" : 1.0,
"protocolVersion" : NumberLong(1),
"writeConcernMajorityJournalDefault" : true,
"members" : [
{
"_id" : 0.0,
"host" : "2f0bd979cc69:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1.0,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1.0
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : 2000.0,
"heartbeatTimeoutSecs" : 10.0,
"electionTimeoutMillis" : 10000.0,
"catchUpTimeoutMillis" : -1.0,
"catchUpTakeoverDelayMillis" : 30000.0,
"getLastErrorModes" : {
},
"getLastErrorDefaults" : {
"w" : 1.0,
"wtimeout" : 0.0
},
"replicaSetId" : ObjectId("6033b612985ce53324d7446c")
}
}, {"force":true})Context
StackExchange Database Administrators Q#232220, answer score: 5
Revisions (0)
No revisions yet.