Docs Menu

$shardedDataDistribution (์ง‘๊ณ„)

$shardedDataDistribution

๋ฒ„์ „ 6.0.3์— ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

์ƒค๋“œ ์ปฌ๋ ‰์…˜์˜ ๋ฐ์ดํ„ฐ ๋ถ„ํฌ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

์ฐธ๊ณ 

์ด ์ง‘๊ณ„ ๋‹จ๊ณ„๋Š” mongos์—์„œ๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด ์ง‘๊ณ„ ๋‹จ๊ณ„๋Š” admin ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์—์„œ ์‹คํ–‰ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž์—๊ฒŒ shardedDataDistribution ๊ถŒํ•œ ์กฐ์น˜๊ฐ€ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

shardedDataDistribution ๋‹จ๊ณ„์—๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ตฌ๋ฌธ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

db.aggregate( [
{ $shardedDataDistribution: { } }
] )

$shardedDataDistribution ๋‹จ๊ณ„๋Š” ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์˜ ๊ฐ ์ƒค๋”ฉ๋œ ์ปฌ๋ ‰์…˜ ์— ๋Œ€ํ•œ ๋ฌธ์„œ ๋ฐฐ์—ด ์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋ฌธ์„œ์—๋Š” ๋‹ค์Œ ํ•„๋“œ๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

ํ•„๋“œ ์ด๋ฆ„
๋ฐ์ดํ„ฐ ์œ ํ˜•
์„ค๋ช…

ns

๋ฌธ์ž์—ด

์ƒค๋“œ๋œ ์ปฌ๋ ‰์…˜์˜ ๋„ค์ž„์ŠคํŽ˜์ด์Šค์ž…๋‹ˆ๋‹ค.

shards

๋ฐฐ์—ด

์ปฌ๋ ‰์…˜์˜ ์ƒค๋“œ์™€ ๊ฐ ์ƒค๋“œ์— ๋Œ€ํ•œ ๋ฐ์ดํ„ฐ ๋ฐฐํฌ ์ •๋ณด์ž…๋‹ˆ๋‹ค.

shards.numOrphanedDocs

integer

์ƒค๋“œ ๋‚ด ๊ณ ์•„ ๋ฌธ์„œ ์ˆ˜์ž…๋‹ˆ๋‹ค.

shards.numOwnedDocuments

integer

์ƒค๋“œ๊ฐ€ ์†Œ์œ ํ•œ ๋ฌธ์„œ ์ˆ˜์ž…๋‹ˆ๋‹ค.

shards.ownedSizeBytes

integer

์••์ถ• ํ•ด์ œ ์‹œ ์ƒค๋“œ ๊ฐ€ ์†Œ์œ ํ•œ ๋ฌธ์„œ์˜ ํฌ๊ธฐ(๋‹จ์œ„: ๋ฐ”์ดํŠธ)์ž…๋‹ˆ๋‹ค.

shards.orphanedSizeBytes

integer

์••์ถ•์„ ํ•˜์ง€ ์•Š์•˜์„ ๋•Œ ์ƒค๋“œ ์— ์žˆ๋Š” ๊ณ ์•„ ๋ฌธ์„œ์˜ ํฌ๊ธฐ(๋‹จ์œ„: ๋ฐ”์ดํŠธ)์ž…๋‹ˆ๋‹ค.

Wired Tiger ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„ ์„ ์‚ฌ์šฉํ•˜์—ฌ mongod ๋ฅผ ๋น„์ •์ƒ์ ์œผ๋กœ ์ข…๋ฃŒํ•œ ํ›„ ์—์„œ ๋ณด๊ณ ํ•œ ํฌ๊ธฐ ๋ฐ ๊ฐœ์ˆ˜ ํ†ต๊ณ„๊ฐ€ $shardedDataDistribution ๋ถ€์ •ํ™•ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํŽธ์ฐจ์˜ ์ •๋„๋Š” ๋งˆ์ง€๋ง‰ ์ฒดํฌํฌ์ธํŠธ์™€ ๋น„์ •์ƒ ์ข…๋ฃŒ ์‚ฌ์ด์— ์ˆ˜ํ–‰๋œ ์‚ฝ์ž…, ์—…๋ฐ์ดํŠธ ๋˜๋Š” ์‚ญ์ œ ์ž‘์—…์˜ ์ˆ˜์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์ง‘๋‹ˆ๋‹ค. ์ฒดํฌํฌ์ธํŠธ๋Š” ๋ณดํ†ต 60์ดˆ๋งˆ๋‹ค ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜mongod ๊ธฐ๋ณธ๊ฐ’์ด ์•„๋‹Œ --syncdelay ์„ค์ •์œผ๋กœ ์‹คํ–‰๋˜๋Š” ์ธ์Šคํ„ด์Šค๋Š” ์ฒดํฌํฌ์ธํŠธ๊ฐ€ ๋‹ค์†Œ ๋นˆ๋ฒˆํ•˜๊ฒŒ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

