Create the necessary directories and authentication files:
[Root@mongo mongo]# mkdir keyfile
[Root@mongo mongo]# echo "MONGO cluster One" > KEYFILE/M1
[Root@mongo mongo]# echo "MONGO cluster One" > keyfile/m2
[Root@mongo mongo]# echo "MONGO cluster One" > keyfile/m3
Start services on different ports
Mongod--replset MCO--keyfile/usr/local/mongo/keyfile/m1--fork--port- Logpath=/usr/local/mongo/log/m1.log--logappend
Mongod--replset MCO--keyfile/usr/local/mongo/keyfile/m2--fork--port- Logpath=/usr/local/mongo/log/m2.log--logappend
Mongod--replset MCO--keyfile/usr/local/mongo/keyfile/m3--fork--port- Logpath=/usr/local/mongo/log/m3.log--logappend
Mongod--replset MCO--keyfile/usr/local/mongo/keyfile/m4--fork--port- Logpath=/usr/local/mongo/log/m4.log--logappend
Mongod--replset MCO--keyfile/usr/local/mongo/keyfile/m5--fork--port- Logpath=/usr/local/mongo/log/m5.log--logappend--fastsync
Configure Master
> config_mco={_id: ' MCO ', members:[
... {_id:0,host: ' localhost:28010 ', priority:1},
... {_id:1,host: ' localhost:28011 '},
... {_id:2,host: ' localhost:28012 '}]
... }
{
"_id": "MCO",
"Members": [
{
"_id": 0,
"Host": "localhost:28010",
"Priority": 1
},
{
"_id": 1,
"Host": "localhost:28011"
},
{
"_id": 2,
"Host": "localhost:28012"
}
]
}