http://www.ibm.com/developerworks/cn/db2/library/techarticles/dm-0802zhangy/index.html
前提:日志的模式必须是归档日志而且必须存在所有需要的日志
* TEST.3.DB2.NODE0000.CATN0000.20060515135047.001 - SYSCATSPACE 和 USERSPACE 1 表空间在 2006051513504 7 时间点的备份;
* TEST.3.DB2.NODE0000.CATN0000.20060516135136.001 - USERSPACE 2 和 USERSPACE 3 表空间在 2006051613513 6 时间点的备份;
* TEST.3.DB2.NODE0000.CATN0000.20060517135208.001 - USERSPACE 3 表空间在 2006051713520 8 时间点的备份。
1.利用 DB2 表空间的备份来快速恢复数据库,甚至可以根据数据的重要性选择恢复一部分重要数据,达到快速恢复的目的。
2.利用一个表空间进行整库恢复步骤:
第一步,我们利用表空间备份执行带 REBUILD 选项的 RESTORE DATABASE 命令恢复数据库。
db2 restore db test rebuild with all tablespaces in database taken at 20060517135208
第二步,通过 ROLLFORWARD DATABASE 命令及 TO END OF LOGS 选项来前滚数据库 TEST,使其恢复到最近的一个同步时间点 (Point in Time)。
db2 rollforward db test to end of logs
第三步,通过执行 ROLLFORWARD DATABASE 命令来结束数据库前滚的状态。
db2 rollforward db test stop
3.暂时只恢复单独的表空间步骤:
db2 restore db test rebuild with tablespace (SYSCATSPACE,USERSPACE1,USERSPACE2)
taken at 20060516135136
db2 rollforward db test to end of logs
db2 rollforward db test stop
4.为了使用这个很好的特性,数据库的日志和 SYSCATSPACE 系统表空间的备份仍然是至关重要不可缺少的。
详细实施步骤:
D:\tbps>db2level
DB21085I Instance "DB2" uses "32" bits and DB2 code release "SQL09010" with level identifier "02010107".
Informational tokens are "DB2 v9.1.0.356", "s060629", "NT32", and Fix Pack "0".
Product is installed at "C:\PROGRA~1\IBM\SQLLIB" with DB2 Copy Name "DB2COPY1".
一、创建测试数据库 test
D:\tbps>db2 "create db test on d:"
二、创建表空间
D:\tbps>db2 connect to test
D:\tbps>db2 "create tablespace userspace2 managed by database using (file 'd:\tbps\tbps2' 1000) "
D:\tbps>db2 "create tablespace userspace3 managed by database using (file 'd:\tbps\tbps3' 1000) "
三、修改 LOGARCHMETH1 使数据库处于归档模式
D:\tbps>db2 update db cfg using LOGARCHMETH1 disk:d:\tbps
四、脱机备份数据库
D:\tbps>db2 backup db test //因为修改了上面的参数,数据库必须进行备份才能进行下面的步骤^_^
五、分别单独备份表空间
D:\tbps>db2 "BACKUP DATABASE test" TABLESPACE syscatspace to 'd:\tbps\'
D:\tbps>db2 "BACKUP DATABASE test" TABLESPACE userspace1 to 'd:\tbps\'
D:\tbps>db2 "BACKUP DATABASE test" TABLESPACE userspace2 to 'd:\tbps\'
D:\tbps>db2 "BACKUP DATABASE test" TABLESPACE userspace3 to 'd:\tbps\'
=========================================================================================
D:\>db2 backup db test
Backup successful. The timestamp for this backup image is : 20070406031059
D:\>db2 "BACKUP DATABASE test" TABLESPACE syscatspace to 'd:\tbps\'
Backup successful. The timestamp for this backup image is : 20070406031106
D:\>db2 "BACKUP DATABASE test" TABLESPACE userspace1 to 'd:\tbps\'
Backup successful. The timestamp for this backup image is : 20070406031111
D:\>db2 "BACKUP DATABASE test" TABLESPACE userspace2 to 'd:\tbps\'
Backup successful. The timestamp for this backup image is : 20070406031116
D:\>db2 "BACKUP DATABASE test" TABLESPACE userspace3 to 'd:\tbps\'
Backup successful. The timestamp for this backup image is : 20070406031149
=========================================================================================
D:\tbps>db2 restore db test rebuild with all tablespaces in database taken at 20070406031149
D:\tbps>db2 rollforward db test to end of logs
D:\tbps>db2 rollforward db test stop
D:\tbps>db2 connect to test
Database Connection Information
Database server = DB2/NT 9.1.0
SQL authorization ID = ERIC_XU
Local database alias = TEST
前提:日志的模式必须是归档日志而且必须存在所有需要的日志
* TEST.3.DB2.NODE0000.CATN0000.20060515135047.001 - SYSCATSPACE 和 USERSPACE 1 表空间在 2006051513504 7 时间点的备份;
* TEST.3.DB2.NODE0000.CATN0000.20060516135136.001 - USERSPACE 2 和 USERSPACE 3 表空间在 2006051613513 6 时间点的备份;
* TEST.3.DB2.NODE0000.CATN0000.20060517135208.001 - USERSPACE 3 表空间在 2006051713520 8 时间点的备份。
1.利用 DB2 表空间的备份来快速恢复数据库,甚至可以根据数据的重要性选择恢复一部分重要数据,达到快速恢复的目的。
2.利用一个表空间进行整库恢复步骤:
第一步,我们利用表空间备份执行带 REBUILD 选项的 RESTORE DATABASE 命令恢复数据库。
db2 restore db test rebuild with all tablespaces in database taken at 20060517135208
第二步,通过 ROLLFORWARD DATABASE 命令及 TO END OF LOGS 选项来前滚数据库 TEST,使其恢复到最近的一个同步时间点 (Point in Time)。
db2 rollforward db test to end of logs
第三步,通过执行 ROLLFORWARD DATABASE 命令来结束数据库前滚的状态。
db2 rollforward db test stop
3.暂时只恢复单独的表空间步骤:
db2 restore db test rebuild with tablespace (SYSCATSPACE,USERSPACE1,USERSPACE2)
taken at 20060516135136
db2 rollforward db test to end of logs
db2 rollforward db test stop
4.为了使用这个很好的特性,数据库的日志和 SYSCATSPACE 系统表空间的备份仍然是至关重要不可缺少的。
详细实施步骤:
D:\tbps>db2level
DB21085I Instance "DB2" uses "32" bits and DB2 code release "SQL09010" with level identifier "02010107".
Informational tokens are "DB2 v9.1.0.356", "s060629", "NT32", and Fix Pack "0".
Product is installed at "C:\PROGRA~1\IBM\SQLLIB" with DB2 Copy Name "DB2COPY1".
一、创建测试数据库 test
D:\tbps>db2 "create db test on d:"
二、创建表空间
D:\tbps>db2 connect to test
D:\tbps>db2 "create tablespace userspace2 managed by database using (file 'd:\tbps\tbps2' 1000) "
D:\tbps>db2 "create tablespace userspace3 managed by database using (file 'd:\tbps\tbps3' 1000) "
三、修改 LOGARCHMETH1 使数据库处于归档模式
D:\tbps>db2 update db cfg using LOGARCHMETH1 disk:d:\tbps
四、脱机备份数据库
D:\tbps>db2 backup db test //因为修改了上面的参数,数据库必须进行备份才能进行下面的步骤^_^
五、分别单独备份表空间
D:\tbps>db2 "BACKUP DATABASE test" TABLESPACE syscatspace to 'd:\tbps\'
D:\tbps>db2 "BACKUP DATABASE test" TABLESPACE userspace1 to 'd:\tbps\'
D:\tbps>db2 "BACKUP DATABASE test" TABLESPACE userspace2 to 'd:\tbps\'
D:\tbps>db2 "BACKUP DATABASE test" TABLESPACE userspace3 to 'd:\tbps\'
=========================================================================================
D:\>db2 backup db test
Backup successful. The timestamp for this backup image is : 20070406031059
D:\>db2 "BACKUP DATABASE test" TABLESPACE syscatspace to 'd:\tbps\'
Backup successful. The timestamp for this backup image is : 20070406031106
D:\>db2 "BACKUP DATABASE test" TABLESPACE userspace1 to 'd:\tbps\'
Backup successful. The timestamp for this backup image is : 20070406031111
D:\>db2 "BACKUP DATABASE test" TABLESPACE userspace2 to 'd:\tbps\'
Backup successful. The timestamp for this backup image is : 20070406031116
D:\>db2 "BACKUP DATABASE test" TABLESPACE userspace3 to 'd:\tbps\'
Backup successful. The timestamp for this backup image is : 20070406031149
=========================================================================================
D:\tbps>db2 restore db test rebuild with all tablespaces in database taken at 20070406031149
D:\tbps>db2 rollforward db test to end of logs
D:\tbps>db2 rollforward db test stop
D:\tbps>db2 connect to test
Database Connection Information
Database server = DB2/NT 9.1.0
SQL authorization ID = ERIC_XU
Local database alias = TEST
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/11795524/viewspace-405469/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/11795524/viewspace-405469/