[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 #启动
There are at least three machines configured above, login on any MongoDB instance, enter Admin library, execute config command:
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