mongo-help功能 version:2.6.12
下面是示例:

> help

db.help()                     help on db methods  
    db.mycoll.help()              help on collection methods
    sh.help()                    sharding helpers
    rs.help()                    replica set helpers
    help admin                    administrative help
    help connect                 connecting to a db help
    help keys                    key shortcuts
    help misc                    misc things to know
    help mr                      mapreduce

show dbs                         show database names
    show collections                show collections in current database
    show users                       show users in current database
    show profile                     show most recent system.profile entries with time >= 1ms
    show logs                        show the accessible logger names
    show log [name]               prints out the last segment of log in memory, 'global' is default
    use <db_name>                set current database
    db.foo.find()                     list objects in collection foo
    db.foo.find( { a : 1 } )        list objects in foo where a == 1
    it                                  result of the last line evaluated; use to further iterate
    DBQuery.shellBatchSize = x    set default number of items to display on shell
    exit                               quit the mongo shell

db.help()  //显示数据库操作命令

db.help()
DB methods:
    db.adminCommand(nameOrDocument)         - switches to 'admin' db, and runs command [ just calls db.runCommand(...) ]
    db.auth(username, password)
    db.cloneDatabase(fromhost)
    db.commandHelp(name)               - returns the help for the command
    db.copyDatabase(fromdb, todb, fromhost)
    db.createCollection(name, { size : ..., capped : ..., max : ... } )
    db.createUser(userDocument)
    db.currentOp()                   - displays currently executing operations in the db
    db.dropDatabase()
    db.eval(func, args)                - run code server-side
    db.fsyncLock()                   - flush data to disk and lock server for backups
    db.fsyncUnlock()                  - unlocks server following a db.fsyncLock()
    db.getCollection(cname)              - same as db['cname'] or db.cname
    db.getCollectionInfos()
    db.getCollectionNames()
    db.getLastError()                 - just returns the err msg string
    db.getLastErrorObj()               - return full status object
    db.getMongo()                    - get the server connection object
    db.getMongo().setSlaveOk()           - allow queries on a replication slave server
    db.getName()
    db.getPrevError()
    db.getProfilingLevel()              - deprecated
    db.getProfilingStatus()             - returns if profiling is on and slow threshold
    db.getReplicationInfo()
    db.getSiblingDB(name)              - get the db at the same server as this one
    db.getWriteConcern()     - returns the write concern used for any operations on this db, inherited from server object if set
    db.hostInfo()                   - get details about the server's host
    db.isMaster()                   - check replica primary status
    db.killOp(opid)                  - kills the current operation in the db
    db.listCommands()                 - lists all the db commands
    db.loadServerScripts()              - loads all the scripts in db.system.js
    db.logout()
    db.printCollectionStats()
    db.printReplicationInfo()
    db.printShardingStatus()
    db.printSlaveReplicationInfo()
    db.dropUser(username)
    db.repairDatabase()
    db.resetError()
    db.runCommand(cmdObj)                 - run a database command.  }
    db.serverStatus()
    db.setProfilingLevel(level,<slowms>)           - =off =slow =all
    db.setWriteConcern( <write concern doc> )    - sets the write concern for writes to the db
    db.unsetWriteConcern( <write concern doc> )    - unsets the write concern for writes to the db
    db.setVerboseShell(flag)                       - display extra information in shell output
    db.shutdownServer()
    db.stats()
    db.version()                     - current version of the server

db.mycoll.help  //数据库的集合进行操作、管理和监控

