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

shardingState (comando de banco de dados)

shardingState

shardingState is an admin command that reports if mongod is a member of a sharded cluster. To run the command, you must run against the admin database. See db.adminCommand().

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

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

Observação

This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, 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

O comando tem a seguinte sintaxe:

db.adminCommand(
{
shardingState: 1
}
)

For shardingState to detect that a mongod is a member of a sharded cluster, the mongod must satisfy the following conditions:

  1. o mongod é um membro principal de um conjunto de réplicas e

  2. a instância mongod é um nó de um cluster fragmentado.

If shardingState detects that a mongod is a member of a sharded cluster, shardingState returns a document that resembles the following prototype:

{
"enabled" : true,
"configServer" : "<configdb-string>",
"shardName" : "<string>",
"shardHost" : "string:",
"versions" : {
"<database>.<collection>" : {
"placementVersion": Timestamp({ t: 1, i: 1024 }),
"timestamp": Timestamp({ t: 1682444810, i: 8 })
},
"<database>.<collection>" : {
"placementVersion": Timestamp({ t: 0, i: 0 }),
"timestamp": Timestamp({ t: 0, i: 0 })
}
},
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp({ t: 1682457265, i: 1 }),
"signature" : {
"hash" : BinData(0,"B2ViX7XLzFLS5Fl9XEuFXbwKIM4="),
"keyId" : Long("6488045157173166092")
}
},
"operationTime" : Timestamp({ t: 1682457260, i: 1 })
}

Otherwise, shardingState will return the following document:

{
"enabled" : false,
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp({t:1510716515, i: 1}),
"signature" : {
"hash" : BinData(0,"B2ViX7XLzFLS5Fl9XEuFXbwKIM4="),
"keyId" : Long("6488045157173166092")
}
},
"operationTime" : Timestamp({t: 1510716515, i: 1})
}

The response from shardingState when used with a config server is:

{
"enabled" : false,
"ok" : 1,
"operationTime" : Timestamp({t: 1510767613, i: 1}),
"$gleStats" : {
"lastOpTime" : Timestamp({t: 0, i: 0}),
"electionId" : ObjectId("7fffffff0000000000000001")
},
"$clusterTime" : {
"clusterTime" : Timestamp({t: 1510767613, i: 1}),
"signature" : {
"hash" : BinData(0,"IwBZ4SZjIMI5NdM62NObV/R31GM="),
"keyId" : Long("6488693018630029321")
}
}
}

Observação

mongos instances do not provide the shardingState.

Aviso

Esse comando obtém um bloqueio de escrita no reconhecimento de data center afetado e bloqueará outras operações até que seja concluído; no entanto, a operação normalmente é de curta duração.

Avalie esta página