【MongoDB学习笔记33】MongoDB副本集rs辅助函数
admin
2023-04-12 08:23:37
0

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://:28017/_replSet for additional diagnostic info



相关内容

热门资讯

终于了解“天天斗地主究竟有挂吗... 网上科普关于“天天斗地主有没有挂”话题很是火热,小编也是针对天天斗地主作*弊开挂的方法以及开挂对应的...
【第一资讯】“开心安徽比鸡怎么... 有 亲,根据资深记者爆料开心安徽比鸡是可以开挂的,确实有挂(咨询软件无需...
终于了解“授权大厅牛牛开挂器?... 有 亲,根据资深记者爆料授权大厅牛牛是可以开挂的,确实有挂(咨询软件无需...
今日重磅消息“免安装麻将机干扰... 网上科普关于“免安装麻将机干扰器有没有挂”话题很是火热,小编也是针对免安装麻将机干扰器作*弊开挂的方...
2025金融大模型评测体系在沪... 证券时报记者 陈雨康 上海人工智能实验室与上海库帕思科技有限公司联合主办的“2025金融大模型评测体...
【今日要闻】“海贝大厅炸/金/... 网上科普关于“海贝大厅炸/金/花有没有挂”话题很是火热,小编也是针对海贝大厅炸/金/花作*弊开挂的方...
终于了解“杭州麻将到底是不是挂... 家人们!今天小编来为大家解答杭州麻将透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里买很...
我来教教您“至尊宝牛牛究竟有挂... 我来教教您“至尊宝牛牛究竟有挂吗?”(太坑了原来有挂)您好,至尊宝牛牛这个游戏其实有挂的,确实是有挂...
【第一消息】“开心泉州麻将怎么... 有 亲,根据资深记者爆料开心泉州麻将是可以开挂的,确实有挂(咨询软件无需...
终于明白“网易麻将怎么装挂?”... 终于明白“网易麻将怎么装挂?”(果然有透视挂)您好,网易麻将这个游戏其实有挂的,确实是有挂的,需要了...