清理DB2的归档日志
DB2归档日志的相关信息保存在恢复历史文件中,可以通过 db2 list history 命令查看。
db2inst1@suse-db:~> db2 list history archive log all for ggyy
List History File for ggyy
Number of matching file entries = 6
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
X D 20100103235553 1 D S0000038.LOG C0000007
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Comment:
Start Time: 20100103235553
End Time: 20100103235553
Status: A www.zzzyk.com
----------------------------------------------------------------------------
EID: 80 Location: /data/palog/db2inst1/GGYY/NODE0000/C0000007/S0000038.LOG
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
X D 20100103235553 N S0000038.LOG
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Comment: ARCHIVE LOG
Start Time: 20100103235553
End Time: 20100103235553
Status: A
----------------------------------------------------------------------------
EID: 81
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
X D 20100103235608 1 D S0000039.LOG C0000007
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Comment:
Start Time: 20100103235608
End Time: 20100103235608
Status: A
----------------------------------------------------------------------------
EID: 82 Location: /data/palog/db2inst1/GGYY/NODE0000/C0000007/S0000039.LOG
......
清除这些信息,需要使用 db2 prune history 命令。该命令会清除指定时间戳及之前的所有条目(不只是归档日志的)。默认情况下,系统不会清除最近一次数据库全备之后的归档日志信息。
db2inst1@suse-db:~> db2 prune history 20100103235553
SQL1024N A database connection does not exist. SQLSTATE=00000
db2inst1@suse-db:~> db2 connect to ggyy www.zzzyk.com
Database Connection Information
Database server = DB2/LINUX 9.7.0
SQL authorization ID = DB2INST1
Local database alias = GGYY
db2inst1@suse-db:~> db2 prune history 20100103235553
DB20000I The PRUNE command completed successfully.
db2inst1@suse-db:~> db2 list history archive log all for ggyy | head -20
List History File for ggyy
Number of matching file entries = 6
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
X D 20100103235553 1 D S0000038.LOG C0000007
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Comment:
Start Time: 20100103235553
End Time: 20100103235553
Status: A
----------------------------------------------------------------------------
EID: 80 Location: /data/palog/db2inst1/GGYY/NODE0000/C0000007/S0000038.LOG
db2inst1@suse-db:~> db2 list history backup all for ggyy
List History File for ggyy
Number of matching file entries = 0
对数据库进行一次全备,再次尝试清除:
db2inst1@suse-db:~> db2 backup db ggyy online to /data/backup
Backup successful. The timestamp for this backup image is : 20100104004121
db2inst1@suse-db:~> db2 connect to ggyy www.zzzyk.com
Database Connection Information
Database server = DB2/LINUX 9.7.0
SQL authorization ID = DB2INST1
Local database alias = GGYY
db2inst1@suse-db:~> db2 prune history 20100103235553
DB20000I The PRUNE command completed successfully.
db2inst1@suse-db:~> db2 list history archive log all for ggyy | head -20
List History File for ggyy
Number of matching file entries = 5
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
X D 20100103235608 1 D S0000039.LOG C0000007
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Comment:
Start Time: 20100103235608
End Time: 20100103235608
Status: A
----------------------------------------------------------------------------
EID: 82 Location: /data/palog/db2inst1/GGYY/NODE0000/C0000007/S0000039.LOG
通过使用 and delete 参数,可以在清理条目的同时删除对应的归档日志文件。
db2inst1@suse-db:~> ls -l /data/palog/db2inst1/GGYY/NODE0000/C0000007
total 48
-rw-r----- 1 db2inst1 db2iadm1 12288 2010-01-03 23:55 S0000038.LOG
-rw-r----- 1 db2inst1 db2iadm1 12288 2010-01-03 23:56 S0000039.LOG
-rw-r----- 1 db2inst1 db2iadm1 12288 2010-01-03 23:56 S0000040.LOG
-rw-r----- 1 db2inst1 db2iadm1 12288 2010-01-04 00:41 S0000041.LOG
db2inst1@suse-db:~> db2 prune history 20100103235608 and delete
DB20000I The PRUNE command completed successfully. www.zzzyk.com
db2inst1@suse-db:~> db2 list history archive log all for ggyy | head -20
List History File for ggyy
Number of matching file entries = 3
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
X D 20100103235618 1 D S0000040.LOG C0000007
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Comment:
上一个:利用DB2控制中心还原数据库[图解]
下一个:DB2-改变日期格式
- 更多DB2疑问解答:
- sql语句 从DB2移动到其他数据库
- DB2 character类型更新报错
- db2 怎么查看执行的sql语句需要多少系统临时表空间?
- db2数据库的table表里,一money字段中的数据显示为:56000,00 本人想要用sql语句将它修改为56,000,000
- DB2导出表结构,能不能只导出指定的表结构。求大神指教,给出命令哈
- DB2数据库,增加数据表空间容量需要重启数据库吗?
- cognos连接db2,为什么启动不了服务啊, 连接Oracle可以启动服务。。
- PostgreSQL对比DB2
- db2如何查看编写好的存储过程?
- db2数值截取
- 谁知道关于DB2怎么看系统日志,归档日志的位置。并且怎么修改日志呢?
- db2怎样重组表结构?
- 求一本【牛新庄的DB2运维教程】?
- db2 的 SECADM权限 是干什么的
- DB2怎么删除表空间所以数据