function () {
    var shortName = this.getName();
    print("DBCollection help");
    print("\tdb." + shortName + ".find().help() - show DBCursor help");
    print("\tdb." + shortName + ".count()");
    print("\tdb." + shortName + ".copyTo(newColl) - duplicates collection by copying all documents to newColl; no indexes are copied.");
    print("\tdb." + shortName + ".convertToCapped(maxBytes) - calls {convertToCapped:'" + shortName + "', size:maxBytes}} command");
    print("\tdb." + shortName + ".dataSize()");
    print("\tdb." + shortName + ".distinct( key ) - e.g. db." + shortName + ".distinct( 'x' )");
    print("\tdb." + shortName + ".drop() drop the collection");
    print("\tdb." + shortName + ".dropIndex(index) - e.g. db." + shortName + ".dropIndex( \"indexName\" ) or db." + shortName + ".dropIndex( { \"indexKey\" : 1 } )");
    print("\tdb." + shortName + ".dropIndexes()");
    print("\tdb." + shortName + ".ensureIndex(keypattern[,options]) - options is an object with these possible fields: name, unique, dropDups");
    print("\tdb." + shortName + ".reIndex()");
    print("\tdb." + shortName + ".find([query],[fields]) - query is an optional query filter. fields is optional set of fields to return.");
    print("\tdb." + shortName + ".find( {x:77} , {name:1, x:1} )");
    print("\tdb." + shortName + ".find(...).count()");
    print("\tdb." + shortName + ".find(...).limit(n)");
    print("\tdb." + shortName + ".find(...).skip(n)");
    print("\tdb." + shortName + ".find(...).sort(...)");
    print("\tdb." + shortName + ".findOne([query])");
    print("\tdb." + shortName + ".findAndModify( { update : ... , remove : bool [, query: {}, sort: {}, 'new': false] } )");
    print("\tdb." + shortName + ".getDB() get DB object associated with collection");
    print("\tdb." + shortName + ".getPlanCache() get query plan cache associated with collection");
    print("\tdb." + shortName + ".getIndexes()");
    print("\tdb." + shortName + ".group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )");
    print("\tdb." + shortName + ".insert(obj)");
    print("\tdb." + shortName + ".mapReduce( mapFunction , reduceFunction , <optional params> )");
    print("\tdb." + shortName + ".aggregate( [pipeline], <optional params> ) - performs an aggregation on a collection; returns a cursor");
    print("\tdb." + shortName + ".remove(query)");
    print("\tdb." + shortName + ".renameCollection( newName , <dropTarget> ) renames the collection.");
    print("\tdb." + shortName + ".runCommand( name , <options> ) runs a db command with the given name where the first param is the collection name");
    print("\tdb." + shortName + ".save(obj)");
    print("\tdb." + shortName + ".stats()");
    print("\tdb." + shortName + ".storageSize() - includes free space allocated to this collection");
    print("\tdb." + shortName + ".totalIndexSize() - size in bytes of all the indexes");
    print("\tdb." + shortName + ".totalSize() - storage allocated for all data and indexes");
    print("\tdb." + shortName + ".update(query, object[, upsert_bool, multi_bool]) - instead of two flags, you can pass an object with fields: upsert, multi");
    print("\tdb." + shortName + ".validate( <full> ) - SLOW");;
    print("\tdb." + shortName + ".getShardVersion() - only for use with sharding");
    print("\tdb." + shortName + ".getShardDistribution() - prints statistics about data distribution in the cluster");
    print("\tdb." + shortName + ".getSplitKeysForChunks( <maxChunkSize> ) - calculates split points over all chunks and returns splitter function");
    print("\tdb." + shortName + ".getWriteConcern() - returns the write concern used for any operations on this collection, inherited from server/db if set");
    print("\tdb." + shortName + ".setWriteConcern( <write concern doc> ) - sets the write concern for writes to the collection");
    print("\tdb." + shortName + ".unsetWriteConcern( <write concern doc> ) - unsets the write concern for writes to the collection");
    return __magicNoPrint;
}

sh.help

