A Three-member Replica Set
Server info: scdbm06~08
MongoDB Info: mongodb-linux-x86_64-2.6.6.tgz
1. Create a folder on the on scdbm06 that holds data and log
Mkdir-p/mongodb/data
Mkdir-p/mongodb/log
Uploading Files to/mongodb
2. On scdbm06
Cd/mongodb
TAR–ZXVF mongodb-linux-x86_64-2.6.6.tgz
3. On scdbm07~8 copy extracted MongoDB file
scp-r [Email Protected]:/mongodb/
4. On scdbm06~08 start Mongod
/mongodb/mongodb-linux-x86_64-2.6.6/bin/mongod--fork--port 27017--dbpath/mongodb/data--logpath=/mongodb/log/ Mongodb.log--replset repset--smallfiles--oplogsize
5. On scdbm06 Connect a MONGO shell to a replica set member.
/mongodb/mongodb-linux-x86_64-2.6.6/bin/mongo--port 27017
6. On scdbm06 Initiate the replica set.
Use Rs.initiate () on the replica set member:
Rs.initiate ()
7. On scdbm06 Verify The initial replica set configuration.
Use Rs.conf () to display the replica set configuration object:
Rs.conf ()
8. On scdbm06 ADD The remaining members to the replica set.
Add the remaining members with the Rs.add () method.
The following example adds:
Rs.add ("Scdbm07")
Rs.add ("scdbm08")
9. On scdbm06 Check The status of the replica set.
Use the Rs.status () operation:
Rs.status ()
--ps-aux | grep MongoDB
The above (6.7.8) can be replaced with the following
Use admin
Config = {_id: "Repset", members:[
{_id:0,host: "scdbm06:27017"},
{_id:1,host: "scdbm07:27017"},
{_id:2,host: "scdbm08:27017"}]
}
Rs.initiate (config);
/*
* Close Mongod
/mongodb/mongodb-linux-x86_64-2.6.6/bin/mongod--fork--port 27017--dbpath/mongodb/data--logpath=/mongodb/log/ Mongodb.log--replset repset--smallfiles--oplogsize---httpinterface--shutdown
*/
Deploy a replica set