'몽고db'에 해당되는 글 9건

  1. 스터디 발표 자료 - 관리와 배포
  2. log rotate 처리하기 - window os
  3. [펌] Global Lock, MongoDB 2.0 vs 2.2
  4. 해외 NoSQL 관련 JOB 수요
  5. 몽고DB 책 소개
  6. 몽고DB Replicated Shard Cluster + Arbitor
  7. 몽고DB 활용 사례
  8. 몽고DB Sharding 설정 및 테스트 16
  9. 몽고DB Config 설정하기(Win7)

몽고DB 스터디 발표 자료입니다.


배포와 관리.ppt


'Etc' 카테고리의 다른 글

Redis - Windows 설치하기  (2) 2012.06.07
MySQL을 대체한 RDBMS F1  (1) 2012.06.01
log rotate 처리하기 - window os  (0) 2012.05.29
[펌] Global Lock, MongoDB 2.0 vs 2.2  (0) 2012.05.25
해외 NoSQL 관련 JOB 수요  (0) 2012.05.23

안녕하세요. 주디아줌마입니다.

몽고DB의 경우 따로 로그를 비워내지 않으면 로그 파일이 무한정 커지게 됩니다.  Windows 환경의 경우 Shell명령을 2.0.3 이후 버젼부터 지원됩니다. 자동으로 rotate되면 좋을 텐데 아직 지원이 안되네요.


http://www.mongodb.org/display/DOCS/Logging

The logRotate command is available on Windows in version 2.0.3 and higher

> use admin

switched to db admin

> db.runCommand({logRotate: 1});

{ "ok" : 1 }




'Etc' 카테고리의 다른 글

MySQL을 대체한 RDBMS F1  (1) 2012.06.01
스터디 발표 자료 - 관리와 배포  (0) 2012.05.30
[펌] Global Lock, MongoDB 2.0 vs 2.2  (0) 2012.05.25
해외 NoSQL 관련 JOB 수요  (0) 2012.05.23
ipv6에 대해 고려중이신가요?  (0) 2012.05.17

charsysm;s 블로그
http://charsyam.wordpress.com/2012/05/24/%EB%B0%9C-%EB%B2%88%EC%97%AD-%EC%9E%98%EA%B0%80-global-lock-mongodb-2-0-vs-2-2/ 


몽고DB 2.2 Release Note
http://www.mongodb.org/display/DOCS/2.2+Release+Notes


몽고DB 2.2 중요 이슈
1. Global lock 의 제거
2. 데이타베이스 수준까지의 락 제어. (데이터베이스 lock을 collectiion 수준의 lock으로 변경되겠지요?...) (점점 다른 dbms에 지원되는 lock까지.ㅋㅋ)


개선 부분
global reader/writer lock 의 제거 – 첫 시도로 database level lock
PageFaultException 구조 – page fault 시에 Lock 양보.
점점 더 개선되는 모습들이 보입니다. ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ


charsysm's님의 블로그에서 확인하세요^^.

'Etc' 카테고리의 다른 글

스터디 발표 자료 - 관리와 배포  (0) 2012.05.30
log rotate 처리하기 - window os  (0) 2012.05.29
해외 NoSQL 관련 JOB 수요  (0) 2012.05.23
ipv6에 대해 고려중이신가요?  (0) 2012.05.17
SQL 책 추천(강력 추천)  (0) 2012.05.16

해외 NoSQL 관련 JOB 수요

'Etc' 카테고리의 다른 글

log rotate 처리하기 - window os  (0) 2012.05.29
[펌] Global Lock, MongoDB 2.0 vs 2.2  (0) 2012.05.25
ipv6에 대해 고려중이신가요?  (0) 2012.05.17
SQL 책 추천(강력 추천)  (0) 2012.05.16
몽고DB 책 소개  (0) 2012.05.16

몽고DB 책 소개

얼마전에 출간된 몽고DB 번역서입니다. 책을 사서 읽고있지만 정말 깊이 있는 내용을 가지고 있네요.  특히, 인덱스 부분 최적화 부분에 잘 설명되어 있습니다.


http://kangcom.com/sub/view.asp?topid=1&sku=201204060003



이 책으로 몽고DB 사용자 그룹에서 스터디 진행중입니다. http://cafe.naver.com/mongodatabase


