【MongoDB學習筆記33】MongoDB複本集rs輔助函數

來源:互聯網
上載者:User

標籤:mongodb   rs   

rs是一個全域的變數,其中那個包含與複製相關的輔助函數,這些函數大多隻是資料庫命令的封裝器,例如

>db.adminCommand({“replSetInitiate”:config})

就和

>rs.initiate(config)

命令是等價的,但是明顯後者更容易操作;多瞭解一下輔助函數還是比較利於操作的。

執行rs.help()可查看可用的輔助函數,如下:

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



本文出自 “緣隨心愿” 部落格,請務必保留此出處http://281816327.blog.51cto.com/907015/1611295

【MongoDB學習筆記33】MongoDB複本集rs輔助函數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.