mysql 前滚指定时间_DB2关于指定时间点前滚恢复方法 | 学步园

本文详细介绍了如何在DB2数据库中进行指定时间点的前滚恢复操作,包括备份、删除、恢复数据库的步骤,以及如何确定最小恢复时间点并执行前滚命令,确保数据库恢复到正确状态。
摘要由CSDN通过智能技术生成

DB2关于指定时间点前滚恢复方法

1)备份数据库

[db2inst1@bytest ~ 22]$db2 backup db sample online include logs

Backup successful. The timestamp for this backup image is : 20051223120837

[db2inst1@bytest ~ 23]$

(2)删除数据库

[db2inst1@bytest ~ 5]$db2 drop db sample

SQL1035N The database is currently in use. SQLSTATE=57019

[db2inst1@bytest ~ 6]$db2 force application all

DB20000I The FORCE APPLICATION command completed successfully.

DB21024I This command is asynchronous and may not be effective immediately.

[db2inst1@bytest ~ 7]$db2 drop db sample

DB20000I The DROP DATABASE command completed successfully.

[db2inst1@bytest ~ 8]$

(3)恢复数据库

[db2inst1@bytest ~ 27]$db2 restore db sample taken at 20051223120837 logtarget /home/db2inst1/db2log/

DB20000I The RESTORE DATABASE command completed successfully.

[db2inst1@bytest ~ 28]$

(4)查看时间标记

[db2inst1@bytest ~ 28]$db2 list history backup all for db sample

List History File for sample

Number of matching file entries = 3

Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID

-- --- ------------------ ---- --- ------------ ------------ --------------

B D 20051223120655001 F D S0000000.LOG S0000000.LOG

----------------------------------------------------------------------------

Contains 2 tablespace(s):

00001 SYSCATSPACE

00002 USERSPACE1

----------------------------------------------------------------------------

Comment: DB2 BACKUP SAMPLE OFFLINE

Start Time: 20051223120655

End Time: 20051223120731

Status: A

----------------------------------------------------------------------------

EID: 1 Location: /home/db2inst1

Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID

-- --- ------------------ ---- --- ------------ ------------ --------------

B D 20051223120837001 N D S0000000.LOG S0000000.LOG

----------------------------------------------------------------------------

Contains 2 tablespace(s):

00001 SYSCATSPACE

00002 USERSPACE1

----------------------------------------------------------------------------

Comment: DB2 BACKUP SAMPLE ONLINE

Start Time: 20051223120837

End Time: 20051223120902

Status: A

----------------------------------------------------------------------------

EID: 2 Location: /home/db2inst1

Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID

-- --- ------------------ ---- --- ------------ ------------ --------------

R D 20051223121039001 F 20051223120837

----------------------------------------------------------------------------

Contains 2 tablespace(s):

00001 SYSCATSPACE

00002 USERSPACE1

----------------------------------------------------------------------------

Comment: RESTORE SAMPLE WITH RF

Start Time: 20051223121039

End Time: 20051223121113

Status: A

----------------------------------------------------------------------------

EID: 3 Location:

[db2inst1@bytest ~ 29]$

根据时间标记可以在上面列出的信息中找出如下信息:

Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID

-- --- ------------------ ---- --- ------------ ------------ --------------

B D 20051223120837001 N D S0000000.LOG S0000000.LOG

----------------------------------------------------------------------------

Contains 2 tablespace(s):

00001 SYSCATSPACE

00002 USERSPACE1

----------------------------------------------------------------------------

Comment: DB2 BACKUP SAMPLE ONLINE

Start Time: 20051223120837

End Time: 20051223120902

Status: A

----------------------------------------------------------------------------

EID: 2 Location: /home/db2inst1

从这段信息中可以得知备份的开始时间(Start Time: 20051223120837)和结束时间(End Time: 20051223120902)

以及进行前滚所需要的日志(S0000000.LOG),该日志文件已经在/home/db2inst1/db2log/中。

其中,End Time: 20051223120902为备份的结束时间,同时它也是前滚时的最小恢复时间点(PIT),也就是说,

如果按照指定时间点恢复,最小要恢复到这个时间点,如果用提前于这个时间的时间来前滚,将会返回信息提示:

[db2inst1@bytest ~ 31]$db2 ”rollforward db sample to 2005-12-23-12.09.00.000000 using local time and stop overflow log path(/home/db2inst1/db2log/)“

SQL1275N The stoptime passed to roll-forward must be greater than or equal to

"2005-12-23-12.09.02.000000", because database "SAMPLE" on node(s) "0"

contains information later than the specified time.

[db2inst1@bytest ~ 32]$

所以至少要恢复到这个时间点。命令如下:

[db2inst1@bytest ~ 33]$db2 "rollforward db sample to 2005-12-23-12.09.02.000000 using local time and stop overflow log path(/home/db2inst1/db2log/)"

Rollforward Status

Input database alias = sample

Number of nodes have returned status = 1

Node number = 0

Rollforward status = not pending

Next log file to be read =

Log files processed = S0000000.LOG - S0000000.LOG

Last committed transaction = 2005-12-23-12.09.02.000000

DB20000I The ROLLFORWARD command completed successfully.

[db2inst1@bytest ~ 34]$db2 connect to sample

Database Connection Information

Database server = DB2/LINUX 8.2.0

SQL authorization ID = DB2INST1

Local database alias = SAMPLE

[db2inst1@bytest ~ 35]$

此时,数据库是可用状态。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值