RS is a global variable that contains auxiliary functions related to replication, most of which are simply wrappers for database commands, such as
>db.admincommand ({"replsetinitiate": config})
Just and
>rs.initiate (config)
Commands are equivalent, but obviously the latter is easier to manipulate; it's better to know more about auxiliary functions.
Perform rs.help () to see the available auxiliary functions, as follows:
Spock:primary> rs.help () rs.status () { replSetGetStatus : 1 } checks repl set Status rs.initiate () { replSetInitiate : null } initiates set with default Settings rs.initiate (CFG) { replSetInitiate : cfg } initiates set with configuration cfg rs.conf () get the current configuration object from local.system.replset rs.reconfig (CFG) updates the configuration of a running replica set with cfg (disconnects) rs.add (HostportSTR) add a new member to the set with default attributes (disconnects) rs.add (membercfgobj) add a new member to the set with extra attributes (disconnects) rs.addarb (HOSTPORTSTR) add a new member which is arbiterOnly:true (disconnects) rs.stepdown ([secs]) step down as primary (momentarily) ( Disconnects) rs.syncfrom (HOSTPORTSTR) make a secondary to sync from the given Member rs.freeze (secs) make a node ineligible to Become primary for the time specified rs.remove (HOSTPORTSTR) remove a host from the replica set (disconnects) rs.slaveok () shorthand for db.getmongo (). Setslaveok () Rs.printreplicationinfo () check oplog size and time range rs.printslavereplicationinfo () check replica set members and Replication lag db.ismaster () check who is primaryreconfiguration helpers disconnect from the database so the shell will display an error, even if the command succeeds. see also http://<mongod_host >:28017/_replset for additionAl diagnostic info
This article is from the "Margin with Wish" blog, please be sure to keep this source http://281816327.blog.51cto.com/907015/1611295
"MongoDB Learning Note 33" MongoDB replica set RS helper function