Rumah > Soal Jawab > teks badan
1 进行备份到/var/lib/dumps/
2 误操作删除了一个表
3备份oplog到/root/dump/目录
4 将/root/dump/local/oplog.rs.bson 复制为/root/dump/oplog.bson
5 通过bsondump找到误删除的时间点
6 根据找到的时间点来恢复到误删除之前 报错:
[root@cd_spy2 /var/lib/dumps]# /usr/local/mongodb/bin/mongorestore --port 27020 --oplogReplay --oplogLimit 1472547691:1 /var/lib/dumps
connected to: 127.0.0.1:27020
Tue Aug 30 17:13:35.270 Latest oplog entry on the server is 1472547691:1
Tue Aug 30 17:13:35.270 Only applying oplog entries matching this criteria: { "ts" : { "$gt" : { "$timestamp" : { "t" : 1472547691, "i" : 1 } }, "$lt" : { "$timestamp" : { "t" : 1472547691, "i" : 1 } } } }
Tue Aug 30 17:13:35.271 /var/lib/dumps/admin/system.profile.bson
Tue Aug 30 17:13:35.271 skipping
Tue Aug 30 17:13:35.271 /var/lib/dumps/test/foo.bson
Tue Aug 30 17:13:35.271 ERROR: The oplogLimit option cannot be used if normal databases/collections exist in the dump directory.
字面意思是先找到当前最新的oplog, 然后apply最新的oplog到我oplogLimit 指定的点位之间的事件(这个例子也就是什么都不做)。这个我不理解,应该是apply 从我备份数据开始的时间点 到oplogLimit指定的时间点指点的时间。
然后我再数据库误操作的那个表再insert了一条数据,那系统最新的oplog就比我oplogLimit 指定的点位还要新了,再执行
[root@cd_spy2 /var/lib/dumps]# /usr/local/mongodb/bin/mongorestore --port 27020 --oplogReplay --oplogLimit 1472547691:1 /var/lib/dumps
connected to: 127.0.0.1:27020
Tue Aug 30 17:16:08.756 The oplogLimit is not newer than the last oplog entry on the server.
报错:说我oplogLimit 指定的点位没有系统的oplog新(这不是废话么,我要恢复当然是恢复到以前,难道还能恢复到未来么 - -!!!!!!!!!!!)