实战演练
88504018喜欢 db2 oracle java的朋友进来了使用RECOVER进行恢复
数据库状态参考实战演练 - 08
1。全备份
CMD: db2 backup database backupts online to /mnt/hgfs/F/backup/
CMD: db2 connect to backupts
Database Connection Information
Database server = DB2/LINUXX8664 9.7.1
SQL authorization ID = DB2INST1
Local database alias = BACKUPTS
2。连续两次插入数据并进行增量备份后,再插入数据
CMD: db2 "insert into header values(5,'EE','55','2010-07-10')"
DB20000I The SQL command completed successfully.
CMD: db2 "insert into details values(5,1,'AAAA','0','0')"
DB20000I The SQL command completed successfully.
CMD: db2 "insert into details values(5,2,'BBBB','0','0')"
DB20000I The SQL command completed successfully.
CMD: db2 backup database backupts incremental delta to /mnt/hgfs/F/backup/
Backup successful. The timestamp for this backup image is : 20100711003827
CMD: db2 connect to backupts
CMD: db2 "insert into master values(3,'CCCC','CC','33','2010-07-10')"
DB20000I The SQL command completed successfully.
CMD: db2 "insert into master values(4,'DDDD','DD','44','2010-07-10')"
DB20000I The SQL command completed successfully.
CMD: db2 backup database backupts incremental delta to /mnt/hgfs/F/backup/
Backup successful. The timestamp for this backup image is : 20100711004008
CMD: db2 connect to backupts
CMD: db2 "insert into details values(3,1,'AAAA','0','0')"
DB20000I The SQL command completed successfully.
CMD: db2 "insert into details values(3,2,'BBBB','0','0')"
DB20000I The SQL command completed successfully.
3。故障。误删除数据!
CMD: date
Sun Jul 11 00:41:41 CST 2010
CMD: db2 delete from master
DB20000I The SQL command completed successfully.
CMD: db2 delete from details
DB20000I The SQL command completed successfully.
4。REVOER恢复
CMD: db2 "recover database to 2010-07-11-00.41.41 using local time"
SQL0104N An unexpected token "2010-07-11-00.41.41" was found following "TO".
Expected tokens may include: "USER". SQLSTATE=42601
CMD: db2 "recover database backupts to 2010-07-11-00.41.41 using loc
al time"
Rollforward Status
Input database alias = backupts
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000007.LOG - S0000007.LOG
Last committed transaction = 2010-07-11-00.41.11.000000 Local
DB20000I The RECOVER DATABASE command completed successfully.
5。验证数据,正确。
CMD: db2 connect to backupts
CMD: db2 connect to backupts
CMD: db2 "select * from details"
ID SEQ ITEM_CODE FLAG DEL_FLG
----------- ----------- --------- ---- -------
1 1 AAAA 0 0
1 2 BBBB 0 0
1 3 CCCC 0 0
2 1 AAAA 0 0
2 2 BBBB 0 0
5 1 AAAA 0 0
5 2 BBBB 0 0
3 1 AAAA 0 0
3 2 BBBB 0 0
9 record(s) selected.
CMD: db2 "select * from master"
ID ITEM_CODE FROM TO EFFECTIVE_STARTDATE
----------- --------- ---- -- -------------------
1 AAAA AA 11 07/10/2010
2 BBBB BB 22 07/10/2010
3 CCCC CC 33 07/10/2010
4 DDDD DD 44 07/10/2010
6。使用db2ckrst工具可以检查恢复的次序。
$ db2ckrst -d backupts -t 20100711004008 -r database
Suggested restore order of images using timestamp 20100711004008 for
database backupts.
====================================================================
restore db backupts incremental taken at 20100711004008
restore db backupts incremental taken at 20100711003519
restore db backupts incremental taken at 20100711003827
restore db backupts incremental taken at 20100711004008
====================================================================
4 record(s) selected.
页:
[1]