199宕机。数据无法恢复。
1.将同是shard2的201上的数copy过来。copy之前先停止更新数据。
2.找到剩下的两台机器那个是PRIMARY。在PRIMARY上执行如下操作。
[liyan@cnews197 ~]$ cd /data/support/mongodb-2.0.2/bin
[liyan@cnews197 bin]$ ./mongo -port 15552
MongoDB shell version: 2.0.2
connecting to: 127.0.0.1:15552/test
PRIMARY> rs.status()
{
"set" : "shard2",
"date" : ISODate("2017-11-15T08:51:32Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "10.70.56.199:15552",
"health" : 0,
"state" : 8,
"stateStr" : "(not reachable/healthy)",
"uptime" : 0,
"optime" : {
"t" : 1510342250000,
"i" : 1
},
"optimeDate" : ISODate("2017-11-10T19:30:50Z"),
"lastHeartbeat" : ISODate("2017-11-10T19:31:16Z"),
"pingMs" : 0,
"errmsg" : "socket exception"
},
{
"_id" : 1,
"name" : "10.70.56.201:15552",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 88,
"optime" : {
"t" : 1510735865000,
"i" : 1
},
"optimeDate" : ISODate("2017-11-15T08:51:05Z"),
"lastHeartbeat" : ISODate("2017-11-15T08:51:30Z"),
"pingMs" : 0
},
{
"_id" : 2,
"name" : "10.70.56.197:15552",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1510735865000,
"i" : 1
},
"optimeDate" : ISODate("2017-11-15T08:51:05Z"),
"self" : true
}
],
"ok" : 1
}
PRIMARY> rs.remove('10.70.56.199:15552')// 删除旧的mongod
Wed Nov 15 16:53:57 DBClientCursor::init call() failed
Wed Nov 15 16:53:57 query failed : admin.$cmd { replSetReconfig: { _id: "shard2", version: 2, members: [ { _id: 1, host: "10.70.56.201:15552" }, { _id: 2, host: "10.70.56.197:15552" } ] } } to: 127.0.0.1:15552
Wed Nov 15 16:53:57 Error: error doing query: failed shell/collection.js:151
Wed Nov 15 16:53:57 trying reconnect to 127.0.0.1:15552
Wed Nov 15 16:53:57 reconnect 127.0.0.1:15552 ok
PRIMARY> rs.status() //查看结果
{
"set" : "shard2",
"date" : ISODate("2017-11-15T08:54:07Z"),
"myState" : 1,
"members" : [
{
"_id" : 1,
"name" : "10.70.56.201:15552",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 8,
"optime" : {
"t" : 1510736036000,
"i" : 1
},
"optimeDate" : ISODate("2017-11-15T08:53:56Z"),
"lastHeartbeat" : ISODate("2017-11-15T08:54:05Z"),
"pingMs" : 0,
"errmsg" : "syncThread: 10278 dbclient error communicating with server: 10.70.56.197:15552"
},
{
"_id" : 2,
"name" : "10.70.56.197:15552",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1510736037000,
"i" : 1
},
"optimeDate" : ISODate("2017-11-15T08:53:57Z"),
"self" : true
}
],
"ok" : 1
}
PRIMARY> rs.add('10.70.56.196:15552')// 添加新的mongod
{ "ok" : 1 }
PRIMARY> rs.status() //
{
"set" : "shard2",
"date" : ISODate("2017-11-15T08:54:41Z"),
"myState" : 1,
"members" : [
{
"_id" : 1,
"name" : "10.70.56.201:15552",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 42,
"optime" : {
"t" : 1510736078000,
"i" : 1
},
"optimeDate" : ISODate("2017-11-15T08:54:38Z"),
"lastHeartbeat" : ISODate("2017-11-15T08:54:39Z"),
"pingMs" : 0
},
{
"_id" : 2,
"name" : "10.70.56.197:15552",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1510736078000,
"i" : 1
},
"optimeDate" : ISODate("2017-11-15T08:54:38Z"),
"self" : true
},
{
"_id" : 3,
"name" : "10.70.56.196:15552",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 3,
"optime" : {
"t" : 1510730231000,
"i" : 1
},
"optimeDate" : ISODate("2017-11-15T07:17:11Z"),
"lastHeartbeat" : ISODate("2017-11-15T08:54:40Z"),
"pingMs" : 163
}
],
"ok" : 1
}
Mongodb复制集中一个mongod挂掉后机器起不来,处理方法
姓名 | |
邮箱 | |
URL | |