定義
sh.status()mongosインスタンス上で実行すると、シャーディング構成のフォーマットされたレポートと、シャーディングされたクラスター内の既存のチャンクに関する情報が出力されます。デフォルトの動作では、チャンクの合計数が 20 以上の場合、チャンクの詳細情報は表示されません。The
sh.status()method has the following parameter:Parameterタイプ説明verboseブール値
任意。冗長レベルを決定します。
trueの場合、メソッドは次のように表示されます。チャンクが 20 個以上ある場合も含めた、シャード間のチャンク分散の完全な詳細および各シャード上のチャンク数。
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._idThe
_idis an identifier for the version details.
sh.status.sharding-version.minCompatibleVersionThe
minCompatibleVersionis the minimum compatible version of the config server.MongoDB 6.2 より前のバージョンでは、このフィールドは
config.versionコレクションに含まれていますが、mongosh2.0.0 以降では、このフィールドはsh.status()出力には返されません。MongoDB 6.2 以降では、このフィールドは削除され、mongoshバージョンまたはその他のクライアント アプリケーションでは返されません。 代わりに、バージョン情報を取得するには、「機能の互換性バージョン(fcv)」を参照してください。
sh.status.sharding-version.currentVersionThe
currentVersionis the current version of the config server.MongoDB 6.2 より前のバージョンでは、このフィールドは
config.versionコレクションに含まれていますが、mongosh2.0.0 以降では、このフィールドはsh.status()出力には返されません。MongoDB 6.2 以降では、このフィールドは削除され、mongoshバージョンまたはその他のクライアント アプリケーションでは返されません。 代わりに、バージョン情報を取得するには、「機能の互換性バージョン(fcv)」を参照してください。
sh.status.sharding-version.clusterIdThe
clusterIdis the identification for the sharded cluster.
アクティブな mongos インスタンス
sh.status.active-mongosesIf
verboseisfalse,sh.status.active-mongoseslists the version and count of the activemongosinstances. Activemongosinstances aremongosinstances that have been pinged within the last 60 seconds.If
verboseistrue,sh.status.active-mongosesreturns a document for each activemongosinstance containing the following fields:フィールドデータ型説明_id文字列
mongosが実行されているホスト名とポート。_idは<hostname>:<port>としてフォーマットされます。advisoryHostFQDNs文字列の配列
mongosの完全修飾ドメイン名(FQDN) の配列。created日付
mongosが開始されたとき。バージョン5.2の新機能。
mongoVersion文字列
mongosが実行している MongoDB のバージョン。ping日付
upNumberLong
最後の ping の時点で
mongosが起動していた秒数。waitingブール値
このフィールドは常に
trueであり、下位互換性のためだけに含まれています。active mongoses: { "_id" : "<hostname:port>", "advisoryHostFQDNs" : [ "<name>" ], "created" : <ISODate>, "mongoVersion" : <string>, "ping" : <ISODate>, "up" : <long>, "waiting" : <boolean> } ...
Autosplit
sh.status.autosplitsh.status.autosplit自動分割が現在有効になっているかどうかを示します。
注意
MongoDB 6.0.3以降、 自動チャンク分割は実行されません。 これはバランシング ポリシーの改善によるものです。 自動分割コマンドは引き続き存在しますが、操作は実行されません。
MongoDB 6.1 より前のバージョンの場合:
balancerStartコマンドおよびmongoシェルヘルパー メソッドであるsh.startBalancer()とsh.setBalancerState(true)も、シャーディングされたクラスターの自動分割を有効にします。バランサーが有効になっているときに自動分割を無効にするには、
sh.disableAutoSplit()を使用できます。balancerStopコマンドおよびmongoシェルヘルパー メソッドであるsh.stopBalancer()とsh.setBalancerState(false)も、シャーディングされたクラスターの自動分割を無効にします。バランサーが無効になっているときに自動分割を有効にするには、
sh.enableAutoSplit()を使用できます。
mongo メソッドである sh.enableBalancing(namespace) および sh.disableBalancing(namespace) は自動分割には影響しません。
オートマージ
sh.status.automergeAutoMerger が有効かどうかを示します。
注意
automergeセクションは、AutoMerger を明示的に有効化または無効化した場合にのみ表示されます。デフォルトでは、AutoMerger は有効になっています。
シャード
sh.status.shards._idThe
_iddisplays the name of the shard.
sh.status.shards.hostThe
hostdisplays the host location of the shard.
sh.status.shards.tagsThe
tagsdisplays all the tags for the shard. The field only displays if the shard has tags.
sh.status.shards.stateThe
statedisplays:0シャードがシャード認識されていない場合。1シャードがシャード認識されている場合。
バランサー
注意
MongoDB 6.0.3以降、 自動チャンク分割は実行されません。 これはバランシング ポリシーの改善によるものです。 自動分割コマンドは引き続き存在しますが、操作は実行されません。
MongoDB 6.1 より前のバージョンの場合:
balancerStartコマンドおよびmongoシェルヘルパー メソッドであるsh.startBalancer()とsh.setBalancerState(true)も、シャーディングされたクラスターの自動分割を有効にします。バランサーが有効になっているときに自動分割を無効にするには、
sh.disableAutoSplit()を使用できます。balancerStopコマンドおよびmongoシェルヘルパー メソッドであるsh.stopBalancer()とsh.setBalancerState(false)も、シャーディングされたクラスターの自動分割を無効にします。バランサーが無効になっているときに自動分割を有効にするには、
sh.enableAutoSplit()を使用できます。
mongo メソッドである sh.enableBalancing(namespace) および sh.disableBalancing(namespace) は自動分割には影響しません。
sh.status.balancer.currently-enabledcurrently-enabledindicates if the balancer is currently enabled on the sharded cluster.
sh.status.balancer.currently-runningcurrently-runningindicates whether the balancer is currently running, and therefore currently balancing the cluster.
sh.status.balancer.collections-with-active-migrationscollections-with-active-migrationslists 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 thesh.status()output.
sh.status.balancer.failed-balancer-rounds-in-last-5-attemptsfailed-balancer-rounds-in-last-5-attemptsdisplays 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-errorlast-reported-errorlists the most recent balancer error message. If there have been no errors, this field will not appear in thesh.status()output.
sh.status.balancer.time-of-reported-errortime-of-reported-errorは、直近に報告されたエラーの日時を提供します。
sh.status.balancer.migration-results-for-the-last-24-hoursmigration-results-for-the-last-24-hoursdisplays 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-hoursdisplaysNo recent migrations.migration-results-for-the-last-24-hoursincludes all migrations, including those not initiated by the balancer.
Databases
sh.status.databases._idThe
_iddisplays the name of the database.
sh.status.databases.primaryThe
primarydisplays the primary shard for the database.
sh.status.databases.versionThe
versiondisplays the version information for the database:{ "uuid" : UUID("cc250b66-8638-49f7-a2e8-c6f1220b9d7a"), "lastMod" : 1 } 以下の条件に一致するもの。
uuidが、データベース識別子です。lastModはデータベースのバージョンです。
シャーディングされたコレクション
sh.status.databases.<collection>.shard-keyThe
shard-keydisplays the shard key specification document.
sh.status.databases.<collection>.uniqueThe
uniquedisplays 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>.chunksThe
chunkslists all the shards and the number of chunks that reside on each shard.
sh.status.databases.<collection>.chunk-detailsThe
chunk-detailslists the details of the chunks [1]:チャンクを定義するシャードキー値の範囲、
チャンクが存在するシャード、および
チャンクの最終変更タイムスタンプ。
sh.status.databases.<collection>.tagThe
taglists the details of the tags associated with a range of shard key values.
シャーディングされたデータ分散
sh.status.shardedDataDistributionクラスター内の各シャーディングされたコレクションのデータ分散メトリクスを提供するドキュメントの配列。データは
$shardedDataDistribution集計ステージの出力と同じです。
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). |