AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

sh.status()(mongoshメソッド)

sh.status()

mongos インスタンス上で実行すると、シャーディング構成のフォーマットされたレポートと、シャーディングされたクラスター内の既存のチャンクに関する情報が出力されます。デフォルトの動作では、チャンクの合計数が 20 以上の場合、チャンクの詳細情報は表示されません。

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

Parameter
タイプ
説明

verbose

ブール値

任意。冗長レベルを決定します。

true の場合、メソッドは次のように表示されます。

false の場合、メソッドは次のように表示されます。

  • チャンクが 20 個未満の場合にのみ、シャード間のチャンク分散の完全な詳細チャンクが 20 個以上ある場合、このメソッドは代わりに too many chunks to print ... メッセージを返し、各シャード上のチャンク数のみを表示します。

デフォルトの冗長の値は false です。

出力には、各シャーディングされたコレクションのデータ分布のメトリクスを提供する shardedDataDistribution セクションも含まれています。このデータは、$shardedDataDistribution集計ステージの出力と同じです。

このメソッドは、次の環境でホストされている配置で使用できます。

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

重要

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

  • MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

  • MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン

The Sharding Version section displays information on the config database:

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

[シャード] セクションには、シャードに関する情報が表示されます。また、各シャードについて、名前、ホスト、および関連付けられているタグ(存在する場合)が表示されます。

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> }

[自動分割 ]には、自動分割が有効になっているかどうかに関する情報が表示されます。

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

[データベース] セクションには、データベースに関する情報が表示されます。 各データベースのデータベース名とプライマリ シャードが表示されます。

databases:
{ "_id" : <dbname1>, "primary" : <string>, "version": <document> }
{ "_id" : <dbname2>, "primary" : <string>, "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.

MongoDB 6.2 より前のバージョンでは、このフィールドは config.version コレクションに含まれていますが、mongosh 2.0.0 以降では、このフィールドは sh.status() 出力には返されません。MongoDB 6.2 以降では、このフィールドは削除され、mongosh バージョンまたはその他のクライアント アプリケーションでは返されません。 代わりに、バージョン情報を取得するには、「機能の互換性バージョン(fcv)」を参照してください。

sh.status.sharding-version.currentVersion

The currentVersion is the current version of the config server.

MongoDB 6.2 より前のバージョンでは、このフィールドは config.version コレクションに含まれていますが、mongosh 2.0.0 以降では、このフィールドは sh.status() 出力には返されません。MongoDB 6.2 以降では、このフィールドは削除され、mongosh バージョンまたはその他のクライアント アプリケーションでは返されません。 代わりに、バージョン情報を取得するには、「機能の互換性バージョン(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:

フィールド
データ型
説明

_id

文字列

mongosが実行されているホスト名とポート。_idは<hostname>:<port>としてフォーマットされます。

advisoryHostFQDNs

文字列の配列

mongosの完全修飾ドメイン名(FQDN) の配列。

created

日付

mongosが開始されたとき。

バージョン5.2の新機能。

mongoVersion

文字列

mongosが実行している MongoDB のバージョン。

ping

日付

mongosインスタンスが 30 秒ごとに構成サーバーに ping を送信します。このフィールドは、最後の ping 時間を示します。

up

NumberLong

最後の ping の時点で mongos が起動していた秒数。

waiting

ブール値

このフィールドは常に true であり、下位互換性のためだけに含まれています。

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

sh.status.autosplit 自動分割が現在有効になっているかどうかを示します。

注意

MongoDB 6.0.3以降、 自動チャンク分割は実行されません。 これはバランシング ポリシーの改善によるものです。 自動分割コマンドは引き続き存在しますが、操作は実行されません。

MongoDB 6.1 より前のバージョンの場合:

mongo メソッドである sh.enableBalancing(namespace) および sh.disableBalancing(namespace) は自動分割には影響しません。

sh.status.automerge

AutoMerger が有効かどうかを示します。

注意

automergeセクションは、AutoMerger を明示的に有効化または無効化した場合にのみ表示されます。デフォルトでは、AutoMerger は有効になっています。

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 シャードがシャード認識されていない場合。

  • 1 シャードがシャード認識されている場合。

注意

MongoDB 6.0.3以降、 自動チャンク分割は実行されません。 これはバランシング ポリシーの改善によるものです。 自動分割コマンドは引き続き存在しますが、操作は実行されません。

MongoDB 6.1 より前のバージョンの場合:

mongo メソッドである sh.enableBalancing(namespace) および sh.disableBalancing(namespace) は自動分割には影響しません。

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 は、直近に報告されたエラーの日時を提供します。

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.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 }

以下の条件に一致するもの。

  • uuid が、データベース識別子です。

  • lastMod はデータベースのバージョンです。

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

バランサーがコレクションのバランスをとれるかどうかを表示。 バランサーが有効になっており、このステータスがtrueを返す場合、バランサーはバランサー操作にこのコレクションを含めます。 ステータスがfalseを返す場合、バランサーがこのコレクション内のデータをバランス調整していないことを示します。

sh.status.databases.<collection>.allowMigrations

コレクションの移行が許可されているかどうかを表示します。true の場合、コレクションは移行を許可します。false の場合、コレクションは移行を許可せず、このコレクションのチャンク移行ができません。この設定を制御するには、sh.enableMigrations()とsh.disableMigrations()を使用します。

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]:

  • チャンクを定義するシャードキー値の範囲、

  • チャンクが存在するシャード、および

  • チャンクの最終変更タイムスタンプ。

sh.status.databases.<collection>.tag

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

sh.status.shardedDataDistribution

クラスター内の各シャーディングされたコレクションのデータ分散メトリクスを提供するドキュメントの配列。データは $shardedDataDistribution 集計ステージの出力と同じです。

sh.status.shardedDataDistribution.ns

<database>.<collection>形式のシャーディングされたコレクションの名前空間。

sh.status.shardedDataDistribution.shards

各シャードのデータ分散メトリクスを報告するドキュメントの配列。

sh.status.shardedDataDistribution.shards.shardName

シャードの名前。

sh.status.shardedDataDistribution.shards.numOrphanedDocs

シャード内の 孤立したドキュメント の数。

sh.status.shardedDataDistribution.shards.numOwnedDocuments

シャードが所有するドキュメントの数。

sh.status.shardedDataDistribution.shards.ownedSizeBytes

ドキュメントが非圧縮の場合にシャードによって所有されるドキュメントの推定サイズ(バイト単位)。

sh.status.shardedDataDistribution.shards.orphanedSizeBytes

ドキュメントが非圧縮の場合にシャード内の 孤立したドキュメント の推定サイズ(バイト単位)。

[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).