Database Manual / Reference / Database Commands / Sharding

flushRouterConfig (database command数据库命令)

Definition定义

flushRouterConfig
flushRouterConfig marks the cached routing table for a sharded cluster as stale, causing the next operation that requests the routing table to refresh the cache. Management of the routing table cache is handled automatically by the cluster.将分片集群的缓存路由表标记为过时,从而导致下一个请求路由表刷新缓存的操作。路由表缓存的管理由集群自动处理。

Note

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.执行movePrimarydropDatabasedb.collection.getShardDistribution()后,不再需要运行flushRouterConfig。这些命令现在可以在运行时根据需要自动刷新分片集群的路由表。

Compatibility兼容性

This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务
  • MongoDB Enterprise: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本
  • MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本

Syntax语法

The flushRouterConfig is available on both mongos and mongod instances, and has the following syntax:flushRouterConfigmongosmongod实例上都可用,语法如下:

  • Flush the cache for a specified collection when passed in a collection namespace parameter:在传入集合命名空间参数时,刷新指定集合的缓存:

    db.adminCommand(
    {
    flushRouterConfig: "<db.collection>"
    }
    )
  • Flush the cache for a specified database and all of its collections when passed in a database namespace parameter:在数据库命名空间参数中传递时,刷新指定数据库及其所有集合的缓存:

    db.adminCommand(
    {
    flushRouterConfig: "<db>"
    }
    )
  • Flush the cache for all databases and their collections when run without a parameter or passed in a non-string scalar value (e.g. 1):在不带参数运行或传入非字符串标量值(例如1)时,刷新所有数据库及其集合的缓存:

    db.adminCommand("flushRouterConfig")
    db.adminCommand(
    {
    flushRouterConfig: 1
    }
    )