When I use mongosh to connect to my instance of mongod I see the following warning:
2022-08-16T18:37:48.856-04:00: Document(s) exist in 'system.replset', but started without --replSet. Database contents may appear inconsistent with the writes that were visible when this node was running as part of a replica set. Restart with --replSet unless you are doing maintenance and no other clients are connected. The TTL collection monitor will not start because of this. For more info see http://dochub.mongodb.org/core/ttlcollections
When I start mongod with the --replSet rs0 argument to address the error it fails to start up with the following fatal error:
{
"t": { "$date": "2022-08-19T10:31:13.968-04:00" },
"s": "F",
"c": "REPL",
"id": 28545,
"ctx": "initandlisten",
"msg": "Locally stored replica set configuration does not parse; See http://www.mongodb.org/dochub/core/recover-replica-set-from-invalid-config for information on how to recover from this",
"attr": {
"error": {
"code": 40415,
"codeName": "Location40415",
"errmsg": "member: { _id: 0, host: \"127.0.0.1:27017\", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 } :: caused by :: BSON field 'MemberConfig.slaveDelay' is an unknown field."
},
"config": {
"_id": "rs0",
"version": 1,
"term": 10,
"members": [{
"_id": 0,
"host": "127.0.0.1:27017",
"arbiterOnly": false,
"buildIndexes": true,
"hidden": false,
"priority": 1,
"tags": {},
"slaveDelay": 0,
"votes": 1
}],
"protocolVersion": 1,
"writeConcernMajorityJournalDefault": true,
"settings": {
"chainingAllowed": true,
"heartbeatIntervalMillis": 2000,
"heartbeatTimeoutSecs": 10,
"electionTimeoutMillis": 10000,
"catchUpTimeoutMillis": -1,
"catchUpTakeoverDelayMillis": 30000,
"getLastErrorModes": {},
"getLastErrorDefaults": { "w": 1, "wtimeout": 0 },
"replicaSetId": { "$oid": "603820afb35392a07c24e0a8" }
}
}
}
}
The linked documentation just redirects to rs.reconfig
, which requires a configuration in order to run. I set up this replica set a long time ago so I’m not sure how to find its original configuration.
How can I fix this error so that I can start up mongod with a replica set again? Should I run rs.reconfig
with the config printed in the error message (minus the slaveDelay it’s failing to parse)?