Skip to content

Instantly share code, notes, and snippets.

@plainprogrammer
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plainprogrammer/63c243ec7c78f5fe28a2 to your computer and use it in GitHub Desktop.
Save plainprogrammer/63c243ec7c78f5fe28a2 to your computer and use it in GitHub Desktop.
MongoDB Forced Reconfiguration

Directions

  1. On the primary, edit /etc/mongod.conf so that it will start and join the evgrs replica set.

  2. On the primary, restart mongod

  3. Get into a mongo console, and run the following series of commands:

    // First we need to connect to the mongo console and copy the current configuration. cfg = rs.conf() printjson(cfg)

    // For this step you need to identify the members you want to keep in the replica // set. In our case, this should probably be the primary that we want/trust and // the arbiter. That should allow the cluster to come back online. cfg.members = [cfg.members[?]]

    // Now we force the modified copy of the configuration. rs.reconfig(cfg, {force: true})

  4. Give the server time to move itself up to master. Confirm that this happens before moving on.

  5. On each secondary, destroy everything in /var/lib/mongo

  6. On each secondary, ensure they are configured to join the right replica set (evgrs)

  7. On each secondary, start mongod

  8. On the primary, use the following commands to add each secondary to the replica set:

    rs.add("hostname.evg.int:27017")

  9. Wait for the secondaries to all resync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment