db.adminCommand({“replSetInitiate”:config})就和>rs.in..."/>
溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

【MongoDB學(xué)習(xí)筆記33】MongoDB副本集rs輔助函數(shù)

發(fā)布時間:2020-06-18 16:10:13 來源:網(wǎng)絡(luò) 閱讀:1430 作者:StanlyCheng 欄目:MongoDB數(shù)據(jù)庫

rs是一個全局的變量,其中那個包含與復(fù)制相關(guān)的輔助函數(shù),這些函數(shù)大多只是數(shù)據(jù)庫命令的包裝器,例如

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

就和

>rs.initiate(config)

命令是等價的,但是明顯后者更容易操作;多了解一下輔助函數(shù)還是比較利于操作的。

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

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 primary
reconfiguration 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



向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI