定义
flushRouterConfigflushRouterConfig将分片集群的缓存路由表标记为过时,导致请求路由表的下一个操作刷新缓存。 路由表缓存的管理由集群自动完成。
注意
Running flushRouterConfig is no longer required after executing movePrimary, dropDatabase, or db.collection.getShardDistribution(). These commands now automatically refresh a sharded cluster's routing table as needed when run.
兼容性
此命令可用于以下环境中托管的部署:
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
The flushRouterConfig is available on both mongos and mongod instances, and has the following syntax:
在集合命名空间参数中传递时,刷新指定集合的缓存:
db.adminCommand( { flushRouterConfig: "<db.collection>" } ) 在数据库命名空间参数中传递时,刷新指定数据库及其所有collection的缓存:
db.adminCommand( { flushRouterConfig: "<db>" } ) 在不带参数运行或传入非字符串标量值(例如
1):db.adminCommand("flushRouterConfig") db.adminCommand( { flushRouterConfig: 1 } )
访问控制
flushRouterConfig 命令需要 cluster 资源上的 flushRouterConfig 权限操作。
具有以下角色的用户也可以执行此权限操作: