Nosql Mongodb之旅(26)—MongoDB Replica Sets减少节点

前端之家收集整理的这篇文章主要介绍了Nosql Mongodb之旅(26)—MongoDB Replica Sets减少节点前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

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

[plain] view plain copy
  1. rs1:PRIMARY>rs.remove("localhost:28014")
  2. {"ok":1}
  3. rs1:PRIMARY>rs.remove("localhost:28013")
  4. {"ok":1}
查看复制集状态,可以看到现在只有28010、28011、28012 这三个成员,原来的28013 和28014 都成功去除
    rs1:PRIMARY>rs.status()
  1. {
  2. "set":"rs1",
  3. "date":ISODate("2012-05-31T14:08:29Z"),
  4. "myState":1,248); line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "members":[
  5. {
  6. "_id":0,108); list-style:decimal-leading-zero outside; color:inherit; line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "name":"localhost:28010",248); line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "health":1,108); list-style:decimal-leading-zero outside; color:inherit; line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "state":1,248); line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "stateStr":"PRIMARY",108); list-style:decimal-leading-zero outside; color:inherit; line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "optime":{
  7. "t":1338473273000,108); list-style:decimal-leading-zero outside; color:inherit; line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "i":1
  8. },108); list-style:decimal-leading-zero outside; color:inherit; line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "optimeDate":ISODate("2012-05-31T14:07:53Z"),248); line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "self":true
  9. },108); list-style:decimal-leading-zero outside; color:inherit; line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "_id":1,248); line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "name":"localhost:28011",108); list-style:decimal-leading-zero outside; color:inherit; line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "health":1,248); line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "state":2,108); list-style:decimal-leading-zero outside; color:inherit; line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "stateStr":"SECONDARY",248); line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "uptime":34,248); line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "lastHeartbeat":ISODate("2012-05-31T14:08:29Z")
  10. "_id":2,248); line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "name":"localhost:28012",108); list-style:decimal-leading-zero outside; color:inherit; line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> }
  11. ],108); list-style:decimal-leading-zero outside; color:inherit; line-height:21px; margin:0px!important; padding:0px 3px 0px 10px!important"> "ok":1
  12. }
  13. rs1:PRIMARY>
原文链接:https://www.f2er.com/nosql/204150.html

猜你在找的NoSQL相关文章