【MongoDB学习笔记33】MongoDB副本集rs辅助函数-创新互联
rs是一个全局的变量,其中那个包含与复制相关的辅助函数,这些函数大多只是数据库命令的包装器,例如
成都网络公司-成都网站建设公司创新互联10年经验成就非凡,专业从事网站设计、成都网站制作,成都网页设计,成都网页制作,软文发稿,广告投放等。10年来已成功提供全面的成都网站建设方案,打造行业特色的成都网站建设案例,建站热线:18982081108,我们期待您的来电!>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://另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网页标题:【MongoDB学习笔记33】MongoDB副本集rs辅助函数-创新互联
文章位置:http://azwzsj.com/article/idgss.html