function () {
    print( "\tsh.addShard( host )                       server:port OR setname/server:port" )
    print( "\tsh.enableSharding(dbname)                 enables sharding on the database dbname" )
    print( "\tsh.shardCollection(fullName,key,unique)   shards the collection" );

    print( "\tsh.splitFind(fullName,find)               splits the chunk that find is in at the median" );
    print( "\tsh.splitAt(fullName,middle)               splits the chunk that middle is in at middle" );
    print( "\tsh.moveChunk(fullName,find,to)            move the chunk where 'find' is to 'to' (name of shard)");

    print( "\tsh.setBalancerState( <bool on or not> )   turns the balancer on or off true=on, false=off" );
    print( "\tsh.getBalancerState()                     return true if enabled" );
    print( "\tsh.isBalancerRunning()                    return true if the balancer has work in progress on any mongos" );

    print( "\tsh.addShardTag(shard,tag)                 adds the tag to the shard" );
    print( "\tsh.removeShardTag(shard,tag)              removes the tag from the shard" );
    print( "\tsh.addTagRange(fullName,min,max,tag)      tags the specified range of the given collection" );

    print( "\tsh.status()                               prints a general overview of the cluster" )
}

rs.help

function () {
    print("\trs.status()                     { replSetGetStatus : 1 } checks repl set status");
    print("\trs.initiate()                   { replSetInitiate : null } initiates set with default settings");
    print("\trs.initiate(cfg)                { replSetInitiate : cfg } initiates set with configuration cfg");
    print("\trs.conf()                       get the current configuration object from local.system.replset");
    print("\trs.reconfig(cfg)                updates the configuration of a running replica set with cfg (disconnects)");
    print("\trs.add(hostportstr)             add a new member to the set with default attributes (disconnects)");
    print("\trs.add(membercfgobj)            add a new member to the set with extra attributes (disconnects)");
    print("\trs.addArb(hostportstr)          add a new member which is arbiterOnly:true (disconnects)");
    print("\trs.stepDown([secs])             step down as primary (momentarily) (disconnects)");
    print("\trs.syncFrom(hostportstr)        make a secondary to sync from the given member");
    print("\trs.freeze(secs)                 make a node ineligible to become primary for the time specified");
    print("\trs.remove(hostportstr)          remove a host from the replica set (disconnects)");
    print("\trs.slaveOk()                    shorthand for db.getMongo().setSlaveOk()");
    print("\trs.printReplicationInfo()       check oplog size and time range");
    print("\trs.printSlaveReplicationInfo()  check replica set members and replication lag");
    print("\tdb.isMaster()                   check who is primary");
    print("\treconfiguration helpers disconnect from the database so the shell will display");
    print("\tan error, even if the command succeeds.");
    print("\tsee also http://<mongod_host>:28017/_replSet for additional diagnostic info");
}

