db.runCommand()示例

我们使用MongoDB Shell登录到mongos,添加Shard节点

[root@100 shard]# /usr/local/mongoDB/bin/mongo admin --port 40000
MongoDB shell version: 2.0.7
connecting to: 127.0.0.1:40000/admin
mongos> db.runCommand({ addshard:"localhost:27020" })
{ "shardAdded" : "shard0000", "ok" : 1 }
......
mongos> db.runCommand({ addshard:"localhost:27029" })
{ "shardAdded" : "shard0009", "ok" : 1 }
mongos> db.runCommand({ enablesharding:"test" }) #设置分片存储的数据库
{ "ok" : 1 }
mongos> db.runCommand({ shardcollection: "test.log", key: { id:1,time:1}})
{ "collectionsharded" : "test.log", "ok" : 1 }

一、分片命令

方法名 描述
shardCollection 对某个集合开启分片.
movePrimary 在将某个分片从集群中删除时,重新设置 primary shard .
removeShard 开始删除一个分片的过程.
enableSharding 对某个数据库开启分片
listShards 返回配置服务器中的分片列表
moveChunk 在分片间迁移数据块的内部命令.
addShard 在 sharded cluster 中增加一个 shard.
getShardVersion 返回 配置服务器 版本的内部命令.
splitVector 决定分裂点的内部命令.
setShardVersion 设置 配置服务器 上数据块版本的内部命令.
shardingState 报告一个 mongod 是不是集群中的一个分片.
mergeChunks 可以合并在一个分片上的数据块.
checkShardingIndex 验证片键上索引有效性的内部命令.
flushRouterConfig 强制更新一个 mongos 缓存的集群元信息.
unsetSharding 在MongoDB部署中影响实例间连接的内部命令.
split 创建一个新的 chunk.
isdbgrid Verifies that a process is a mongos.
splitChunk 分裂数据块的内部命令,使用 sh.splitFind() 和 sh.splitAt() 进行替代.
cleanupOrphaned 移除不属于某个分片却存储在这个分片的数据.
medianKey 废弃非内部命令,参见 splitVector.
getShardMap 报告集群状态的内部命令.

二、复制命令

方法名 描述
replSetStepDown  
replSetGetStatus  
isMaster  
replSetFreeze  
replSetReconfig  
replSetInitiate  
replSetMaintenance  
applyOps  
replSetSyncFrom  
resync  
replSetGetConfig

三、角色管理命令

方法名 描述
createRole  
dropAllRolesFromDatabase  
grantPrivilegesToRole  
rolesInfo  
revokePrivilegesFromRole  
invalidateUserCache  
dropRole  
revokeRolesFromRole  
updateRole  
grantRolesToRole  

四、用户管理命令

方法名 描述
updateUser  
usersInfo  
grantRolesToUser  
revokeRolesFromUser  
dropUser  
createUser 创建一个数据库新用户
dropAllUsersFromDatabase  

最新文章

  1. SQL Server遍历表的几种方法
  2. Java实现选择排序
  3. npoi实现 从固定的行读取数据作为表头并返回datable
  4. Hibernate逍遥游记-第13章 映射实体关联关系-005双向多对多(使用组件类集合\<composite-element>\)
  5. win7旗舰版通知windows不是正版副本解决方法
  6. <Learning How to Learn>Week One: Focused versus Diffuse Thinking
  7. Word续上表
  8. html5 本地存储
  9. 一次非典型的SQL报错
  10. Python爬虫(二十)_动态爬取影评信息
  11. PID算法笔记2
  12. 快速构建SPA框架SalutJS--项目工程目录 一
  13. 02:安装 Kerberos
  14. Spring如何使用JdbcTemplate调用存储过程的三种情况
  15. 为什么List.add()所增加的数据都是一样的
  16. 怎样建立你自己的MASM导入库
  17. Visual Studio Code配置Python开发环境
  18. 背水一战 Windows 10 (45) - 控件(图标类): IconElement, SymbolIcon, FontIcon, PathIcon, BitmapIcon
  19. ARP原理和欺骗
  20. WritePrivateProfileString、GetPrivateProfileString 读写配置文件

热门文章

  1. C++ 结构体、模板、类、重载初使用
  2. .net core mvc启动顺序以及主要部件4-MVC
  3. docker搭建elasticsearch、kibana,并集成至spring boot
  4. 【转载】UiPath,UiPath教程,UiPath视频教程 RPA
  5. .Net Core 遇到 “'windows-1252' is not a supported encoding name.”
  6. Django:RestFramework之-------频率控制
  7. Qt Graphics-View的打印功能实现
  8. Web前端2019面试总结2
  9. android解析xml (pull)
  10. 数据结构与算法5—KMP算法