前提数据库以安装完成,并创建好sample库
1、开始数据库归档模式
db2 connect to sample;
db2 update db cfg using logarchmeth1 disk:/opt/dbbak/arch
DISK:/tmp/db2exe/guidan/
2、需先冷备在执行现在备份;
db2 backup db sample to /tmp/db2exe/db2backup
db2 backup db sample online to /tmp/db2exe/db2backup compress include logs
3、数据库还原
db2 restore db sample from /tmp/db2exe/db2backup taken at 20200913234400;
db2 rollforward db sample to end of logs and complete
报错:SQL4970N Rollforward recovery stopped on the database named "SAMPLE" because
the rollforward utility cannot reach the specified stop point (end-of-log or
point-in-time) on the following database partitions: "0".
解决方案:
在主机上解压logs日志
db2 restore db sample logs from /tmp/db2exe/db2backup taken at 20200914103746 logtarget /tmp/db2exe/db2backup
得到日志文件
把备份文件和日志文件拷贝到备机
在备机上查看备份文件
db2ckbkp -h SAMPLE.0.db2assp.DBPART000.20200914103746.001
主机上拷贝过来的日志文件放到此文件下相应的目录
然后执行数据库恢复命令
db2 restore db sample from /tmp/db2exe/db2backup taken at 20200913234400;
db2 rollforward db sample to end of logs and complete
SQL1261N Database "sample" is not in rollforward pending state on node(s) "0",so it does not need to be rolled forward on these nodes.(正常)
db2 connect to sample
连接成功
另一种方式,指定活动日志位置
db2 backup database asspdb online to /assp/dbbk/bak/ compress include logs
db2 restore database asspdb from /assp/dbbk/bak to /assp/db REPLACE EXISTING;
db2 restore db asspdb logs from /assp/dbbk/bak logtarget /assp/dbbk/bak;
db2 rollforward db asspdb to end of backup and complete overflow log path \(/assp/dbbk/bak\)
网友评论