iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >【MongoDB学习笔记33】MongoDB副本集rs辅助函数
  • 714
分享到

【MongoDB学习笔记33】MongoDB副本集rs辅助函数

2024-04-02 19:04:59 714人浏览 独家记忆
摘要

rs是一个全局的变量,其中那个包含与复制相关的辅助函数,这些函数大多只是数据库命令的包装器,例如>db.adminCommand({“replSetInitiate”:config})就和>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 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



您可能感兴趣的文档:

--结束END--

本文标题: 【MongoDB学习笔记33】MongoDB副本集rs辅助函数

本文链接: https://www.lsjlt.com/news/37671.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作