Para agentes de IA: um índice de documentação está disponível em https://www.mongodb.com/pt-br/docs/llms.txt — as versões de markdown de todas as páginas estão disponíveis anexando .md a qualquer caminho de URL.
Menu Docs

sh.status() (método mongosh)

sh.status()

Quando executado em uma instância mongos imprime um relatório formatado da configuração de fragmentação e as informações sobre os chunks existentes em um cluster fragmentado. O comportamento padrão suprime as informações detalhadas do chunk se o número total de chunks for maior ou igual a 20.

The sh.status() method has the following parameter:

Parâmetro
Tipo
Descrição

verbose

booleano

Opcional. Determina o nível de verbosidade.

Se for true, o método exibe:

  • Detalhes completos da distribuição de chunks em shards, mesmo se você tiver 20 ou mais chunks, bem como o número de chunks em cada shard.

Se for false, o método exibe:

  • Detalhes completos da distribuição de chunk em shards somente se você tiver menos de 20 chunks. Se você tiver 20 ou mais chunks, o método retornará uma mensagem de too many chunks to print ..., mostrando apenas o número de chunks em cada shard.

O valor detalhado padrão é false.

A saída também inclui uma seção shardedDataDistribution, que fornece métricas de distribuição de dados para cada coleção fragmentada. Esses dados são os mesmos que a saída do estágio de agregação $shardedDataDistribution.

Esse método está disponível em implantações hospedadas nos seguintes ambientes:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

Importante

This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.

  • 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

The Sharding Version section displays information on the config database:

--- Sharding Status ---
sharding version: {
"_id" : <num>,
"minCompatibleVersion" : <num>,
"currentVersion" : <num>,
"clusterId" : <ObjectId>
}

A seção Fragmentos lista informações sobre o(s) fragmento(s). Para cada fragmento, a seção exibe o nome, o host e as tags associadas, se houver.

shards:
{ "_id" : <shard name1>, "host" : <string>, "tags" : [ <string> ... ], "state" : <num> }
{ "_id" : <shard name2>, "host" : <string>, "tags" : [ <string> ... ], "state" : <num> }
...

The Active mongos Instances section displays, by default, information on the version and count of mongos instances that have been active within the last 60 seconds:

active mongoses:
<version> : <num>

If the method is run with the verbose parameter to true, the Active mongos Instances section displays additional information:

active mongoses:
{ "_id" : "<hostname:port>", "advisoryHostFQDNs" : [ "<name>" ], "mongoVersion" : <string>, "ping" : <ISODate>, "up" : <long>, "waiting" : <boolean> }

A Autosplit exibe informações sobre se autosplit está habilitada:

autosplit:
Currently enabled: <yes|no>

The Balancer section lists information about the state of the balancer. This provides insight into current balancer operation and can be useful when troubleshooting an unbalanced sharded cluster.

balancer:
Currently enabled: yes
Currently running: yes
Collections with active migrations:
config.system.sessions started at Fri May 15 2020 17:38:12 GMT-0400 (EDT)
Failed balancer rounds in last 5 attempts: 0
Migration Results for the last 24 hours:
416 : Success
1 : Failed with error 'aborted', from shardA to shardB

A seção Bancos de dados lista informações sobre o(s) banco(s) de dados. Ela exibe o nome do banco de dados e o fragmento primário de cada banco de dados.

databases:
{ "_id" : <dbname1>, "primary" : <string>, "partitioned" : <boolean>, "version": <document> }
{ "_id" : <dbname2>, "primary" : <string>, "partitioned" : <boolean>, "version": <document> }
...

The Sharded Collection section provides information on the sharding details for sharded collection(s). For each sharded collection, the section displays the shard key, the number of chunks per shard(s), the distribution of chunks across shards [1], and the tag information, if any, for shard key range(s).

<dbname>.<collection>
shard key: { <shard key> : <1 or hashed> }
unique: <boolean>
balancing: <boolean>
allowMigrations: <boolean>
chunks:
<shard name1> <number of chunks>
<shard name2> <number of chunks>
...
{ <shard key>: <min range1> } -->> { <shard key> : <max range1> } on : <shard name> <last modified timestamp>
{ <shard key>: <min range2> } -->> { <shard key> : <max range2> } on : <shard name> <last modified timestamp>
...
tag: <tag1> { <shard key> : <min range1> } -->> { <shard key> : <max range1> }
...

The Sharded Data Distribution section displays data distribution information for each sharded collection:

