1. 마스터 만들기
mongod -dbpath /Users/User/Desktop/비트전문가과정/repl1/master --master -port 10001
mongo localhost:10001
show dbs
db.printReplicationInfo()
configured oplog size: 192MB
log length start to end: 317secs (0.09hrs)
oplog first event time: Sat Jul 27 2013 11:50:16 GMT+0900 (KST)
oplog last event time: Sat Jul 27 2013 11:55:33 GMT+0900 (KST)
now: Sat Jul 27 2013 11:55:36 GMT+0900 (KST)
db.printSlaveReplicationInfo()
local.sources is empty; is this db a --slave?
db.printShardingStatus()
2. slave1, 2 만들기
mongod -dbpath /Users/User/Desktop/비트전문가과정/repl1/slave1 --slave -port 10002 --source localhost:10001
mongod -dbpath /Users/User/Desktop/비트전문가과정/repl1/slave2 --slave -port 10003 --source localhost:10001
3. REPL로 작업하고 확인하기
//slave1
mongo localhost:10002
db.printSlaveReplicationInfo()
source: localhost:10001
syncedTo: Sat Jul 27 2013 12:09:53 GMT+0900 (KST)
= 74 secs ago (0.02hrs)
> ^C
bye
//slave2
mongo localhost:10003
db.printSlaveReplicationInfo()
source: localhost:10001
syncedTo: Sat Jul 27 2013 12:09:53 GMT+0900 (KST)
= 74 secs ago (0.02hrs)
> ^C
bye
//master
mongo localhost:10001
db.printSlaveReplicationInfo()
local.sources is empty; is this db a --slave?
- master에 데이터 넣고 master에서 save한것이 slave로 복제되는지 확인하기
//master
use hellomaster
db.emp.({name:'honggildong',age:22})
db.emp.find()
{ "_id" : ObjectId("51f33a81dbed34cf65d102d0"), "name" : "honggildong", "age" : 22 }
> show dbs
config (empty)
dowon 0.203125GB
local 0.328125GB
> ^C
bye
//slave1
mongo localhost:10002
rs.slaveOk()
show dbs
use hellomaster
show collection
db.emp.find()
{ "_id" : ObjectId("51f33a81dbed34cf65d102d0"), "name" : "honggildong", "age" : 22 }
'SKILL > DATABASE' 카테고리의 다른 글
몽고db 샤드, 리플리카 (0) | 2018.01.05 |
---|---|
몽고DB (0) | 2018.01.04 |
몽고db JDBC 예제 (0) | 2018.01.03 |
모델링 (0) | 2018.01.03 |
몽고db 실습예제 (0) | 2018.01.02 |