Definição
flushRouterConfigflushRouterConfigmarks 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 theflushRouterConfigcommand manually in specific instances, as indicated under Considerations.
Observação
Running flushRouterConfig is no longer required after executing the movePrimary or dropDatabase commands. These two commands now automatically refresh a sharded cluster's routing table as needed when run.
Compatibilidade
Esse comando está disponível em implantações hospedadas nos seguintes ambientes:
- MongoDB Atlas: o serviço totalmente gerenciado para implantações do MongoDB na nuvem
MongoDB Enterprise: a versão autogerenciada e baseada em assinatura do MongoDB
MongoDB Community: uma versão com código disponível, de uso gratuito e autogerenciada do MongoDB
Sintaxe
The flushRouterConfig is available on both mongos and mongod instances, and has the following syntax:
Liberar o cache para uma collection especificada quando passada em um parâmetro de namespace da collection:
db.adminCommand( { flushRouterConfig: "<db.collection>" } ) Liberar o cache de um reconhecimento de data center especificado e todas as suas collection quando passado em um parâmetro de namespace do reconhecimento de data center:
db.adminCommand( { flushRouterConfig: "<db>" } ) Limpar o cache para todos os reconhecimento de data center e suas collection ao executar sem um parâmetro ou passar em um valor escalar não string (por exemplo
1):db.adminCommand("flushRouterConfig") db.adminCommand( { flushRouterConfig: 1 } )
Considerações
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 before running the db.collection.getShardDistribution() command. This ensures that the command returns the most up-to-date information.