DB2中自动清理数据库历史文件
2016-02-16 18:00
519 查看
DB2可以做到自动清除历史文件,有关详细介绍请参考
http://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.admin.ha.doc/doc/t0051348.html?cp=SSEPGG_9.7.0&lang=en
这里只举一个例子:
C:\windows\system32>db2 update db cfg for sample using rec_his_retentn 1
C:\windows\system32>db2 update db cfg for sample using NUM_DB_BACKUPS 1
//重新激活数据库
C:\windows\system32>db2 list history all for db sample
List History File for sample
Number of matching file entries = 0
测试1.) 备份次数超过NUM_DB_BACKUPS,但时间上未达到rec_his_retentn,不会发生自动prune
C:\windows\system32>db2 "alter tablespace userspace1 rebalance"
C:\windows\system32>db2 "reorg table t1"
C:\windows\system32>db2 "backup db sample online"
Backup successful. The timestamp for this backup image is :
20151023133140
C:\windows\system32>db2 "load from t1.del of del insert into t1"
C:\windows\system32>db2 "backup db sample online"
Backup successful. The timestamp for this backup image is :
20151023133319
C:\windows\system32>db2 list history all for db sample
List History File for sample
Number of matching file entries = 5 <-NUM_DB_BACKUPS 达到要求, 但rec_his_retentn没有达到要求,没有prune
..
测试2.)1天之后,观察是否发生了自动prune
C:\windows\system32>db2 list history all for db sample
List History File for sample
Number of matching file entries = 5 <--rec_his_retentn 和 NUM_DB_BACKUPS 都达到要求, 但没有 backup 操作. 没有发生prune
测试3.)再次发出backup命令,这次的backup命令触发了之前的历史文件条目被删除
C:\windows\system32>db2 "reorg table employee"
DB20000I The REORG command completed successfully.
C:\windows\system32>db2 backup db sample online
Backup successful. The timestamp for this backup image is :
20151024134000
C:\windows\system32>db2 list history all for db sample
List History File for sample
Number of matching file entries = 2 <--已经被自动prune
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------
--------------
G T 20151024133939 F S0000530.LOG S0000530.LOG
-----------------------------------------------------------------------
-----
Table: "MIAOQINGSONG"."EMPLOYEE"
-----------------------------------------------------------------------
-----
Comment: REORG
Start Time: 20151024133939
End Time: 20151024133939
Status: A
-----------------------------------------------------------------------
-----
EID: 90
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------
--------------
B D 20151024134000001 N D S0000531.LOG S0000531.LOG
-----------------------------------------------------------------------
-----
Contains 3 tablespace(s):
00001 SYSCATSPACE
00002 USERSPACE1
00003 SYSTOOLSPACE
-----------------------------------------------------------------------
-----
Comment: DB2 BACKUP SAMPLE ONLINE
Start Time: 20151024134000
End Time: 20151024134007
Status: A
-----------------------------------------------------------------------
-----
EID: 91 Location: C:\windows\system32
这里需要注意一点:
No matter how small the retention period, the most recent full database backup plus its restore set is always kept, unless you use the PRUNEcommand with the FORCE option.
http://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.admin.ha.doc/doc/t0051348.html?cp=SSEPGG_9.7.0&lang=en
这里只举一个例子:
C:\windows\system32>db2 update db cfg for sample using rec_his_retentn 1
C:\windows\system32>db2 update db cfg for sample using NUM_DB_BACKUPS 1
//重新激活数据库
C:\windows\system32>db2 list history all for db sample
List History File for sample
Number of matching file entries = 0
测试1.) 备份次数超过NUM_DB_BACKUPS,但时间上未达到rec_his_retentn,不会发生自动prune
C:\windows\system32>db2 "alter tablespace userspace1 rebalance"
C:\windows\system32>db2 "reorg table t1"
C:\windows\system32>db2 "backup db sample online"
Backup successful. The timestamp for this backup image is :
20151023133140
C:\windows\system32>db2 "load from t1.del of del insert into t1"
C:\windows\system32>db2 "backup db sample online"
Backup successful. The timestamp for this backup image is :
20151023133319
C:\windows\system32>db2 list history all for db sample
List History File for sample
Number of matching file entries = 5 <-NUM_DB_BACKUPS 达到要求, 但rec_his_retentn没有达到要求,没有prune
..
测试2.)1天之后,观察是否发生了自动prune
C:\windows\system32>db2 list history all for db sample
List History File for sample
Number of matching file entries = 5 <--rec_his_retentn 和 NUM_DB_BACKUPS 都达到要求, 但没有 backup 操作. 没有发生prune
测试3.)再次发出backup命令,这次的backup命令触发了之前的历史文件条目被删除
C:\windows\system32>db2 "reorg table employee"
DB20000I The REORG command completed successfully.
C:\windows\system32>db2 backup db sample online
Backup successful. The timestamp for this backup image is :
20151024134000
C:\windows\system32>db2 list history all for db sample
List History File for sample
Number of matching file entries = 2 <--已经被自动prune
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------
--------------
G T 20151024133939 F S0000530.LOG S0000530.LOG
-----------------------------------------------------------------------
-----
Table: "MIAOQINGSONG"."EMPLOYEE"
-----------------------------------------------------------------------
-----
Comment: REORG
Start Time: 20151024133939
End Time: 20151024133939
Status: A
-----------------------------------------------------------------------
-----
EID: 90
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------
--------------
B D 20151024134000001 N D S0000531.LOG S0000531.LOG
-----------------------------------------------------------------------
-----
Contains 3 tablespace(s):
00001 SYSCATSPACE
00002 USERSPACE1
00003 SYSTOOLSPACE
-----------------------------------------------------------------------
-----
Comment: DB2 BACKUP SAMPLE ONLINE
Start Time: 20151024134000
End Time: 20151024134007
Status: A
-----------------------------------------------------------------------
-----
EID: 91 Location: C:\windows\system32
这里需要注意一点:
No matter how small the retention period, the most recent full database backup plus its restore set is always kept, unless you use the PRUNEcommand with the FORCE option.
相关文章推荐
- DB2 自动递增字段实现方法
- 创建一个空的IBM DB2 ECO数据库的方法
- DB2中REVERSE函数的实现方法
- IBM DB2 Connect简介(1)
- DB2 日期和时间的函数应用说明
- DB2 常用命令速查(备忘)
- DB2 常用命令小结
- DB2比较常用与实用sql语句总结
- db2 导入导出单个表的操作详解
- DB2新手使用的一些小笔记:新建实例、数据库路径不存在、客户端连接 .
- CentOS下DB2数据库安装过程详解
- 比较SQL Server与Oracle、DB2
- db2数据库常用操作命令大全
- DB2 信息中心及学习地
- DB2 基础: 使用 DB2 数据移动实用工具中的文件类型修饰符
- linux db2安装及卸载
- Oracle和DB2的区别
- Oracle中关于PCTFREE和PCTUSED的说明
- 解密DB2独步江湖之五大法宝
- DB2优化