config データベースのコレクションは以下をサポートします。
スタンドアロン、レプリカセット、シャーディングされたクラスターの場合は不特定にコンシステント セッションと、レプリカセットとシャーディングされたクラスターの場合は再試行可能な書き込み。
注意
シャーディングされたクラスターは、mongos に接続するか mongod に接続するかに応じて、config データベースに異なるコレクションを表示する場合があります。
On
mongos, theconfigdatabase shows collections located on the config servers, such ascollectionsorchunks.On
mongod, theconfigdatabase shows collections specific to the given shard, such asmigrationCoordinatorsorrangeDeletions.
コンフィギュレーションサーバーとシャードが同じノードでホストされている場合、mongos は、config データベース内の一部のシャード ローカル コレクションにアクセスできる可能性があります。
制限事項
Starting in MongoDB 5.0, non-transaction reads are not allowed on the config.transactions collection with the following read concerns and options:
"majority"と afterClusterTime オプションが設定されているWhen using a MongoDB Driver and
"majority"within a causally consistent session
重要
config データベースのスキーマは内部的なものであり、MongoDB のリリース間で変更される可能性があります。config データベースは信頼できる API ではないため、ユーザーは通常の操作またはメンテナンス中に config データベースにデータを書き込まないでください。
注意
マルチドキュメントトランザクション内では、config データベース内のコレクションに対して読み取り/書き込み操作を実行することはできません。
MongoDB 8.0 以降では、一部の config コレクションを読み取るには mongos に接続する必要があります。これらのコレクションの一覧については、単一シャード コレクションの読み取りを参照してください。
シャーディングされたクラスター操作をサポートするコレクション
To access the config database and view the list of collections that support sharding operations, connect mongosh to a mongos instance in a sharded cluster and issue the following:
use config show collections
注意
アクセス権制御を使用して実行中の場合は、データベースに対して listCollections アクションを許可する特権があることを確認してください。
コンフィギュレーションデータベースは主に内部使用を目的として、通常の操作中はデータを手動で挿入したり保存したりしないでください。ただし、シャーディングされたクラスターのコンフィギュレーションサーバーの書き込み可否を確認する必要がある場合は、テストコレクションにドキュメントを挿入できます(その名前のコレクションがまだ存在しないことを確認した後に)。
警告
Modification of the config database on a functioning system may lead to instability or inconsistent data sets. If you must modify the config database, use mongodump to create a full backup of the config database.
db.testConfigServerWriteAvail.insertOne( { a : 1 } )
操作が成功すると、コンフィギュレーションサーバーは書き込みを処理できるようになります。
サーバーの今後のリリースでは、コンフィギュレーションデータベースにさまざまなコレクションが含まれる可能性があるため、テストコレクションの名前を選択するときは注意してください。
MongoDB は、シャーディングをサポートするために config データベース内の次のコレクションを使用します。
config.changelogTip
内部 MongoDB メタデータ
The config database is internal. Applications and administrators should not modify or depend on its content during normal operation.
The
changelogcollection stores a document for each change to the metadata of a sharded collection.例
The following example displays a single record of a chunk split from a
changelogcollection:{ "_id" : "<hostname>-<timestamp>-<increment>", "server" : "<hostname><:port>", "clientAddr" : "127.0.0.1:63381", "time" : ISODate("2012-12-11T14:09:21.039Z"), "what" : "split", "ns" : "<database>.<collection>", "details" : { "before" : { "min" : { "<database>" : { $minKey : 1 } }, "max" : { "<database>" : { $maxKey : 1 } }, "lastmod" : Timestamp(1000, 0), "lastmodEpoch" : ObjectId("000000000000000000000000") }, "left" : { "min" : { "<database>" : { $minKey : 1 } }, "max" : { "<database>" : "<value>" }, "lastmod" : Timestamp(1000, 1), "lastmodEpoch" : ObjectId(<...>) }, "right" : { "min" : { "<database>" : "<value>" }, "max" : { "<database>" : { $maxKey : 1 } }, "lastmod" : Timestamp(1000, 2), "lastmodEpoch" : ObjectId("<...>") }, "owningShard" : "<value>" } } Each document in the
changelogcollection contains the following fields:config.changelog.clientAddrこの変更を開始する
mongosインスタンスである、クライアントのアドレスを保持する文字列。
config.changelog.time変更が発生した日時を反映する ISODate タイムスタンプ。
config.chunksTip
内部 MongoDB メタデータ
The config database is internal. Applications and administrators should not modify or depend on its content during normal operation.
The
config.chunkscollection stores a document for each chunk in the cluster. The following example shows a document:{ _id: ObjectId('65a954c0de11596e08e7c1dc'), uuid: UUID('a4479215-a38d-478f-a82b-e5e95d455e55'), min: { a: Long('121204345') }, max: { a: Long('993849349') }, shard: 'shard01', lastmod: Timestamp({ t: 1, i: 0 }), history: [ { validAfter: Timestamp({ t: 1705596095, i: 14 }), shard: 'shard01' } ] } ドキュメント内:
_idは、チャンク識別子です。minとmaxはチャンクのシャードキーの値の範囲です。shardは、クラスターにチャンクを保存するシャードの名前です。
Tip
To find the chunks in a collection, retrieve the collection's
uuididentifier from theconfig.collectionscollection. Then, useuuidto retrieve the matching document with the sameuuidfrom theconfig.chunkscollection.
config.collectionsTip
内部 MongoDB メタデータ
The config database is internal. Applications and administrators should not modify or depend on its content during normal operation.
MongoDB 8.0 以降、
config.collectionsは、moveCollectionによって移動されたすべてのシャーディングされたコレクションとシャーディングされていないコレクションのメタデータを保存します。8.0 より前のバージョンの MongoDB では、
config.collectionsはシャーディングされたコレクションのメタデータのみを保存します。config.collectionsは、コレクションに関するメタデータのみを保存し、コレクションに保存されているドキュメントは保存しません。For a collection named
petsin therecordsdatabase, a document in thecollectionscollection would resemble the following:{ "_id" : "records.pets", "lastmod" : ISODate("2021-07-21T15:48:15.193Z"), "timestamp": Timestamp(1626882495, 1), "key" : { "a" : 1 }, "unique" : false, "lastmodEpoch" : ObjectId("5078407bd58b175c5c225fdc"), "uuid" : UUID("f8669e52-5c1b-4ea2-bbdc-a00189b341da") }
config.databasesTip
内部 MongoDB メタデータ
The config database is internal. Applications and administrators should not modify or depend on its content during normal operation.
The
databasescollection stores a document for each database in the cluster.各データベースに対応するドキュメントには、名前、データベースのプライマリシャード、およびバージョンが表示されます。
{ "_id" : "test", "primary" : "shardA", "version" : { "uuid" : UUID("516a5f79-5eb9-4844-8ee9-b8e9de91b760"), "timestamp" : Timestamp(1626894204, 1), "lastMod" : 1 } } { "_id" : "hr", "primary" : "shardA", "version" : { "uuid" : UUID("8e39d61d-6259-4c33-a5ed-bcd2ae317b6f"), "timestamp" : Timestamp(1626895015, 1), "lastMod" : 1 } } { "_id" : "reporting", "primary" : "shardB", "version" : { "uuid" : UUID("07c63242-51b3-460c-865f-a67b3372d792"), "timestamp" : Timestamp(1626895826, 1), "lastMod" : 1 } } sh.status()メソッドは、データベース セクションでこの情報を返します。
config.migrationCoordinatorsThe
migrationCoordinatorscollection exists on each shard and stores a document for each in-progress chunk migration from this shard to another shard. The chunk migration fails if the document cannot be written to a majority of the members of the shard's replica set.移行が完了すると、移行を説明するドキュメントがコレクションから削除されます。
config.mongosTip
内部 MongoDB メタデータ
The config database is internal. Applications and administrators should not modify or depend on its content during normal operation.
The
mongoscollection stores a document for eachmongosinstance affiliated with the cluster. The cluster maintains this collection for reporting purposes.Each document in the
mongoscollection contains these fields:フィールドデータ型説明_id文字列
mongosが実行されているホスト名とポート。_idは<hostname>:<port>としてフォーマットされます。advisoryHostFQDNs文字列の配列
mongosの完全修飾ドメイン名(FQDN) の配列。created日付
mongosが開始されたとき。バージョン5.2の新機能。
mongoVersion文字列
mongosが実行している MongoDB のバージョン。ping日付
upNumberLong
最後の ping の時点で
mongosが起動していた秒数。waitingブール値
このフィールドは常に
trueであり、下位互換性のためだけに含まれています。次のドキュメントは、
example.com:27017で実行されているmongosのステータスを示しています。[ { _id: 'example.com:27017', advisoryHostFQDNs: [ "example.com" ], created: ISODate("2021-11-22T16:32:13.708Z"), mongoVersion: "5.2.0", ping: ISODate("2021-12-15T22:09:23.161Z"), up: Long("2007429"), waiting: true } ]
config.placementHistoryTip
内部 MongoDB メタデータ
The config database is internal. Applications and administrators should not modify or depend on its content during normal operation.
The
placementHistorycollection exists on the config server and records which shards contained data for a database or collection at specific cluster timestamps. MongoDB uses this information to reconstruct historical data placement.For a collection named
myCollectionin thetestdatabase, a document in theplacementHistorycollection would resemble the following:{ _id: ObjectId("61e0a1f4e5b8c9d0a1b2c3d4"), nss: "test.myCollection", collUuid: UUID("07c63242-51b3-460c-865f-a67b3372d792"), timestamp: Timestamp(1626895826, 1), shards: [ "shardA", "shardB" ] } nssフィールドには、名前空間またはデータベース名いずれかを含めることができます。collUuidフィールドは、コレクションにのみ存在します。
config.rangeDeletionsThe
rangeDeletionscollection exists on each shard and stores a document for each chunk range that contains orphaned documents. The chunk migration fails if the document cannot be written to a majority of the members of the shard's replica set.孤立したチャンク範囲が完了されると、その範囲を説明するドキュメントがコレクションから削除されます。
config.settingsTip
内部 MongoDB メタデータ
The config database is internal. Applications and administrators should not modify or depend on its content during normal operation.
settingsコレクションには、次のシャーディング構成設定が保持されます。範囲サイズ。範囲サイズを変更するには、「シャーディングされたクラスターの範囲サイズの変更」を参照してください。指定された
chunksize値はメガバイト単位です。バランサー設定。バランサーのステータスを含むバランサー設定を変更するには、「シャーディングされたクラスター バランサーの管理」を参照してください。
Autosplit:
MongoDB 6.0.3以降、 自動チャンク分割は実行されません。 これはバランシング ポリシーの改善によるものです。 自動分割コマンドは引き続き存在しますが、操作は実行されません。
MongoDB 6.1 より前のバージョンの場合:
balancerStartは、シャーディングされたクラスターの自動分割も有効にします。balancerStopは、シャーディングされたクラスターの自動分割も無効にします。自動分割フラグを有効または無効にするには、対応する
sh.enableAutoSplit()メソッドまたはsh.disableAutoSplit()メソッドを使用します。
settingsコレクション内のドキュメントの例:{ "_id" : "chunksize", "value" : 64 } { "_id" : "balancer", "mode" : "full", "stopped" : false }
config.shardsTip
内部 MongoDB メタデータ
The config database is internal. Applications and administrators should not modify or depend on its content during normal operation.
The
shardscollection represents each shard in the cluster in a separate document, as in the following:{ "_id" : "shard0000", "host" : "localhost:30000", "state" : 1 } シャードがレプリカセットの場合、次の例のように
hostフィールドにはレプリカセットの名前、次にスラッシュ、次にレプリカセットの各ノードのホスト名のカンマ区切りリストが表示されます。{ "_id" : "shard0001", "host" : "shard0001/localhost:27018,localhost:27019,localhost:27020", "state" : 1 } シャードにゾーンが割り当てられている場合、このドキュメントには
tagsフィールドがあり、次の例のように、割り当てられているゾーンの配列が保持されます。{ "_id" : "shard0002", "host" : "localhost:30002", "state" : 1, "tags": [ "NYC" ] }
config.tagsTip
内部 MongoDB メタデータ
The config database is internal. Applications and administrators should not modify or depend on its content during normal operation.
The
tagscollection holds documents for each zone range in the cluster. The documents in thetagscollection resemble the following:{ "_id" : { "ns" : "records.users", "min" : { "zipcode" : "10001" } }, "ns" : "records.users", "min" : { "zipcode" : "10001" }, "max" : { "zipcode" : "10281" }, "tag" : "NYC" }
config.versionTip
内部 MongoDB メタデータ
The config database is internal. Applications and administrators should not modify or depend on its content during normal operation.
The
versioncollection holds the current metadata version number. This collection contains only one document. For example:{ "_id" : 1, "minCompatibleVersion" : 5, "currentVersion" : 6, "clusterId" : ObjectId("5d8bc01a690d8abbd2014ddd") } To access the
versioncollection, you must use thedb.getCollection()method. For example, to retrieve the collection's document:db.getCollection("version").find()
セッションをサポートするコレクション
config データベースには、スタンドアロン、レプリカセット、シャーディングされたクラスターの不特定のコンシステント セッションと、レプリカセットとシャーディングされたクラスターの再試行可能な書き込みとトランザクションをサポートするための内部コレクションが含まれています。
警告
これらのコレクションを手動で変更したり削除したりしないでください。
To access these collections for a mongod or mongos instance, connect mongosh to the instance.
config.system.sessionssystem.sessionsコレクションには、配置のすべてのノードが利用できるセッションレコードが保存されます。ユーザーが
mongodまたはmongosインスタンスでセッションを作成すると、セッションのレコードは最初はインスタンスのメモリ内にのみ存在します。インスタンスはキャッシュされたセッションをsystem.sessionsコレクションに定期的に同期します。同期されると、配置のすべてのノードにそのセッションが表示されます。system.sessionsコレクション内のレコードを表示するには、$listSessionsを使用します。警告
system.sessionsコレクションを手動で修正したり削除したりしないでください。シャーディングされたクラスターでは、
system.sessionsコレクションがシャーディングされます。シャードをシャーディングされたクラスターに追加するときに、追加するシャードにすでに独自の
system.sessionsコレクションが含まれている場合、MongoDB は追加プロセス中に新しいシャードのsystem.sessionsコレクションを削除します。
config.transactionstransactionsコレクションには、レプリカセットとシャーディングされたクラスターの再試行可能な書き込みとトランザクションをサポートするために使用されたレコードが保存されます。警告
transactionsコレクションを手動で修正したり削除したりしないでください。