ot@orcl ~]# ps -ef |grep mongo
root ? ? ?3472 ? ? 1 ?2 19:15 ? ? ? ? ?00:02:18 mongod -f /etc/config.conf
root ? ? ?3575 ? ? 1 ?0 19:28 ? ? ? ? ?00:00:48 mongos -f /etc/route.conf
root ? ? ?4135 ? ? 1 ?0 20:52 ? ? ? ? ?00:00:07 mongod -f /etc/sd1.conf
root ? ? ?4205 ? ? 1 ?0 20:55 ? ? ? ? ?00:00:05 mongod -f /etc/sd2.conf
root ? ? ?4265 ? ? 1 ?0 20:58 ? ? ? ? ?00:00:04 mongod -f /etc/sd3.conf
节点2
[root@localhost ~]# ps -ef |grep mongo
root ? ? ?2998 ? ? 1 ?1 19:15 ? ? ? ? ?00:02:02 mongod -f /etc/config.conf
root ? ? ?3057 ? ? 1 ?1 19:28 ? ? ? ? ?00:01:02 mongos -f /etc/route.conf
root ? ? ?3277 ? ? 1 ?1 20:52 ? ? ? ? ?00:00:20 mongod -f /etc/sd1.conf
root ? ? ?3334 ? ? 1 ?6 20:56 ? ? ? ? ?00:00:52 mongod -f /etc/sd2.conf
root ? ? ?3470 ? ? 1 ?1 21:01 ? ? ? ? ?00:00:07 mongod -f /etc/sd3.conf
节点3
[root@db10g data]# ps -ef |grep mongo
root ? ? ?4086 ? ? 1 ?1 19:25 ? ? ? ? ?00:01:58 mongod -f /etc/config.conf
root ? ? ?4108 ? ? 1 ?0 19:27 ? ? ? ? ?00:00:55 mongos -f /etc/route.conf
root ? ? ?4592 ? ? 1 ?0 20:54 ? ? ? ? ?00:00:07 mongod -f /etc/sd1.conf
root ? ? ?4646 ? ? 1 ?3 20:56 ? ? ? ? ?00:00:30 mongod -f /etc/sd2.conf
root ? ? ?4763 ? ? 1 ?4 21:04 ? ? ? ? ?00:00:12 mongod -f /etc/sd3.conf
七、配置副本集
192.168.1.30
[root@orcl ~]# mongo --port 27018
MongoDB shell version: 2.6.4
connecting to: 127.0.0.1:27018/test
> use admin
switched to db admin
> rs1={_id:"set1",members:[{_id:0,host:"192.168.1.30:27018",priority:2},{_id:1,host:"192.168.1.52:27018"},{_id:2,host:"192.168.1.108:27018",arbiterOnly:true}]}
{
? ? ? ? "_id" : "set1",
? ? ? ? "members" : [
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? "_id" : 0,
? ? ? ? ? ? ? ? ? ? ? ? "host" : "192.168.1.30:27018",
? ? ? ? ? ? ? ? ? ? ? ? "priority" : 2
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? "_id" : 1,
? ? ? ? ? ? ? ? ? ? ? ? "host" : "192.168.1.52:27018"
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? "_id" : 2,
? ? ? ? ? ? ? ? ? ? ? ? "host" : "192.168.1.108:27018",
? ? ? ? ? ? ? ? ? ? ? ? "arbiterOnly" : true
? ? ? ? ? ? ? ? }
? ? ? ? ]
}
> rs.initiate(rs1)
{
? ? ? ? "info" : "Config now saved locally. ?Should come online in about a minute.",
? ? ? ? "ok" : 1
}
192.168.1.52
[root@orcl ~]# mongo --port 27019
MongoDB shell version: 2.6.4
connecting to: 127.0.0.1:27019/test
> use admin
switched to db admin
> rs2={_id:"set2",members:[{_id:0,host:"192.168.1.52:27019",priority:2},{_id:1,host:"192.168.1.108:27019"},{_id:2,host:"192.168.1.30:27019",arbiterOnly:true}]}
{
? ? ? ? "_id" : "set2",
? ? ? ? "members" : [
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? "_id" : 0,
? ? ? ? ? ? ? ? ? ? ? ? "host" : "192.168.1.52:27019",
? ? ? ? ? ? ? ? ? ? ? ? "priority" : 2
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? "_id" : 1,
? ? ? ? ? ? ? ? ? ? ? ? "host" : "192.168.1.108:27019"
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? "_id" : 2,
? ? ? ? ? ? ? ? ? ? ? ? "host" : "192.168.1.30:27019",
? ? ? ? ? ? ? ? ? ? ? ? "arbiterOnly" : true
? ? ? ? ? ? ? ? }
? ? ? ? ]
}
> rs.initiate(rs2);
{
? ? ? ? "info" : "Config now saved locally. ?Should come online in about a minute.",
? ? ? ? "ok" : 1
}
192.168.1.108
[root@localhost sd3]# mongo --port 27020
MongoDB shell version: 2.6.4
connecting to: 127.0.0.1:27020/test
> use admin
switched to db admin
> rs3={_id:"set3",members:[{_id:0,host:"192.168.1.108:27020",priority:2},{_id:1,host:"192.168.1.30:27020"},{_id:2,host:"192.168.1.52:27020",arbiterOnly:true}]}
{
? ? ? ? "_id" : "set3",
? ? ? ? "members" : [
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? "_id" : 0,
? ? ? ? ? ? ? ? ? ? ? ? "host" : "192.168.1.108:27020",
? ? ? ? ? ? ? ? ? ? ? ? "priority" : 2
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? "_id" : 1,
? ? ? ? ? ? ? ? ? ? ? ? "host" : "192.168.1.30:27020"
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? "_id" : 2,
? ? ? ? ? ? ? ? ? ? ? ? "host" : "192.168.1.52:27020",
? ? ? ? ? ? ? ? ? ? ? ? "arbiterOnly" : true
? ? ? ? ? ? ? ? }
? ? ? ? ]
}
> rs.initiate(rs3);