v1.8+
Use the rs.reconfig() helper in the shell. (Run "rs.reconfig" in the shell with no parenthesis to see what it does.)
$ mongo
> > cfg = rs.conf()
> cfg.members[0].priority = 2
> rs.reconfig(cfg)
Earlier versions (1.6)
You can reconfigure a set from any other language/driver/version using the replSetReconfig command directly.
$ mongo
> > > cfg = rs.conf()
> cfg.members[0].votes = 2
> cfg.version++
> use admin
> db.runCommand( { replSetReconfig : cfg } )
Requirements
- You must connect to the admin db of the current primary.
- A majority of members of the set must be up.
Notes
- You may experience a short downtime period while the set renegotiates master after a reconfiguration. This typically is 10-20 seconds. As always, it is best to do admin work during planned maintenance windows regardless just to be safe.
- In certain circumstances, the primary steps down (perhaps transiently) on a reconfiguration. On a step-down, the primary closes sockets from clients to assure the clients know quickly that the server is no longer primary. Thus, your shell session may experience a disconnect on a reconfig command.
See Also
PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.
blog comments powered by Disqus