AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

dbHash (데이터베이스 명령)

dbHash

Returns the hash values of the collections in a database and an MD5 value for these collections. dbHash is useful to compare databases across mongod instances, such as across members of replica sets.

경고

The dbHash command obtains a shared (S) lock on the database, which prevents writes until the command completes.

이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.

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

명령은 다음과 같은 구문을 가집니다:

db.runCommand(
{
dbHash: 1,
collections: [ <collection1>, ... ],
maxTimeMS: <integer>
}
)

이 명령은 다음 필드를 사용합니다.

필드
유형
설명

dbHash

모든 유형

실행할 명령입니다. 값을 지정합니다.

collections

배열

선택 사항입니다. 현재 데이터베이스에 있는 컬렉션 이름의 배열입니다. 각 컬렉션을 이름으로만 지정하세요. test.orders과 같이 데이터베이스로 이름을 한정하지 마세요.

데이터베이스의 모든 컬렉션에 대한 해시 값을 반환하려면 빈 배열을 지정하십시오.

maxTimeMS

non-negative integer

선택 사항.

시간 제한을 밀리초 단위로 지정합니다. maxTimeMS에 값을 지정하지 않으면 작업이 시간 초과되지 않습니다. 0 값은 바인딩되지 않는 기본 동작을 명시적으로 지정합니다.

MongoDB는 db.killOp()와 동일한 메커니즘을 사용하여 할당된 시간 제한을 초과하는 작업을 종료합니다. MongoDB는 지정된 중단 지점 중 하나에서만 작업을 종료합니다.

If a collection in the collections array is non-existent, dbHash does not return a hash value for that collection. A database-qualified name such as test.orders never matches, because dbHash compares each entry against the collection names in the current database.

collections 배열의 이름이 컬렉션과 일치하지 않거나 컬렉션이 존재하지만 비어 있는 경우, dbHash은(는) 빈 입력의 md5 값인 d41d8cd98f00b204e9800998ecf8427e을(를) 반환합니다.

참고

dbhash의 출력은 존재하지 않는 컬렉션과 빈 컬렉션을 구분하지 않습니다.

배포서버 간에 md5 값을 비교하기 전에 반환 문서의 collections 필드에 예상하는 각 컬렉션이 나열되어 있는지 확인하세요.

The dbHash command no longer support afterClusterTime. As such, dbHash cannot be associated with causally consistent sessions.

이 명령은 다음 필드가 있는 문서를 반환합니다.

필드
설명

호스트

명령이 실행되는 mongod 인스턴스의 호스트와 포트입니다.

collections

컬렉션과 해당 해시 값이 있는 문서입니다.

{
<collection1>: <hash1>,
<collection2>: <hash2>,
...
}

capped

고정 사이즈 컬렉션을 나열하는 배열입니다.

uuids

컬렉션과 해당 UUID 값이 있는 문서입니다.

{
<collection1>: <UUID1>,
<collection2>: <UUID2>,
...
}

md5

이러한 컬렉션에 대한 집계 해시 값입니다.

timeMillis

해시를 생성하는 데 걸리는 시간(밀리초)입니다.

ok
operationTime
$clusterTime

모든 명령과 함께 반환됩니다. 자세한 내용은 응답을 참조하세요.

다음 예에서는 데이터베이스 test의 모든 컬렉션에 대한 해시 값을 반환합니다:

use test
db.runCommand( { dbHash: 1 } )

연산은 다음 문서를 반환합니다.

{
"host" : "myHostName.local:27017",
"collections" : {
"foo" : "d27b769230edc551d869060ec3fb68bd",
"inventory" : "ec3d821581ea1bd3aa8196c94b946874",
"log" : "d41d8cd98f00b204e9800998ecf8427e",
"orders" : "0242c0a128c284ea9576a34db2306c12",
"restaurants" : "5dc9b88091c36f0d529567b5b6e3fc92",
"zipcodes" : "31ede812bf397509a87359c65bf2a08c"
},
"capped" : [
"log"
],
"uuids" : {
"foo" : UUID("469592fe-3bfe-425e-975f-cedbe0c4741d"),
"inventory" : UUID("0830e0ad-cc24-4fc7-80d0-8e22fe45e382"),
"log" : UUID("4be024ff-711b-4ab8-836b-dee662e090f1"),
"orders" : UUID("755be489-745f-400c-ac3b-f27525ad0108"),
"restaurants" : UUID("520b56ec-3276-4904-b6e5-286bc9bfa648"),
"zipcodes" : UUID("12e97b70-c174-40af-a178-5d83a241fe20")
},
"md5" : "0cb7417ae9d9eb865000b4debdc671da",
"timeMillis" : 53,
"ok" : 1,
"operationTime" : Timestamp(1529208582, 4),
"$clusterTime" : {
"clusterTime" : Timestamp(1529208582, 4),
"signature" : {
"hash" : BinData(0,"X3MmevDqUgCVvN1AhnT+fiOL/Lc="),
"keyId" : Long("6567898567824900097")
}
}
}

다음 예시에서는 데이터베이스 test의 collection inventory 및 orders에 대한 해시 값을 반환합니다.

use test
db.runCommand( { dbHash: 1, collections: [ "inventory", "orders" ] } )

연산은 다음 문서를 반환합니다.

{
"host" : "myHostName.local:27017",
"collections" : {
"inventory" : "ec3d821581ea1bd3aa8196c94b946874",
"orders" : "0242c0a128c284ea9576a34db2306c12"
},
"capped" : [ ],
"uuids" : {
"inventory" : UUID("0830e0ad-cc24-4fc7-80d0-8e22fe45e382"),
"orders" : UUID("755be489-745f-400c-ac3b-f27525ad0108")
},
"md5" : "cb4676f316ff2ff29c701a5edd18afe3",
"timeMillis" : 0,
"ok" : 1,
"operationTime" : Timestamp(1529208801, 1),
"$clusterTime" : {
"clusterTime" : Timestamp(1529208801, 1),
"signature" : {
"hash" : BinData(0,"I4z4a4Mgs+tcx0MP5xIU8DYAMB0="),
"keyId" : Long("6567898567824900097")
}
}
}