getShardMap
Nesta página
getShardMap
getShardMap
returns the following information about your cluster:The names of your shards and the config server replica set
Hostnames and connection strings for the nodes that comprise the cluster's shards and the config server replica set
You must use the admin database to run
getShardMap
.
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
Importante
Esse comando não é suportado em M,0 M,2 M5 e Flex clusters ou em instâncias sem servidor. Para obter mais informações, consulte Comandos não suportados.
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
O comando tem a seguinte sintaxe:
db.runCommand("getShardMap")
documento de saída
Here's an example of the output the command returns:
{ map: { shard01: 'shard01/localhost:27018,localhost:27019,localhost:27020,localhost:27021,localhost:27022', shard02: 'shard02/localhost:27023,localhost:27024,localhost:27025,localhost:27026,localhost:27027', shard03: 'shard03/localhost:27028,localhost:27029,localhost:27030,localhost:27031,localhost:27032', config: 'configRepl/localhost:27033',localhost:27034,localhost:27035,localhost:27036,localhost:27037' }, hosts: { 'localhost:27021': 'shard01', 'localhost:27022': 'shard01', 'localhost:27028': 'shard03', 'localhost:27026': 'shard02', 'localhost:27020': 'shard01', 'localhost:27032': 'shard03', 'localhost:27027': 'shard02', 'localhost:27024': 'shard02', 'localhost:27018': 'shard01', 'localhost:27019': 'shard01', 'localhost:27031': 'shard03', 'localhost:27025': 'shard02', 'localhost:27029': 'shard03', 'localhost:27023': 'shard02', 'localhost:27030': 'shard03', 'localhost:27033': 'config' 'localhost:27036': 'config' 'localhost:27034': 'config' 'localhost:27037': 'config' 'localhost:27035': 'config' }, connStrings: { 'shard01/localhost:27018,localhost:27019,localhost:27020,localhost:27021,localhost:27022': 'shard01', 'shard01/localhost:27019,localhost:27020,localhost:27021': 'shard01', 'shard01/localhost:27020,localhost:27021': 'shard01', 'shard01/localhost:27021': 'shard01', 'shard02/localhost:27023,localhost:27024,localhost:27025,localhost:27026,localhost:27027': 'shard02', 'shard02/localhost:27025,localhost:27026,localhost:27027': 'shard02', 'shard02/localhost:27025,localhost:27027': 'shard02', 'shard03/localhost:27028,localhost:27029,localhost:27030,localhost:27031,localhost:27032': 'shard03', 'shard03/localhost:27032': 'shard03', 'configRepl/localhost:27033',localhost:27036,localhost:27034,localhost:27037,localhost:27035': 'config' }, ok: 1 }
The command returns the following fields:
Campo | Descrição |
---|---|
| List of shards in the cluster, the config server for the cluster, and the hostname and port for every node in the cluster. |
| List of hostnames and ports for the nodes of the cluster and the shards or config server to which they map. |
| List of connection strings for the nodes grouped by the shard or config server the node belongs to. |
Saiba mais
For more sharding commands, see Comandos de fragmentação.