MongoDB學習整理之Replica Sets安裝 |
發布時間: 2012/7/26 16:58:21 |
準備: 1、創建數據文件、日志路徑目錄及復制集key文件 echo "test sets" > /app/mongo/mongodb/data/sets/key/r0 chmod 600 /app/mongo/mongodb/data/sets/key/r* 2、啟動3個mongodb實例模擬3個節點服務器: /app/mongo/mongodb/bin/mongod --replSet rs1 --keyFile /app/mongo/mongodb/data/sets/key/r0 --port 28010 --dbpath=/app/mongo/mongodb/data/sets/r0 --logpath=/app/mongo/mongodb/data/sets/log/r0.log --logappend --fork /app/mongo/mongodb/bin/mongod --replSet rs1 --keyFile /app/mongo/mongodb/data/sets/key/r1 --port 28011 --dbpath=/app/mongo/mongodb/data/sets/r1 --logpath=/app/mongo/mongodb/data/sets/log/r2.log --logappend --fork /app/mongo/mongodb/bin/mongod --replSet rs1 --keyFile /app/mongo/mongodb/data/sets/key/r2 --port 28012 --dbpath=/app/mongo/mongodb/data/sets/r2 --logpath=/app/mongo/mongodb/data/sets/log/r3.log --logappend --fork 3、初始化Replica Sets環境 >config_rs={_id:'rs1',members:[{_id:0,host:'localhost:28010'},{_id:1,host:'localhost:28011'},{_id:2,host:'localhost:28012'}]} 本文出自:億恩科技【www.endtimedelusion.com】 |