mongodb-help功能的更多相关文章

  1. MongoDB基础

    1.概念及特点 说明:由于部分语句中$ 符号无法正常显示,使用¥代表 概念 MongoDB是一个基于文档的分布式的开源的NoSQL数据库,文档的结构为BSON形式,每一个文档都有一个唯一的Object ...

  2. MongoDB学习笔记一—简介

    MongoDB简介 MongoDB在功能和复杂性之间取得了很好的平衡,并且大大简化了原先十分复杂的任务,它具备支撑今天主流web应用的关键功能:索引.复制.分片.丰富的查询语法,特别灵活的数据模型.与 ...

  3. MongoDB数据库未授权访问漏洞及加固

    1.漏洞危害 开启MongoDB服务时不添加任何参数时,默认是没有权限验证的,登录的用户可以通过默认端口无需密码对数据库任意操作(增删改高危动作)而且可以远程访问数据库. 2.漏洞成因 在刚安装完毕的 ...

  4. Mongodb学习笔记一(Mongodb环境配置)

    Mongodb学习 说明: MongoDB由databases组成,database由collections组成,collection由documents组成,document由fileds组成.Mo ...

  5. Mongodb Manual阅读笔记:CH4 管理

    4 管理 Mongodb Manual阅读笔记:CH2 Mongodb CRUD 操作Mongodb Manual阅读笔记:CH3 数据模型(Data Models)Mongodb Manual阅读笔 ...

  6. MongoDB基本概念

    MongoDB是一种强大灵活可扩展的数据存储方式,它扩展了关系数据库的众多功能.MongoDB的功能非常丰富,但是却非常容易上手和便于使用,今天来了解一下MongoDB的主要概念. 文档 文档是的核心 ...

  7. 学习Mongodb(一)

    图片摘录自陈彦铭出品2012.5的<10天掌握MongDB> MongoDB的特点--->面向集合存储,易于存储对象类型的数据--->模式自由--->支持动态查询---& ...

  8. Windows Azure下如何安装 MongoDb

    MongoDB 是一种受欢迎的高性能 NoSQL 开源数据库.使用 Windows Azure管理门户,您可从映像库创建运行 CentOS Linux 的虚拟机.然后,您可以在该虚拟机上安装和配置 M ...

  9. MongoDB数据库基础操作

    前面的话 为了保存网站的用户数据和业务数据,通常需要一个数据库.MongoDB和Node.js特别般配,因为Mongodb是基于文档的非关系型数据库,文档是按BSON(JSON的轻量化二进制格式)存储 ...

  10. MongoDB入门学习(一):MongoDB的安装和管理

    以前用MySQL数据库,整天都是写大堆大堆的SQL语句,要记住这些SQL关键字都要花好几天时间,写的蛋都爆了,当接触到MongoDB的时候,发现不用写SQL,瞬间觉得高大上,瞬间产生了学习使用它的冲动 ...

随机推荐

  1. CSS选择器(三)

    九.CSS 伪类 (Pseudo-classes) CSS 伪类用于向某些选择器添加特殊的效果. CSS 伪类 (Pseudo-classes)实例: 1.向文档中的超链接添加不同的颜色. <s ...

  2. mysql sql语句:行转列问题

    存在表score,记录学生的考试成绩,如下图所示: 现要求以 学生姓名,语文,数学,英语 这种格式显示学生成绩,如下图所示 具体步骤如下: 1.首先,使用case when函数输出单个课程的成绩 ca ...

  3. [原创]java WEB学习笔记40:简单标签概述(背景,使用一个标签,标签库的API,SimpleTag接口,创建一个自定义的标签的步骤 和简单实践)

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...

  4. java 遍历数组的几种方式

    本文总结自: https://www.cnblogs.com/hellochennan/p/5373186.html 1. 传统方式 非常简单的for循环 int[] a = {1, 2, 3, 4} ...

  5. 收缩VC数据库

    注意: 在收缩日志前必须截断事务日志. 一. SQL Server 2008 收缩日志 (1) 使用SQL管理器收缩日志 第一步执行如下命令 ALTER DATABASE dbname SET REC ...

  6. JAVA强制类型转换(转载+自己的感想) - stemon

    JAVA强制类型转换(转载+自己的感想) - stemon 时间 2013-10-29 15:52:00  博客园-Java原文  http://www.cnblogs.com/stemon/p/33 ...

  7. 爬虫第一篇:爬虫详解之urllib.request模块

    我将urllib.request 的GET请求和POST请求两种方法做了总结 GET请求 GET请求爬取: import urllib.request import urllib.parse head ...

  8. django使用html模板减少代码

    看下面两个页面: —————————————————————————————————————————————————————————————————————————————————— 一个显示文章列表 ...

  9. node cluster模块的使用和测试

    首先安装async包 用到的有http.cluster包 http和cluster都会node自带的包,无需安装 1:创建cluster.js,代码如下,更具cpu创建多个进程 var cluster ...

  10. 一致性问题和Raft一致性算法——一致性问题是无法彻底解决的,可以说一个分布式系统可靠性达到99.99…%,但不能说它达到了100%

    一致性问题 一致性算法是用来解决一致性问题的,那么什么是一致性问题呢? 在分布式系统中,一致性问题(consensus problem)是指对于一组服务器,给定一组操作,我们需要一个协议使得最后它们的 ...