On this page本页内容
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命令,如注意事项中所示。
Starting in MongoDB 4.4, running 从MongoDB 4.4开始,执行flushRouterConfig is no longer required after executing the movePrimary or dropDatabase commands. movePrimary或dropDatabase命令后,不再需要运行flushRouterConfig。These two commands now automatically refresh a sharded cluster's routing table as needed when run.这两个命令现在可以在运行时根据需要自动刷新分片集群的路由表。
Starting in MongoDB 4.0.6 (and 3.6.11), the 从MongoDB 4.0.6(和3.6.11)开始,flushRouterConfig is available on both mongos and mongod instances, and has the following syntax:flushRouterConfig在mongos和mongod实例上都可用,并具有以下语法:
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 } )
In MongoDB 4.0.5 and earlier (and 3.6.10 and earlier), 在MongoDB 4.0.5和更早版本(以及3.6.10和更早版本)中,flushRouterConfig is only available for mongos instances and can only flush the cache for all databases and their collections:flushRouterConfig仅适用于mongos实例,并且只能刷新所有数据库及其集合的缓存:
db.adminCommand("flushRouterConfig") db.adminCommand( { flushRouterConfig: 1 } )
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命令:
movePrimary or dropDatabase commands.movePrimary或dropDatabase命令后。jumbo flag from a chunk that could not be split (i.e. an indivisible chunk). jumbo标志之后。jumbo Flag for more information.jumbo标志。db.collection.getShardDistribution() command. db.collection.getShardDistribution()命令之前。