单独备份恢复表空间来恢复数据库

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



  

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/11795524/viewspace-405469/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/11795524/viewspace-405469/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值