이 책으로 심도있게 서버 구축, 테스트, 모니터링 관련해서 공부하려고 합니다.

아자.ㅋㅋ


'Etc' 카테고리의 다른 글

ipv6에 대해 고려중이신가요?  (0) 2012.05.17
SQL 책 추천(강력 추천)  (0) 2012.05.16
DB 개체 스크립트 하기  (0) 2012.04.25
몽고DB Replicated Shard Cluster + Arbitor  (0) 2012.03.19
몽고DB 활용 사례  (0) 2012.03.19

MongoDB on EC2


위와 같이 EC2에서  몽고DB 환경 구성을 ReplicaSet + Sharding 테스트 환경구성하려고 합니다. 


참고링크
CookBook의 Marc Bastien님이 정리해주신 자료를 바탕으로 테스트 환경 구성합니다.


테스트 환경
Win7 64bit

테스트 구성 정보

- 각각의 Replica Sets은 3개 노드로 구성되며, 그중 3번째 노드는 arbiter로 구성.
- Mongos N개까지 여유가 되면 추가 구성 합니다. 
- Replica-Set은 스스로 감지할 수 있는 장점이 있지만, 간혹가다 감지를 못하는 경우도 있다고 합니다. 그럴경우를 대비해서 aribter node(결정권자 노드) 구성을 하여 복제 노드들 간의 투표 참가만 합니다. arbiter node는  복제본을 가지고 있지 않습니다.



Process

1. 3개 Replica Set 구성 및 테스트 데이타 등록

1.1 저장소 디렉토리 구성

D:\DB\MONGO> mkdir firstset1 , firstset2, firstarbiter

D:\DB\MONGO> mkdir secondset1, secondset2, secondarbiter

D:\DB\MONGO> mkdir thirdset1, thirdset2, thirdarbiter
D:\DB\MONGO> mkdir config1,  config2, config3

테스트로 D:\DB\MONGO\ 폴더에 관리자 권한으로 저장 디렉토리를 생성

1.2 mongod 3개의 인스턴스를 시작

mongod --dbpath D:\DB\MONGO\firstset1 --port 10001 --replSet firstset --oplogSize 700 --rest

mongod --dbpath D:\DB\MONGO\firstset2 --port 10002 --replSet firstset --oplogSize 700 --rest

mongod --dbpath D:\DB\MONGO\firstarbiter --port 10003 --replSet firstset --oplogSize 700 --rest

- 몽고DB 설치 참조  http://judydba.tistory.com/129  
- oplog :  마스터가 수행한 연산 기록을 oplog(operatorion log)이라고 하며, 특수한 데이타베이스의 oplog.$main 컬렉션에 저장.  msql에서 보면 트랜잭션 로그 같다고 보면 된다. oplog는 제한 컬렉션에 저장된다는 점인데  새로운 연산이 oplog에 저장될때 자동적으로 오래된 연산을 대체 한다. 64비트 인스턴스라고 하면 가용량의 5% 정도를 oplog 용도로 사용 한다. 테스트 환경에서는 700M로 로그 제한 한다. 
 
1.3 mongo shell 접속

C:\>mongo localhost:10001/admin

MongoDB shell version: 2.0.2

connecting to: localhost:10001/admin


1.4 first replica-set 초기화 

db.runCommand({"replSetInitiate" : {"_id" : "firstset", "members" : [{"_id" : 1, "host" : "localhost:10001"}, {"_id" : 2, "host" : "localhost:10002"}, {"_id" : 3, "host" : "localhost:10003", arbiterOnly: true }]}})

firstset이라고 하는 replica-set 이름을 지정하며, 세번째 호스트를 arbiter노드로 지정

1.5 데이타를 등록

PRIMARY> use test

switched to db test
 

PRIMARY>  people = ["Marc", "Bill", "George", "Eliot", "Matt", "Trey", "Tracy", "Greg", "Steve", "Kristina", "Katie", "Jeff"];

