MongoDB学习之旅二十五:MongoDB Replica Sets 减少节点

    当应用的压力小时,可以减少一些节点来减少硬件资源的成本;总之这是一个长期且持续的工作。

    下面将刚刚添加的两个新节点28013 和28014 从复制集中去除掉,只需执行rs.remove 指令就可以了,具体如下:

rs1:PRIMARY> rs.remove("localhost:28014")
{ "ok" : 1 }
rs1:PRIMARY> rs.remove("localhost:28013")
{ "ok" : 1 }
    查看复制集状态,可以看到现在只有28010、28011、28012 这三个成员,原来的28013 和28014 都成功去除了
rs1:PRIMARY> rs.status()
{
"set" : "rs1",
"date" : ISODate("2012-05-31T14:08:29Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "localhost:28010",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1338473273000,
"i" : 1
},
"optimeDate" : ISODate("2012-05-31T14:07:53Z"),
"self" : true
},
{
"_id" : 1,
"name" : "localhost:28011",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 34,
"optime" : {
"t" : 1338473273000,
"i" : 1
},
"optimeDate" : ISODate("2012-05-31T14:07:53Z"),
"lastHeartbeat" : ISODate("2012-05-31T14:08:29Z")
},
{
"_id" : 2,
"name" : "localhost:28012",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 34,
"optime" : {
"t" : 1338473273000,
"i" : 1
},
"optimeDate" : ISODate("2012-05-31T14:07:53Z"),
"lastHeartbeat" : ISODate("2012-05-31T14:08:29Z")
}
],
"ok" : 1
}
rs1:PRIMARY>

你可能感兴趣的:(mongodb)