|
MongoDB常用操作命令整理
[日期:2015-07-08] | 来源:Linux社区 作者:Linux | [字体:大 中 小] |
mongodb操作命令(注意所有db.开头命令,请先使用use到指定db再操作)
连接操作数据库:
/usr/local/mongodb-3.0.4/bin/mongo 192.168.6.118:30000/admin
添加分片服务器:
db.runCommand({"addshard":"192.168.6.118:27017"})
设置分片数据库:
db.runCommand({"enablesharding": "qiaodazhao"})
db.runCommand({"enablesharding": "testdb"})
使用数据库:
use qiaodazhao
设置表分片基于字段hash:
sh.shardCollection("qiaodazhao.resume_meta_data",{_id:"hashed"})
sh.shardCollection("testdb.resumetemp",{_id:"hashed"})
设置表分片基于字段(注意以下两种方式作用相同):
db.runCommand({"shardcollection":"qiaodazhao.things", "key":{"_id":1}})
sh.shardCollection("qiaodazhao.things",{_id:1})
打印数据库分片信息:
db.printShardingStatus()
打印服务器信息:
db.serverStatus()
表格数据总量统计:
db.table.count()
创建表索引:
db.resume_meta_data.ensureIndex({"org_name":1},{"background":true})
查看表索引:
db.resume_meta_data.getIndexes()
MongoDB 3.0 正式版发布下载 http://www.iyunv.com/Linux/2015-03/114414.htm
CentOS编译安装MongoDB http://www.iyunv.com/Linux/2012-02/53834.htm
CentOS 编译安装 MongoDB与mongoDB的php扩展 http://www.iyunv.com/Linux/2012-02/53833.htm
CentOS 6 使用 yum 安装MongoDB及服务器端配置 http://www.iyunv.com/Linux/2012-08/68196.htm
Ubuntu 13.04下安装MongoDB2.4.3 http://www.iyunv.com/Linux/2013-05/84227.htm
MongoDB入门必读(概念与实战并重) http://www.iyunv.com/Linux/2013-07/87105.htm
Ubunu 14.04下MongoDB的安装指南 http://www.iyunv.com/Linux/2014-08/105364.htm
《MongoDB 权威指南》(MongoDB: The Definitive Guide)英文文字版[PDF] http://www.iyunv.com/Linux/2012-07/66735.htm
Nagios监控MongoDB分片集群服务实战 http://www.iyunv.com/Linux/2014-10/107826.htm
基于CentOS 6.5操作系统搭建MongoDB服务 http://www.iyunv.com/Linux/2014-11/108900.htm
MongoDB 的详细介绍:请点这里
MongoDB 的下载地址:请点这里
本文永久更新链接地址:http://www.iyunv.com/Linux/2015-07/119596.htm
|
|
|