MongoDB Shell db.runCommand
2024-09-05 07:00:49
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 |
最新文章
- SQL Server遍历表的几种方法
- Java实现选择排序
- npoi实现 从固定的行读取数据作为表头并返回datable
- Hibernate逍遥游记-第13章 映射实体关联关系-005双向多对多(使用组件类集合\<;composite-element>;\)
- win7旗舰版通知windows不是正版副本解决方法
- <;Learning How to Learn>;Week One: Focused versus Diffuse Thinking
- Word续上表
- html5 本地存储
- 一次非典型的SQL报错
- Python爬虫(二十)_动态爬取影评信息
- PID算法笔记2
- 快速构建SPA框架SalutJS--项目工程目录 一
- 02:安装 Kerberos
- Spring如何使用JdbcTemplate调用存储过程的三种情况
- 为什么List.add()所增加的数据都是一样的
- 怎样建立你自己的MASM导入库
- Visual Studio Code配置Python开发环境
- 背水一战 Windows 10 (45) - 控件(图标类): IconElement, SymbolIcon, FontIcon, PathIcon, BitmapIcon
- ARP原理和欺骗
- WritePrivateProfileString、GetPrivateProfileString 读写配置文件
热门文章
- C++ 结构体、模板、类、重载初使用
- .net core mvc启动顺序以及主要部件4-MVC
- docker搭建elasticsearch、kibana,并集成至spring boot
- 【转载】UiPath,UiPath教程,UiPath视频教程 RPA
- .Net Core 遇到 &ldquo;'windows-1252' is not a supported encoding name.&rdquo;
- Django:RestFramework之-------频率控制
- Qt Graphics-View的打印功能实现
- Web前端2019面试总结2
- android解析xml (pull)
- 数据结构与算法5—KMP算法