Skip to content

Instantly share code, notes, and snippets.

@denzhel
Created March 24, 2022 19:48
Show Gist options
  • Select an option

  • Save denzhel/d05f582cfe16525700a3a4274f04b50f to your computer and use it in GitHub Desktop.

Select an option

Save denzhel/d05f582cfe16525700a3a4274f04b50f to your computer and use it in GitHub Desktop.
mongo replica set reconfigure error

If you're trying to rs.reconfigure() or rs.initiate() and you get the following error:

Cannot run replSetReconfig because the node is currently updating its configuration

And you can't seem to find any other solution, try this hack on each node of the replica set:

  1. SSH to the first node
  2. Edit Mongo's configuration file: sudo vi /etc/mongod.conf
  3. Comment out the replicaset config block
  4. Restart mongo: sudo service mongod restart
  5. Open Mongo Shell: mongo
  6. Run the following commands:
use local
db.system.replset.remove({})
  1. Open the file from step 2 again
  2. Remove the comments from step 3
  3. Restart mongo: sudo service mongod restart
  4. Repeat the process on all nodes

After you're done, run the rs.reconfigure() or rs.initiate() commands, e.g:

rs.initiate({_id: "<replicaSetName>",version: 1,members: [{ _id: 0, host : "X:27017" },{ _id: 1, host : "Y:27017" },{ _id: 2, host : "Y:27017" }]},{force:true})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment