准备加入一个备分节点,如下操作:
使用MONGODUMP进行一致性备份
./mongodump -o /ora11g/monbak --oplog -u moadm1 -p gelc123
同样的首先进行恢复
./mongorestore --oplogReplay --port 27030 /ora11g/monbak/
加入OPLOG集合
use local
db.createCollection("oplog.rs",{"capped":true,"size":100000000})
然后恢复oplog的记录
./mongorestore --port 27030 -d local -c oplog.rs /ora11g/monbak/oplog.bson
然后加入备份集主库进行设置
复制key文件
使用如下配置启动新的备份节点
fork=true
logpath=/ora11g/mongodb2.log
logappend=true
journal=true
dbpath=/ora11g/mondata2/
replSet=test1
keyFile=/ora11g/mongodb/mongodb-linux-x86_64-2.6.5/bin/mongodb-keyfile
port=27030
最后主库加入节点
use admin
rs.add({"_id":4,"host":"192.168.190.6:27030","priority":0.5})
最后查看其状态
{
"_id" : 4,
"name" : "192.168.190.6:27030",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 14,
"optime" : Timestamp(1413699079, 2838716),
"optimeDate" : ISODate("2014-10-19T06:11:19Z"),
"lastHeartbeat" : ISODate("2014-06-09T15:21:14Z"),
"lastHeartbeatRecv" : ISODate("2014-06-09T15:21:15Z"),
"pingMs" : 0,
"lastHeartbeatMessage" : "syncing to: 192.168.190.6:27017",
"syncingTo" : "192.168.190.6:27017"
},
已经正常