PRIMARY> for(var i=0; i<1000000; i++){

     name = people[Math.floor(Math.random()*people.length)];

     user_id = i;

     boolean = [true, false][Math.floor(Math.random()*2)];

     added_at = new Date();

     number = Math.floor(Math.random()*10001);

     db.test_collection.save({"name":name, "user_id":user_id, "boolean": boolean, "added_at":added_at, "number":number });

test db를 생성하고, test_collection에 데이타를 입력 한다.  


2. Config instance와 single shard 생성

config server는 어떤 데이타가 어떤 샤드에 있는지, 클러스터 설정을 저장한다. mongos 어떤 데이터도 영구 저장하지 않기 때문에 샤드 설정 받을 곳이 필요하다. 

2.1 config servers 실행

mongod --configsvr --dbpath D:\DB\MONGO\config1 --port 20001

mongod --configsvr --dbpath D:\DB\MONGO\config2 --port 20002

mongod --configsvr --dbpath D:\DB\MONGO\config3 --port 20003


2.2 mongos 실행

mongos --configdb localhost:20001,localhost:20002,localhost:20003 --port 27018 --chunkSize 1

27018 port로 mongos 인스턴스를 실행한다.  

2.3 샤드를 추가

D:\DB\MONGO>mongo localhost:27018/admin

MongoDB shell version: 2.0.2

connecting to: localhost:27018/admin

mongos> db.runCommand( { addshard : "firstset/localhost:10001,localhost:10002,localhost:10003" } )

{ "shardAdded" : "firstset", "ok" : 1 }

mongos>



3. 두번째, 세번째 복제셋 생성 

3.1 두번째 mongod instance 실행

mongod --dbpath D:\DB\MONGO\secondset1 --port 10004 --replSet secondset --oplogSize 700 --rest

mongod --dbpath D:\DB\MONGO\secondset2 --port 10005 --replSet secondset --oplogSize 700 --rest

mongod --dbpath D:\DB\MONGO\secondarbiter --port 10006 --replSet secondset --oplogSize 700 --rest


3.2  second replica-set 초기화  

mongo localhost:10004/admin
db.runCommand({"replSetInitiate" : {"_id" : "secondset", "members" : [{"_id" : 1, "host" : "localhost:10004"}, {"_id" : 2, "host" : "localhost:10005"}, {"_id" : 3, "host" : "localhost:10006", arbiterOnly: true}]}}) 



3.3 두번째 샤드 클러스터 복제셋 추가

mongo localhost:27018/admin

db.runCommand( { addshard : "secondset/localhost:10004,localhost:10005,localhost:10006" } )

db.runCommand({listshards:1})


 3.4 세번째 리플리카 mongod instance 실행

mongod --dbpath D:\DB\MONGO\thirdset1 --port 10007 --replSet thirdset --oplogSize 700 --rest

mongod --dbpath D:\DB\MONGO\thirdset2 --port 10008 --replSet thirdset --oplogSize 700 --rest

mongod --dbpath D:\DB\MONGO\thirdarbiter --port 10009 --replSet thirdset --oplogSize 700 --rest


3.5 복제 설정 초기화

mongo localhost:10007/admin


db.runCommand({"replSetInitiate" : {"_id" : "thirdset", "members" : [{"_id" : 1, "host" : "localhost:10007"}, {"_id" : 2, "host" : "localhost:10008"}, {"_id" : 3, "host" : "localhost:10009",  arbiterOnly: true  }]}})



3.6 세번째 샤드 클러스터 복제셋 구성

mongo localhost:27018/admin

db.runCommand( { addshard : "thirdset/localhost:10007,localhost:10008,localhost:10009" } )

db.runCommand({listshards:1})



4. 샤딩 활성화

5.1 데이타베이스 레벨 샤딩 설정

mongo localhost:27018/admin 

mongos> use admin

switched to db admin

mongos> show dbs;

config  0.0625GB

test    0.203125GB

mongos> db.runCommand( { enablesharding : "test" } )

{ "ok" : 1 }


5.2 샤딩키 인덱스 생성

use test
db.test_collection.ensureIndex({number:1})


5.3 Collection의 샤드키 설정

use admin

-- test.test_collection의 number를 키 설정

db.runCommand( { shardcollection : "test.test_collection", key : {"number":1} })


5.4 마무리

use test


db.stats()

db.printShardingStatus()


'Etc' 카테고리의 다른 글

몽고DB 책 소개  (0) 2012.05.16
DB 개체 스크립트 하기  (0) 2012.04.25
몽고DB 활용 사례  (0) 2012.03.19
몽고DB Sharding 설정 및 테스트  (16) 2012.02.29
SQL 설치 유용한 스크립트  (0) 2012.02.24

몽고DB 활용 사례

'Etc' 카테고리의 다른 글

DB 개체 스크립트 하기  (0) 2012.04.25
몽고DB Replicated Shard Cluster + Arbitor  (0) 2012.03.19
몽고DB Sharding 설정 및 테스트  (16) 2012.02.29
SQL 설치 유용한 스크립트  (0) 2012.02.24
journal 폴더가 왜 생기는 걸까?  (0) 2012.02.21

테스트 환경 : Win7 64bit, SSD 128G, Memory 8G

 
1. DB 폴더 생성(관리자 권한 실행)

D:\DB\MONGO>mkdir SHARD1, SHARD2, CONFIG

 
2. 샤딩 서비스 실행

가. 설정 서버 실행

D:\DB\MONGO>mongod --dbpath D:\DB\MONGO\CONFIG --port 20000

 
나. 라우팅 서버 실행

D:\DB\MONGO>mongos --port 30000 --configdb localhost:20000

 
다. 샤딩 인스턴스 1, 2 실행

D:\DB\MONGO>mongod --dbpath D:\DB\MONGO\SHARD1 --port 10000
D:\DB\MONGO>mongod --dbpath D:\DB\MONGO\SHARD2 --port 10001  

 
3. 샤딩 구성

가. mongos 라우팅 인스턴스 접속

C:\Users\judydba>mongo localhost:30000/admin

MongoDB shell version: 2.0.2

connecting to: localhost:30000/admin


 
나. 샤드 구성
addshard 명령어로 샤드를 추가

mongos> db.runCommand( {addshard : "localhost:10000", allowLocal:true})

{ "shardAdded" : "shard0000", "ok" : 1 }

mongos> db.runCommand( {addshard : "localhost:10001", allowLocal:true})

{ "shardAdded" : "shard0001", "ok" : 1 }

※ allowLocal 키는 localhost에 샤드를 실행할 때만 필요합니다. 몽고디비는 실수로 로컬에 클러스터를 설정하는 사태를 막기 위해. allowLocal:true는 생략 가능
 

다. 데이터 샤딩
데이타 분산을 위한 데이터베이스와 컬렉션 수준으로 명시적 설정 
testdb의 test collection을 분산.
분산을 위한 샤드 키는 seq 설정

mongos> db.runCommand({ "enablesharding" : "testdb" })

{ "ok" : 1 }

mongos> db.runCommand({ "shardcollection" : "testdb.test", "key" : {"seq" : 1}})

{ "collectionsharded" : "testdb.test", "ok" : 1 }

 
라. 샤드 구성 확인
청크 사이즈  64M

mongos> use config

switched to db config

mongos> db.shards.find();

{ "_id" : "shard0000", "host" : "localhost:10000" }

{ "_id" : "shard0001", "host" : "localhost:10001" }

mongos> db.databases.find()

{ "_id" : "admin", "partitioned" : false, "primary" : "config" }

{ "_id" : "testdb", "partitioned" : true, "primary" : "shard0000" }

mongos> db.chunks.find()

{ "_id" : "testdb.test-seq_MinKey", "lastmod" : { "t" : 1000, "i" : 0 }, "ns" :

"testdb.test", "min" : { "seq" : { $minKey : 1 } }, "max" : { "seq" : { $maxKey

: 1 } }, "shard" : "shard0000" }
 

mongos> db.printShardingStatus()

--- Sharding Status ---

  sharding version: { "_id" : 1, "version" : 3 }

  shards:

        {  "_id" : "shard0000",  "host" : "localhost:10000" }

        {  "_id" : "shard0001",  "host" : "localhost:10001" }

  databases:

        {  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }

        {  "_id" : "testdb",  "partitioned" : true,  "primary" : "shard0000" }

                testdb.test chunks:

                                shard0000       1

                        { "seq" : { $minKey : 1 } } -->> { "seq" : { $maxKey : 1

 } } on : shard0000 { "t" : 1000, "i" : 0 }

 
 
4. 테스트
500000 데이타를 입력

mongos> use testdb
switched to db testdb

mongos> for(i=0; i<500000; i++) { db.test.insert({"_id" : i, "seq" : i+5000, "date": new Date() }); }


5. 청크 정보 확인

mongos> use config

switched to db config

mongos> db.chunks.find()

{ "_id" : "testdb.test-seq_MinKey", "lastmod" : { "t" : 2000, "i" : 1 }, "ns" :

"testdb.test", "min" : { "seq" : { $minKey : 1 } }, "max" : { "seq" : 5000 }, "s

hard" : "shard0000" }

{ "_id" : "testdb.test-seq_5000.0", "lastmod" : { "t" : 1000, "i" : 3 }, "ns" :

"testdb.test", "min" : { "seq" : 5000 }, "max" : { "seq" : 17024 }, "shard" : "s

hard0000" }

{ "_id" : "testdb.test-seq_17024.0", "lastmod" : { "t" : 2000, "i" : 2 }, "ns" :

 "testdb.test", "min" : { "seq" : 17024 }, "max" : { "seq" : 419135 }, "shard" :

 "shard0001" }

{ "_id" : "testdb.test-seq_419135.0", "lastmod" : { "t" : 2000, "i" : 3 }, "ns"

: "testdb.test", "min" : { "seq" : 419135 }, "max" : { "seq" : { $maxKey : 1 } }

, "shard" : "shard0001" }
 

mongos> db.printShardingStatus()

--- Sharding Status ---

  sharding version: { "_id" : 1, "version" : 3 }

  shards:

        {  "_id" : "shard0000",  "host" : "localhost:10000" }

        {  "_id" : "shard0001",  "host" : "localhost:10001" }

  databases:

        {  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }

        {  "_id" : "testdb",  "partitioned" : true,  "primary" : "shard0000" }

                testdb.test chunks:

                                shard0000       2

                                shard0001       2

                        { "seq" : { $minKey : 1 } } -->> { "seq" : 5000 } on : s

hard0000 { "t" : 2000, "i" : 1 }

                        { "seq" : 5000 } -->> { "seq" : 17024 } on : shard0000 {

 "t" : 1000, "i" : 3 }

                        { "seq" : 17024 } -->> { "seq" : 419135 } on : shard0001

 { "t" : 2000, "i" : 2 }

                        { "seq" : 419135 } -->> { "seq" : { $maxKey : 1 } } on :

 shard0001 { "t" : 2000, "i" : 3 }

데이타가 증가할 수록 moveChunk 폴더가 생기면서 데이타가 분리되었음을 확인가능함.

shard0000, shard0001 청크가 2개씩 존재하며, 각 샤드키로 분산되어 있다.

shard0000 : seq 1 ~ 50000
shard0000 : seq 5000~17024
shard0001 : seq 17024 ~ 419135
shard0001 : seq 419135 ~ Max

 


'Etc' 카테고리의 다른 글

몽고DB Replicated Shard Cluster + Arbitor  (0) 2012.03.19
몽고DB 활용 사례  (0) 2012.03.19
SQL 설치 유용한 스크립트  (0) 2012.02.24
journal 폴더가 왜 생기는 걸까?  (0) 2012.02.21
몽고DB Config 설정하기(Win7)  (0) 2012.02.20

몽고DB 환경설정을 -f, --config으로  설정할 수 있다.

1. 환경설정 파일 생성
   mongodb.conf 파일을 생성하여 아래와 같이 적용한다. 확장자를 꼭 확인해야 한다. 메모장에서  생성하여 저장하면 기본적으로 .txt로 생성된다. 

dbpath = /mdb

bind_ip = 127.0.0.1

port = 5586
logpath = C:\mongodb\log\log.txt  ## 로그 경로 

noauth = true # use 'true' for options that don't take an argument

verbose = true # to disable, comment out.
 


2. 환경 설정 파일 실행하기(관리자 권한으로 실행)

  
 

'Etc' 카테고리의 다른 글

SQL 설치 유용한 스크립트  (0) 2012.02.24
journal 폴더가 왜 생기는 걸까?  (0) 2012.02.21
몽고DB 책 소개  (0) 2012.02.17
몽고DB 어드민 관리툴  (1) 2011.08.18
SQL to Mongo Mapping Chart  (0) 2011.08.18