정의
dbHashReturns the hash values of the collections in a database and an MD5 value for these collections.
dbHashis useful to compare databases acrossmongodinstances, 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.
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
구문
명령은 다음과 같은 구문을 가집니다:
db.runCommand( { dbHash: 1, collections: [ <collection1>, ... ], maxTimeMS: <integer> } )
명령 필드
이 명령은 다음 필드를 사용합니다.
필드 | 유형 | 설명 |
|---|---|---|
| 모든 유형 | 실행할 명령입니다. 값을 지정합니다. |
| 배열 | 선택 사항입니다. 현재 데이터베이스에 있는 컬렉션 이름의 배열입니다. 각 컬렉션을 이름으로만 지정하세요. 데이터베이스의 모든 컬렉션에 대한 해시 값을 반환하려면 빈 배열을 지정하십시오. |
| non-negative integer | 선택 사항. 시간 제한을 밀리초 단위로 지정합니다. 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.
returnDocument
이 명령은 다음 필드가 있는 문서를 반환합니다.
필드 | 설명 | |||||
|---|---|---|---|---|---|---|
호스트 | 명령이 실행되는 | |||||
| 컬렉션과 해당 해시 값이 있는 문서입니다. | |||||
| 고정 사이즈 컬렉션을 나열하는 배열입니다. | |||||
| 컬렉션과 해당 UUID 값이 있는 문서입니다. | |||||
| 이러한 컬렉션에 대한 집계 해시 값입니다. | |||||
| 해시를 생성하는 데 걸리는 시간(밀리초)입니다. | |||||
| 모든 명령과 함께 반환됩니다. 자세한 내용은 응답을 참조하세요. |
예시
데이터베이스의 모든 컬렉션에 대한 해시값 반환
다음 예에서는 데이터베이스 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") } } }
데이터베이스의 지정된 collection에 대한 해시 값 반환
다음 예시에서는 데이터베이스 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") } } }