mongod์˜ ๊ฐ ์ปฌ๋ ‰์…˜์—์„œ validate๋ฅผ ์‹คํ–‰ํ•˜์—ฌ ๋น„์ •์ƒ ์ข…๋ฃŒ ํ›„ ํ†ต๊ณ„๋ฅผ ๋ณต์›ํ•ฉ๋‹ˆ๋‹ค.

๋น„์ •์ƒ ์ข…๋ฃŒ ํ›„

์ƒค๋”ฉ๋œ ๋ฐ์ดํ„ฐ ๋ฐฐํฌ ์ง€ํ‘œ๋ฅผ ๋ชจ๋‘ ๋ฐ˜ํ™˜ํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

db.aggregate([
{ $shardedDataDistribution: { } }
])

์ถœ๋ ฅ ์˜ˆ์‹œ:

[
{
"ns": "test.names",
"shards": [
{
"shardName": "shard-1",
"numOrphanedDocs": 0,
"numOwnedDocuments": 6,
"ownedSizeBytes": 366,
"orphanedSizeBytes": 0
},
{
"shardName": "shard-2",
"numOrphanedDocs": 0,
"numOwnedDocuments": 6,
"ownedSizeBytes": 366,
"orphanedSizeBytes": 0
}
]
}
]

ํŠน์ • ์ƒค๋“œ์— ๋Œ€ํ•ด ์ƒค๋”ฉ๋œ ๋ฐ์ดํ„ฐ ๋ถ„ํฌ ์ง€ํ‘œ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

db.aggregate([
{ $shardedDataDistribution: { } },
{ $match: { "shards.shardName": "<name of the shard>" } }
])

๋„ค์ž„์ŠคํŽ˜์ด์Šค์— ๋Œ€ํ•œ ์ƒค๋”ฉ๋œ ๋ฐ์ดํ„ฐ ๋ถ„ํฌ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

db.aggregate([
{ $shardedDataDistribution: { } },
{ $match: { "ns": "<database>.<collection>" } }
])

MongoDB 6.0.3๋ถ€ํ„ฐ $shardedDataDistribution ๋‹จ๊ณ„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ง‘๊ณ„๋ฅผ ์‹คํ–‰ํ•˜ํ•ด ๊ณ ์•„ ๋ฌธ์„œ๊ฐ€ ๋‚จ์•„ ์žˆ์ง€ ์•Š์€์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

db.aggregate([
{ $shardedDataDistribution: { } },
{ $match: { "ns": "<database>.<collection>" } }
])

$shardedDataDistribution ์˜ ์ถœ๋ ฅ์€ ๋‹ค์Œ๊ณผ ์œ ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

[
{
"ns": "test.names",
"shards": [
{
"shardName": "shard-1",
"numOrphanedDocs": 0,
"numOwnedDocuments": 6,
"ownedSizeBytes": 366,
"orphanedSizeBytes": 0
},
{
"shardName": "shard-2",
"numOrphanedDocs": 0,
"numOwnedDocuments": 6,
"ownedSizeBytes": 366,
"orphanedSizeBytes": 0
}
]
}
]

ํด๋Ÿฌ์Šคํ„ฐ์˜ ๊ฐ ์ƒค๋“œ์— ๋Œ€ํ•ด "numOrphanedDocs" ๊ฐ€ 0 ์ธ์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.