[MongDB+Node.js] 부산정보산업진흥원 교육 샘플

2014. 10. 24. 17:05서버 프로그래밍

<Replication>

1)마스터실행

mongod -dbpath d:\mongodb\var -port 10000 -master


2)슬래이브 실행

mkdir var2

mkdir var3

mongod -dbpath d:\mongodb\var2 -port 10001 -slave -source localhost:10000

mongod -dbpath d:\mongodb\var3 -port 10002 -slave -source localhost:10000


3)마스터 접속

mongo localhost:10000

> db.users.save({name:'Park'});


4)슬래이브 접속

mongo localhost:10001

> db.users.find();

---------------------------------

<레플리카셋>

1)서버 실행 

mongod --replSet downSet -dbpath d:\mongodb\var -port 10000

mongod --replSet downSet -dbpath d:\mongodb\var4 -port 10001

mongod --replSet downSet -dbpath d:\mongodb\var5 -port 10002


2)primary접속

mongo localhost:10000

> var config = {_id:'downSet',members:[{_id:0,host:'localhost:10000'},

  {_id:1,host:'localhost:10001'},{_id:2,host:'localhost:10002'}]};

> rs.initiate(config);


workspace_부산정보산업진흥원_20141024_1.zip


workspace_부산정보산업진흥원_20141024_2.zip