[test@localhost mongodb-replica]$ tar -zxvf mongodb-linux-x86_64-3.0.5.tgz
[test@localhost mongodb-replica]$ mv mongodb-linux-x86_64-3.0.5 mongodb-replica
[test@localhost mongodb-replica]$ pwd
/home/zhaohongyong/install/mongodb-replica
[test@localhost mongodb-replica]$ mkdir log data
[test@localhost mongodb-replica]$ touch start.sh
[test@localhost mongodb-replica]$ vi start.sh
#!/bin/sh
echo 'start reboot mongo'
# nohup ./bin/mongod --port=27017 --dbpath data/ --logpath log/mongodb.log &
nohup ./bin/mongod --replSet repset --port=27018 --dbpath data/ --logpath log/mongodb.log &
echo 'started mongo'
~
[test@localhost mongodb-replica]$ sh start.sh #啟動
上面總共配置至少三台機器,在任何一台mongodb執行個體上登入,進入admin庫,執行config命令:
use admin
config = { _id:"repset", members:[
{_id:0,host:"172.16.2.132:27017"},
{_id:1,host:"172.16.2.133:27018"},
{_id:2,host:"172.16.2.134:27017"}]
}
rs.initiate(config);
http://blog.csdn.net/mchdba/article/details/51638131