利用TSM 恢复 DB2数据库
关于使用TSM恢复DB2数据库的思考
由于用户在使用过程中发现文件系统使用率超过99%,以为是垃圾文件太多,然后重启系统,结果业务无法启动,他们怀疑是db2归档日志没有被备走,但是我是做了归档日志调度备走的。在初步的解决办法无效后,决定进行数据库恢复
1、 查看可用的备份版本:
jdbwdev:db2bwd 26> db2adutl query db bwd
Query for database BWD
Retrieving FULL DATABASE BACKUP information.
1 Time: 20110417003004 Oldest log: S0014956.LOG DB Partition Number: 0 Sessions: 1
2 Time: 20110416000001 Oldest log: S0014948.LOG DB Partition Number: 0 Sessions: 1
3 Time: 20110410003004 Oldest log: S0014884.LOG DB Partition Number: 0 Sessions: 1
4 Time: 20110403003004 Oldest log: S0014838.LOG DB Partition Number: 0 Sessions: 1
5 Time: 20110402000001 Oldest log: S0014826.LOG DB Partition Number: 0 Sessions: 1
6 Time: 20110327003006 Oldest log: S0014430.LOG DB Partition Number: 0 Sessions: 1
7 Time: 20110320003005 Oldest log: S0014393.LOG DB Partition Number: 0 Sessions: 1
8 Time: 20110319000001 Oldest log: S0014386.LOG DB Partition Number: 0 Sessions: 1
9 Time: 20110313003005 Oldest log: S0014333.LOG DB Partition Number: 0 Sessions: 1
10 Time: 20110312011002 Oldest log: S0014327.LOG DB Partition Number: 0 Sessions: 1
11 Time: 20110301011001 Oldest log: S0014279.LOG DB Partition Number: 0 Sessions: 1
12 Time: 20110227053247 Oldest log: S0014276.LOG DB Partition Number: 0 Sessions: 1
Retrieving INCREMENTAL DATABASE BACKUP information.
1 Time: 20110419000001 Oldest log: S0014979.LOG DB Partition Number: 0 Sessions: 1
2 Time: 20110412000001 Oldest log: S0014897.LOG DB Partition Number: 0 Sessions: 1
3 Time: 20110405000002 Oldest log: S0014840.LOG DB Partition Number: 0 Sessions: 1
4 Time: 20110331000001 Oldest log: S0014810.LOG DB Partition Number: 0 Sessions: 1
5 Time: 20110329000001 Oldest log: S0014622.LOG DB Partition Number: 0 Sessions: 1
6 Time: 20110322000001 Oldest log: S0014402.LOG DB Partition Number: 0 Sessions: 1
7 Time: 20110315000002 Oldest log: S0014335.LOG DB Partition Number: 0 Sessions: 1
8 Time: 20110310001602 Oldest log: S0014316.LOG DB Partition Number: 0 Sessions: 1
9 Time: 20110302230001 Oldest log: S0014283.LOG DB Partition Number: 0 Sessions: 1
Retrieving DELTA DATABASE BACKUP information.
1 Time: 20110420000002 Oldest log: S0014989.LOG DB Partition Number: 0 Sessions: 1
2 Time: 20110418000001 Oldest log: S0014962.LOG DB Partition Number: 0 Sessions: 1
3 Time: 20110413000002 Oldest log: S0014913.LOG DB Partition Number: 0 Sessions: 1
4 Time: 20110411000001 Oldest log: S0014888.LOG DB Partition Number: 0 Sessions: 1
5 Time: 20110408000001 Oldest log: S0014872.LOG DB Partition Number: 0 Sessions: 1
6 Time: 20110406000001 Oldest log: S0014842.LOG DB Partition Number: 0 Sessions: 1
7 Time: 20110404000001 Oldest log: S0014839.LOG DB Partition Number: 0 Sessions: 1
8 Time: 20110401000002 Oldest log: S0014813.LOG DB Partition Number: 0 Sessions: 1
9 Time: 20110330000001 Oldest log: S0014807.LOG DB Partition Number: 0 Sessions: 1
10 Time: 20110328000001 Oldest log: S0014431.LOG DB Partition Number: 0 Sessions: 1
11 Time: 20110325000001 Oldest log: S0014416.LOG DB Partition Number: 0 Sessions: 1
12 Time: 20110323000001 Oldest log: S0014406.LOG DB Partition Number: 0 Sessions: 1
13 Time: 20110321000002 Oldest log: S0014394.LOG DB Partition Number: 0 Sessions: 1
14 Time: 20110318000001 Oldest log: S0014362.LOG DB Partition Number: 0 Sessions: 1
15 Time: 20110316000002 Oldest log: S0014341.LOG DB Partition Number: 0 Sessions: 1
16 Time: 20110314000001 Oldest log: S0014334.LOG DB Partition Number: 0 Sessions: 1
17 Time: 20110309001602 Oldest log: S0014309.LOG DB Partition Number: 0 Sessions: 1
18 Time: 20110305230001 Oldest log: S0014293.LOG DB Partition Number: 0 Sessions: 1
由于最新的一份备份是delta 类型的在线增量备份。故决定将其恢复至该版本。
1、 使用如下命令检查备份版本的恢复顺序
jdbwdev:db2bwd 40> db2ckrst -d bwd -t 20110420000002 -r database
Suggested restore order of images using timestamp 20110420000002 for
database bwd.
====================================================================
restore db bwd incremental taken at 20110420000002 delta备份
restore db bwd incremental taken at 20110417003004 离线全备份
restore db bwd incremental taken at 20110419000001 在线incremental备份
restore db bwd incremental taken at 20110420000002 delta备份
疑惑: 此处为什么会出来2个一模一样的版本呢?难道是要按照以上的顺序20110420000002—20110417003004—20110419000001---20110420000002
依次恢复?这明显说不过去,因为20110420000002应该在20110417003004之后,故第一个就不用恢复了,所以我是按照20110417003004—20110419000001---20110420000002这个顺序来进行恢复。结果悲剧了
2、 版本依次恢复如下:
jdbwdev:db2bwd 36> db2 restore db bwd use tsm taken at 20110417003004
SQL2539W Warning! Restoring to an existing database that is the same as the
backup image database. The database files will be deleted.
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.
jdbwdev:db2bwd 38> db2 restore db bwd incremental use tsm taken at 20110419000001
SQL2539W Warning! Restoring to an existing database that is the same as the
backup image database. The database files will be deleted.
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.
jdbwdev:db2bwd 39> db2 restore db bwd incremental use tsm taken at 20110420000002
SQL2574N A backup image restored as part of an incremental RESTORE operation
cannot be newer than the target image.
报错了,这是为什么???
备份镜像不能比目标镜像要新?怎么查看目标镜像版本?
由于提示备份的镜像不能比目标更新,所以我又把老版本恢复过去,仍然出错
jdbwdev:db2bwd 41> db2 restore db bwd incremental use tsm taken at 20110419000001
SQL2572N Attempted an incremental restore of an out of order image. The
restore of tablespace "SYSCATSPACE" encountered an error because the backup
image with timestamp "20110417003004" must be restored before the image that
was just attempted.
jdbwdev:db2bwd 42> db2 restore db bwd incremental automatic use tsm taken at 20110420000002
SQL2583N The intended restore command cannot be processed because a previous
incremental restore is still in progress.
作者: tangpeixing 发布时间: 2011-04-22
db2 restore from Tivoli Storage manage 好強,太利害
作者: barrypeter 发布时间: 2011-05-13