【MongoDB学习笔记33】MongoDB副本集rs辅助函数
发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,rs是一个全局的变量,其中那个包含与复制相关的辅助函数,这些函数大多只是数据库命令的包装器,例如>db.adminCommand({"replSetInitiate":config})就和>rs.in
千家信息网最后更新 2026年11月02日【MongoDB学习笔记33】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://:28017/_replSet for additional diagnostic info
函数
辅助
命令
明显
全局
变量
只是
数据
数据库
等价
还是
包装
副本
笔记
学习
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
蓝思科技飞鸽互联网
科技互联网项目
互联网金融与金融科技
西安互联网科技
互联网 科技创业
互联网科技股票
广州互联网络科技有限公司
狮子座互联网科技培训
互联网和高科技公司
科技互联网大厂
湖南一路畅行互联网科技
辽宁互联网新科技
互联网金融科技展
互联网科技如何创业
上海京穆互联网科技有限公司
沐思想互联网科技有限公司
新氧科技和美国互联网有关系吗
济南小医互联网科技有限公司招聘
西安左小互联网科技有限公司
张家口科技产业互联网平台
互联网科技有限公司图片
互联网下的科技发展
广州互联网科技公司
字节跳动和互联网科技
21世纪互联网科技成就
上海互联网科技公司ppt
国产互联网科技公司
湖北辰鑫科技互联网
株洲百竞科技的互联网营销顾问
小牛互联网科技有限公司地址