shardedDataDistribution:
[
{
"ns" : "<database>.<collection>",
"shards" : [
{
"shardName" : "<shard name>",
"numOrphanedDocs" : <num>,
"numOwnedDocuments" : <num>,
"ownedSizeBytes" : <num>,
"orphanedSizeBytes" : <num>
}
]
}
]
sh.status.sharding-version._id

The _id is an identifier for the version details.

sh.status.sharding-version.minCompatibleVersion

The minCompatibleVersion is the minimum compatible version of the config server.

Em versões do MongoDB anteriores à 6.2, esse campo é incluído na collection config.version , mas no mongosh 2.0.0 e posterior, o campo não é retornado na saída do sh.status() . A partir do MongoDB 6.2, esse campo é removido e não é retornado em nenhuma versão mongosh ou outro aplicativo cliente. Em vez disso, para obter informações sobre a versão, consulte a feature compatibility version (fcv).

sh.status.sharding-version.currentVersion

The currentVersion is the current version of the config server.

Em versões do MongoDB anteriores à 6.2, esse campo é incluído na collection config.version , mas no mongosh 2.0.0 e posterior, o campo não é retornado na saída do sh.status() . A partir do MongoDB 6.2, esse campo é removido e não é retornado em nenhuma versão mongosh ou outro aplicativo cliente. Em vez disso, para obter informações sobre a versão, consulte a feature compatibility version (fcv).

sh.status.sharding-version.clusterId

The clusterId is the identification for the sharded cluster.

sh.status.active-mongoses

If verbose is false, sh.status.active-mongoses lists the version and count of the active mongos instances. Active mongos instances are mongos instances that have been pinged within the last 60 seconds.

If verbose is true, sh.status.active-mongoses returns a document for each active mongos instance containing the following fields:

Campo
Tipo de Dados
Descrição

_id

String

O nome do host e a porta onde o mongos está sendo executado. O _id está formatado como <hostname>:<port>.

advisoryHostFQDNs

Array de strings

Array dos FQDNs (Fully Qualified Domain Names, Nomes de domínio totalmente qualificados) do mongos.

created

Data

Quando o mongos foi iniciado.

Novidades na versão 5.2.

mongoVersion

String

Versão do MongoDB que o mongos está executando.

ping

Data

As instâncias mongos enviam pings para o servidor de configuração a cada 30 segundos. Este campo indica a hora do último ping.

up

Número longo

Número de segundos em que mongos esteve ativo desde o último ping.

waiting

Boolean

Esse campo é sempre true e só é incluído para fins de compatibilidade com versões anteriores.

active mongoses:
{
"_id" : "<hostname:port>",
"advisoryHostFQDNs" : [ "<name>" ],
"created" : <ISODate>,
"mongoVersion" : <string>,
"ping" : <ISODate>,
"up" : <long>,
"waiting" : <boolean>
}
...
sh.status.autosplit

sh.status.autosplit indica se a divisão automática está habilitada no momento.

Observação

A partir do MongoDB 6.0.3, a divisão automática de partes não é executada. Isso se deve a melhorias na política de balanceamento. Os comandos de divisão automática ainda existem, mas não executam uma operação.

Em versões anteriores ao MongoDB 6.1:

Os métodos mongo sh.enableBalancing(namespace) e sh.disableBalancing(namespace) não afetam a divisão automática.

sh.status.automerge

Indica se o AutoMerger está ativado.

Observação

A seção automerge só aparece se você habilitar ou desabilitar explicitamente o AutoMerger. Como padrão, o AutoMerger vem ativado.

sh.status.shards._id

The _id displays the name of the shard.

sh.status.shards.host

The host displays the host location of the shard.

sh.status.shards.tags

The tags displays all the tags for the shard. The field only displays if the shard has tags.

sh.status.shards.state

The state displays:

  • 0 se o shard não reconhecer shards.

  • 1 se o shard reconhecer shards.

Observação

A partir do MongoDB 6.0.3, a divisão automática de partes não é executada. Isso se deve a melhorias na política de balanceamento. Os comandos de divisão automática ainda existem, mas não executam uma operação.

Em versões anteriores ao MongoDB 6.1:

Os métodos mongo sh.enableBalancing(namespace) e sh.disableBalancing(namespace) não afetam a divisão automática.

sh.status.balancer.currently-enabled

currently-enabled indicates if the balancer is currently enabled on the sharded cluster.

sh.status.balancer.currently-running

currently-running indicates whether the balancer is currently running, and therefore currently balancing the cluster.

