暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

DB2 数据库在线备份和恢复的操作步骤

不畏过往不惧将来 2021-04-21
3184

1、数据库在线备份操作命令如下:

DB2 backup db 数据库名 online to 备份路径

例如:db2 backup db tony online to home/db2inst/db2backup

2、数据库恢复操作命令如下:

Db2 restore db 旧数据库名 taken at 时间戳 into 恢复数据库名

例如:要把这个备份的数据库恢复到TONY这个数据库HBJRZL.0.db2inst.DBPART000.20160619201225.001

db2 restore db HBJRZL taken at 20160619201225 into TONY

备注:还原数据库时如果数据库名相同可以把into TONY省略不写

3、如果执行恢复数据库命令时出现如下提示:

http://www.ibm.com/developerworks/cn/data/library/techarticle/dm-1011db2purescalefeature/

SQL1117N  A connection to or activation of database "TONY" cannot be made

because of ROLL-FORWARD PENDING.  SQLSTATE=57019

4、执行以下命令:

db2 rollforward db tonydev to end of logs and complete

5、如果执行第4步,没有成功,出现以下提示:则执行第6步

SQL1273N  An operation reading the logs on database "TONY" cannot continue

because of a missing log file "S0000020.LOG" on database partition "0" and log

stream "0".

6、获取 db2数据库管理配置环境信息

db2 get db cfg for 数据库名

例如:db2 get db cfg for TONY

 

7、执行第6步出现如下信息:

Database Configuration for Database tony

Database configuration release level                    = 0x0f00

……..........(其他内容省略)

Changed path to log files                  (NEWLOGPATH) =

 Path to log files      /home/db2inst/db2inst/NODE0000/SQL00001/LOGSTREAM0000/                                  

 Overflow log path                     (OVERFLOWLOGPATH) =

 Mirror log path                         (MIRRORLOGPATH) =

 First active log file                        = S0000020.LOG

 Block log on disk full                (BLK_LOG_DSK_FUL) = NO

 ………….. (其他内容省略)

8、找到S0000020.LOG (此日志文件根据查询出来的日志文件为准)这个日志文件,然后把此日志文件在备份的那个数据库服务器下载下来,然后上传到需要备份的数据库服务器所对应的目录下,如

/home/db2inst/db2inst/NODE0000/SQL00001/LOGSTREAM0000/

最后再次执行以下命令即可完成本次数据库恢复操作

  db2 rollforward db tony to end of logs and complete


使用如下命令监控备份进度:
[db2inst1@db db2data]$ db2 list utilities show detail
ID                               = 2
Type                             = BACKUP
Database Name                    = TEST
Partition Number                 = 0
Description                      = offline db 
Start Time                       = 10/17/2017 22:54:37.300623
State                            = Executing
Invocation Type                  = User
Throttling:
   Priority                      = Unthrottled
Progress Monitoring:
   Estimated Percentage Complete = 51
      Total Work                 = 17150073271 bytes
      Completed Work             = 8759459743 bytes
      Start Time                 = 10/17/2017 22:54:37.300638

链接:

https://blog.csdn.net/lk_db/article/details/78284755

https://blog.csdn.net/tony7706/article/details/70199191


文章转载自不畏过往不惧将来,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论