对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

flushRouterConfig(数据库命令)

flushRouterConfig

flushRouterConfig 将分片集群的缓存路由表标记为过时,导致请求路由表的下一个操作刷新缓存。 路由表缓存的管理由集群自动完成。

注意

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

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 权限操作。

具有以下角色的用户也可以执行此权限操作:

给本页内容打分