01. Sharding 활성화하기

HA (고가용성) → Replica Set

Scale Out → Sharded Cluster

샤드 클러스터 특징

mongodb database tool

C:\Users\mungy\OneDrive\바탕 화면\HMG\개발공부\백엔드 개발자를 위한 한 번에 끝내는 대용량 데이터 & 트래픽 처리 초격차 패키지 Online\mongodb-database-tools-windows-x86_64-100.7.0\bin


...bin> ./mongo --nodb --norc
> MongoRunner.dataPath
> MongoRunner.dataPath = "/Users/user/fastcampus/mongodb" // 임의지정 (디렉토리 미리생성필요)
> st = ShardingTest({
		name: "test-shard",
		chunkSize: 1,
		shards: 3,
		rs: {
				nodes: 3,
				oplogSize: 10
		},
		other: {
				enableBalance: true
		}
})
> ps -ef | grep mongos
> mongosh localhost:20012
> sh.status()

> arr=[]
> for (i=0; i<100000; i++){
		document = {
				index: i,
				text: "text"+i
		}
		arr.push(document);
}
> db.testing.insertMany(arr);

> sh.enableSharding('test')
> db.testing.createIndex({ index: 1 })
> sh.shardCollection{"test.testing", { index: 1 })
> sh.status()

> db.testing.createIndex({text: "hashed"})
> sh.reshardCollection("test.testing", {text: "hashed"})
> sh.status()

02. MongoDB는 대용량 데이터를 처리하는 데이터베이스일까?

대용량 데이터 기준 : 1PB (사람마다 기준은 다름)