클러스터 구성 보기
이 페이지의 내용
MongoDB 5.0 은(는) 2024 10월을 기준으로 수명이 종료됩니다. 이 버전의 문서는 더 이상 지원되지 않습니다. 6.0 배포서버 업그레이드 5.0 하려면 MongoDB 업그레이드 절차를 참조하세요.
샤딩이 활성화된 데이터베이스 나열
샤딩이 활성화된 데이터베이스를 나열하려면 config 데이터베이스에서
databases
컬렉션을 쿼리합니다. 데이터베이스에 샤딩이 활성화되려면 partitioned
필드의 값이 true
여야 합니다. mongosh
을 mongos
인스턴스에 연결하고 샤딩이 활성화된 데이터베이스의 전체 목록을 얻기 위해 다음 작업을 실행합니다.
use config db.databases.find( { "partitioned": true } )
예시
다음의 명령 시퀀스를 사용하여 클러스터의 모든 데이터베이스 목록을 반환할 수 있습니다.
use config db.databases.find()
다음과 같은 결과 세트가 반환되면
{ "_id" : "test", "primary" : "shardB", "partitioned" : false } { "_id" : "animals", "primary" : "shardA", "partitioned" : true } { "_id" : "farms", "primary" : "shardA", "partitioned" : false }
animals
데이터베이스에 대해서만 샤딩이 활성화됩니다.
샤드 나열
현재 구성된 샤드 세트를 나열하려면 다음과 같이 listShards
명령을 사용합니다.
db.adminCommand( { listShards : 1 } )
클러스터 상세 정보 보기
클러스터 상세 정보를 보려면 db.printShardingStatus()
또는 sh.status()
를 실행합니다. 두 메서드 모두 동일한 출력을 반환합니다.
예시
다음 예시에서는 sh.status()의 출력이
sharding version
은(는) 샤드 메타데이터의 버전 번호를 표시합니다.shards
은(는) 클러스터에서 샤드로 사용되는mongod
인스턴스 목록을 표시합니다.databases
에는 샤딩이 활성화되지 않은 데이터베이스를 포함하여 클러스터의 모든 데이터베이스가 표시됩니다.foo
데이터베이스에 대한chunks
정보는 각 샤드에 존재하는 청크 개수와 각 청크의 범위를 표시합니다.
--- Sharding Status --- sharding version: { "_id" : 1, "minCompatibleVersion" : 5, "currentVersion" : 6, "clusterId" : ObjectId("59a4443c3d38cd8a0b40316d") } shards: { "_id" : "shard0000", "host" : "m0.example.net:27018" } { "_id" : "shard0001", "host" : "m3.example2.net:27018" } { "_id" : "shard0002", "host" : "m2.example.net:27018" } active mongoses: "3.4.7" : 1 autosplit: Currently enabled: yes balancer: Currently enabled: yes Currently running: no Failed balancer rounds in last 5 attempts: 0 Migration Results for the last 24 hours: 1 : Success databases: { "_id" : "foo", "partitioned" : true, "primary" : "shard0000" } foo.contacts shard key: { "zip" : 1 } unique: false balancing: true chunks: shard0001 2 shard0002 3 shard0000 2 { "zip" : { "$minKey" : 1 } } -->> { "zip" : "56000" } on : shard0001 { "t" : 2, "i" : 0 } { "zip" : 56000 } -->> { "zip" : "56800" } on : shard0002 { "t" : 3, "i" : 4 } { "zip" : 56800 } -->> { "zip" : "57088" } on : shard0002 { "t" : 4, "i" : 2 } { "zip" : 57088 } -->> { "zip" : "57500" } on : shard0002 { "t" : 4, "i" : 3 } { "zip" : 57500 } -->> { "zip" : "58140" } on : shard0001 { "t" : 4, "i" : 0 } { "zip" : 58140 } -->> { "zip" : "59000" } on : shard0000 { "t" : 4, "i" : 1 } { "zip" : 59000 } -->> { "zip" : { "$maxKey" : 1 } } on : shard0000 { "t" : 3, "i" : 3 } { "_id" : "test", "partitioned" : false, "primary" : "shard0000" }