Home  >  Article  >  Database  >  DB2在线备份的恢复

DB2在线备份的恢复

WBOY
WBOYOriginal
2016-06-07 15:14:151265browse

简单整理下在线备份的恢复步骤 1. 查找出数据库 db2 list history backup all for xcldb 2. 在数据库没被破坏前,可用db2ckrst命令得到恢复序列,如要恢复的数据库已损坏,则跳过这步. 这个在增量备份恢复时很有用 db2ckrst -d xcldb -t 20131018111438 -r data

           简单整理下在线备份的恢复步骤

1. 查找出数据库

db2 list history backup all for xcldb

2. 在数据库没被破坏前,可用db2ckrst命令得到恢复序列,如要恢复的数据库已损坏,则跳过这步.

  这个在增量备份恢复时很有用

  db2ckrst -d xcldb -t 20131018111438 -r database

 

3.检查并得到备份文件的信息

  db2ckbkp -h C:\db2bk2\XCLDB.0.DB2.NODE0000.CATN0000.20131018111438.001

4.恢复数据库和日志文件

   --采用自动查找方式,使用incremental automatic参数

   db2 restore database xcldb incremental automatic from c:\db2bk2 taken at 20131018111438 logtarget C:\DB2\NODE0000\SQL00001\SQLOGDIR

 

 --采用手工恢复方式,与自动查找恢复差别就是命令没有automatic参数,需要一个个依次来恢复每个镜像. 这种方式与Oracle的增差量恢复一对比.相当的有趣. 不想详细列了,

   大概恢复顺序如下:

   Incremental : 全备 -> 增量1 -> 全备

   Detal : 差量2 -> 全备 -> 差量1 -> 差量2

5. 前滚(rollforward)

    restore 执行完后,你连接数据库会发现,还处于ROLL-FORWARD状态.

    --查出数据库当前状态

    db2 rollforward db xcldb query status

    --再通过查备份,确定下日志文件的路径

    db2 list history backup all for xcldb

   --把备份后的归档日志复制到数据库的目录下

    cp .. /日志目录/

    --前滚

   -- 指定日志所在目录

   -- db2 rollforward db xcldb to end of logs and complete overflow log path (/db2bak/logs)

   --日志原目录(推荐用这种)

    db2 rollforward db xcldb to end of logs and stop

     

  --结束ROLL-FORWARD状态.数据库变为normal状态

  db2 rollforward db xcldb complete 或 db2 rollforward db xcldb stop

   

 --参数说明:

  logs and stop : 表示期望恢复到最后一个日志文件结束,也就是数据库损坏前的那一个时刻.

小技巧:

    --查看恢复进度

    db2 list utilities show detail


MAIL:xcl_168@aliyun.com

Blog: http://blog.csdn.net/xcl168


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn