Get the App
SLTechnology News&Howtos  ›  Database  › 

[MongoDB Learning Notes 33] MongoDB copy set rs auxiliary function

Shulou Source: shulou.com Published: 2022-06-01 16:22:40 09月18日 Update

Rs is a global variable, which contains replication-related helper functions, most of which are just wrappers for database commands, such as

> db.adminCommand ({"replSetInitiate": config})

Just like

> rs.initiate (config)

Commands are equivalent, but the latter is obviously easier to operate; it is easier to learn more about auxiliary functions.

Execute rs.help () to see the available helper functions, as follows:

Spock:PRIMARY > rs.help () rs.status () {replSetGetStatus: 1} checks replset 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://:28017/_replSet for additional diagnostic info

Tags: Function auxiliary command obvious global variable just data database equivalence or wrapper copy note learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Microsoft vpn NVidia Xiaomi