组里用的几台机器换了网段,MongoDB需要做重新配置。

查看Replica Set的状态如下:

rs.status()
{
"startupStatus" : 1,
"ok" : 0,
"errmsg" : "loading local.system.replset config (LOADINGCONFIG)"
}

查看Replica Set的config如下,仍然是之前的IP:

 rs.conf()
{
"_id" : "nj-mongo",
"version" : 1,
"members" : [
{
"_id" : 1,
"host" : "192.168.131.15:27017"
},
{
"_id" : 2,
"host" : "192.168.131.16:27017"
},
{
"_id" : 3,
"host" : "192.168.131.13:27017",
"arbiterOnly" : true
}
]
}

重新配置:

config = {
"_id" : "nj-mongo",
"version" : 1,
"members" : [
{"_id" : 1,"host" : "10.64.203.235:27017"},
{"_id" : 2,"host" : "10.64.203.234:27017"},
{"_id" : 3,"host" : "10.64.203.237:27017","arbiterOnly" : true}
]
}
rs.reconfig(config, {force: true})

这时会显示:

{
"msg" : "will try this config momentarily, try running rs.conf() again in a few seconds",
"ok" : 1
}

过一会再查看状态:

rs.status()
{
"set" : "nj-mongo",
"date" : ISODate("2014-05-09T09:26:33Z"),
"myState" : 1,
"members" : [
{
"_id" : 1,
"name" : "10.64.203.235:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 4724,
"optime" : Timestamp(1397201109, 4),
"optimeDate" : ISODate("2014-04-11T07:25:09Z"),
"self" : true
},
{
"_id" : 2,
"name" : "10.64.203.234:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 543,
"optime" : Timestamp(1397201109, 4),
"optimeDate" : ISODate("2014-04-11T07:25:09Z"),
"lastHeartbeat" : ISODate("2014-05-09T09:26:32Z"),
"lastHeartbeatRecv" : ISODate("2014-05-09T09:26:33Z"),
"pingMs" : 0,
"syncingTo" : "10.64.203.235:27017"
},
{
"_id" : 3,
"name" : "10.64.203.237:27017",
"health" : 1,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 543,
"lastHeartbeat" : ISODate("2014-05-09T09:26:32Z"),
"lastHeartbeatRecv" : ISODate("2014-05-09T09:26:33Z"),
"pingMs" : 0
}
],
"ok" : 1
}
05-29 00:18