sh.status.balancer.collections-with-active-migrations

collections-with-active-migrations lists the names of any collections with active migrations, and specifies when the migration began. If there are no active migrations, this field will not appear in the sh.status() output.

sh.status.balancer.failed-balancer-rounds-in-last-5-attempts

failed-balancer-rounds-in-last-5-attempts displays the number of balancer rounds that failed, from among the last five attempted rounds. A balancer round will fail when a chunk migration fails.

sh.status.balancer.last-reported-error

last-reported-error lists the most recent balancer error message. If there have been no errors, this field will not appear in the sh.status() output.

sh.status.balancer.time-of-reported-error

time-of-reported-error fornece a data e a hora do erro relatado mais recentemente.

sh.status.balancer.migration-results-for-the-last-24-hours

migration-results-for-the-last-24-hours displays the number of migrations in the last 24 hours, and the error messages from failed migrations . If there have been no recent migrations, migration-results-for-the-last-24-hours displays No recent migrations.

migration-results-for-the-last-24-hours includes all migrations, including those not initiated by the balancer.

sh.status.databases._id

The _id displays the name of the database.

sh.status.databases.partitioned

A partir do MongoDB 6.0 e da versão de compatibilidade do recurso 6.0, o sinalizador partitioned mantém apenas a compatibilidade retroativa com as versões anteriores. Por padrão, todos os bancos de dados estão habilitados para fragmentação, independentemente do valor partitioned.

sh.status.databases.primary

The primary displays the primary shard for the database.

sh.status.databases.version

The version displays the version information for the database:

{ "uuid" : UUID("cc250b66-8638-49f7-a2e8-c6f1220b9d7a"), "lastMod" : 1 }

onde:

  • uuid é o identificador do banco de dados.

  • lastMod é a versão do banco de dados.

sh.status.databases.<collection>.shard-key

The shard-key displays the shard key specification document.

sh.status.databases.<collection>.unique

The unique displays whether MongoDB enforces uniqueness on the shard key values (i.e. whether the underlying shard key index is unique).

sh.status.databases.<collection>.balancing

Exibe se o balanceador pode equilibrar a coleta. Se o balanceador estiver habilitado e esse status retornar true, o balanceador incluirá essa coleção nas operações de balanceamento. Se o status retornar false, isso indica que o balanceador não está balanceando dados nesta coleção.

sh.status.databases.<collection>.allowMigrations

Exibe se as migrações são permitidas para a coleção. Quando true, a coleção permite migrações. Quando false, a coleção não permite migrações, impedindo migrações de partes para essa coleção. Use sh.enableMigrations() e sh.disableMigrations() para controlar esta configuração.

sh.status.databases.<collection>.chunks

The chunks lists all the shards and the number of chunks that reside on each shard.

sh.status.databases.<collection>.chunk-details

The chunk-details lists the details of the chunks [1]:

  • O faixa de valores da chave de shard que definem o chunk,

  • O shard onde o chunk reside e

  • O último carimbo de data/hora modificado para o chunk.

sh.status.databases.<collection>.tag

The tag lists the details of the tags associated with a range of shard key values.

sh.status.shardedDataDistribution

Um array de documentos que fornece métricas de distribuição de dados para cada coleção fragmentada no cluster. Os dados são os mesmos que a saída do estágio de agregação do $shardedDataDistribution.

sh.status.shardedDataDistribution.ns

O namespace da coleção fragmentada no formato <database>.<collection>.

sh.status.shardedDataDistribution.shards

Um array de documentos que relata métricas de distribuição de dados para cada fragmento.

sh.status.shardedDataDistribution.shards.shardName

O nome do shard.

sh.status.shardedDataDistribution.shards.numOrphanedDocs

O número de documentos órfãos no fragmento.

sh.status.shardedDataDistribution.shards.numOwnedDocuments

O número de documentos de propriedade do fragmento.

sh.status.shardedDataDistribution.shards.ownedSizeBytes

O tamanho estimado em bytes de documentos de propriedade do fragmento quando os documentos são descompactados.

sh.status.shardedDataDistribution.shards.orphanedSizeBytes

O tamanho estimado em bytes de documentos órfãos no fragmento quando os documentos são descompactados.

[1](1, 2) The sharded collection section, by default, displays the chunk information if the total number of chunks is less than 20. To display the information when you have 20 or more chunks, call the sh.status() methods with the verbose parameter set to true, i.e. sh.status(true).