可通过实时查看日志数据,观察备份进度。
?
tail –f mongodump.log
步骤三:在新实例上恢复数据库
?
mongorestore要在mongod未启动的情况下运行,它直接写入文件。
1 mongorestore --host=192.168.11.2:27017 --oplogReplay --dbpath /data/var/lib/mongodb --directoryperdb /nfspool/mongodata > mongorestore.log 2>&1 &
可通过实时查看日志数据,观察恢复进度。
tail –f mongorestore.log
步骤四:在新实例上重建oplog
?
1.查看主副本的维护窗口和oplog大小:
rs_main:PRIMARY> db.printReplicationInfo()? ?
configured oplog size:? 23862.404296875MB? ?
log length start to end: 39405secs (10.95hrs)? ?
oplog first event time:? Sun Feb 08 2015 10:34:07 GMT-0600 (CST)? ?
oplog last event time:? Sun Feb 08 2015 21:30:52 GMT-0600 (CST)? ?
now:? ? ? ? ? ? ? ? ? ? Sun Feb 08 2015 21:30:53 GMT-0600 (CST)
?
2.在新机器上重建oplog:
?
以standalone方式启动,执行如下删除和创建脚本:
> use local? ?
> db.oplog.rs.drop()? ?
> db.createCollection("oplog.rs", {"capped" : true, "size" : 23 * 1024 * 1024 * 1024})? ?
或? ?
> db.runCommand( { create: "oplog.rs", capped: true, size: (23 * 1024 * 1024 * 1024) } )
步骤五:在新实例上恢复oplog
?
此oplog是mongodump时导出的oplog.bson。
mongorestore -d local -c oplog.rs /nfspool/mongodata/oplog.bson
步骤六:新实例以副本集启动
?
新实例配置和源副本集添加相同的--replSet和--keyFile参数,以副本集启动
?
步骤七:将该节点添加到复制集集群中
>rs.add(“192.168.11.2:27017”)
{“ok”:1}