Frank
Frank

Reputation: 1407

MongoDB Unable to reach primary for set '<new replica set name>'

I'm trying to rename a MondoDB Replica Set as explained in the MongoDB docs:

/* Set `newId` to the new replica set name */
var newId = 'idcom'

var doc = db.getSiblingDB("local").system.replset.findOne()
var oldId = doc._id
doc._id = newId
db.getSiblingDB("local").system.replset.save(doc)
db.getSiblingDB("local").system.replset.remove({_id: oldId})

However, it did not work and I am unable to revert to the previous configuration. If I attempt to repeat the instructions (start with a different port, etc.) the mongod.service on my Ubuntu machine, it does not start due to the following error:

mongod[20493]: Unrecognized option: processManagement.replication.replSetName 
systemd[1]: mongod.service: Main process exited, code=exited, status=2/INVALIDARGUMENT 
systemd[1]: mongod.service: Failed with result 'exit-code'.

If I attempt starting MongoDB via mongod command mongod --dbpath /opt/mongodb/ --port 27017 --replSet idcom the server starts, but I cannot access the MongoDB terminal and logs keep throwing the following:

NETWORK  [ReplicaSetMonitor-TaskExecutor] Unable to reach primary for set idcomm

Any help on how to revert to the previous configuration, please? Previously the SECONDARY was set with replSetName: "comm0"

Thx!

Upvotes: 0

Views: 1205

Answers (1)

Wernfried Domscheit
Wernfried Domscheit

Reputation: 59642

I would suggest to deploy the replicaset from scratch.

  1. Stop all instances
  2. Restart one instance in maintenance mode as described in Restart the secondary as a standalone on a different port
  3. Connect to this instance and drop the local database: db.getSiblingDB('local').drop()
  4. On all other nodes remove all files from dbpath (maybe you can skip this, because an Initial Sync will delete all data anyway)
  5. Restart the instance in normal mode and deploy the replicaset as given in Deploy a Replica Set, i.e. rs.initiate(), rs.add(), etc.

Upvotes: 1

Related Questions