flushRouterConfig

On this page本页内容

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 generally handled automatically by the cluster. 路由表缓存的管理通常由集群自动处理。You should only need to run the flushRouterConfig command manually in specific instances, as indicated under Considerations.您只需要在特定实例中手动运行flushRouterConfig命令,如注意事项中所示。

Note注意

Starting in MongoDB 4.4, running flushRouterConfig is no longer required after executing the movePrimary or dropDatabase commands. 从MongoDB 4.4开始,执行movePrimarydropDatabase命令后,不再需要运行flushRouterConfigThese two commands now automatically refresh a sharded cluster's routing table as needed when run.这两个命令现在可以在运行时根据需要自动刷新分片集群的路由表。

Syntax语法

Starting in MongoDB 4.0.6 (and 3.6.11), the flushRouterConfig is available on both mongos and mongod instances, and has the following syntax:从MongoDB 4.0.6(和3.6.11)开始,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 } )
Note注意

In MongoDB 4.0.5 and earlier (and 3.6.10 and earlier), flushRouterConfig is only available for mongos instances and can only flush the cache for all databases and their collections:在MongoDB 4.0.5和更早版本(以及3.6.10和更早版本)中,flushRouterConfig仅适用于mongos实例,并且只能刷新所有数据库及其集合的缓存:

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

Considerations注意事项

Generally, a sharded cluster's routing table is automatically refreshed as needed as part of normal operation. 通常,作为正常操作的一部分,分片集群的路由表会根据需要自动刷新。However, you should manually issue the flushRouterConfig command in the following instances:但是,您应该在以下情况下手动发出flushRouterConfig命令:

  • If running MongoDB 4.2 or earlier, after executing the movePrimary or dropDatabase commands.如果运行MongoDB 4.2或更早版本,则在执行movePrimarydropDatabase命令后。
  • If running MongoDB 4.2.2 or earlier (or 4.0.14 or earlier), after manually clearing the jumbo flag from a chunk that could not be split (i.e. an indivisible chunk). 如果运行MongoDB 4.2.2或更早版本(或4.0.14或更早版本),则在手动清除无法分割的块(即不可分割的块)中的jumbo标志之后。See Clear jumbo Flag for more information.有关详细信息,请参阅清除jumbo标志
  • Before running the db.collection.getShardDistribution() command. 在运行db.collection.getShardDistribution()命令之前。This ensures that the command returns the most up-to-date information.这可确保命令返回最新的信息。
←  enableShardinggetShardMap →