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 S0000038LOG C0000007
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Comment:
Start Time: 20100103235553
End Time: 20100103235553
Status: A
----------------------------------------------------------------------------
EID: 80 Location: /data/palog/db2inst1/GGYY/NODE0000/C0000007/S0000038LOG
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
X D 20100103235553 N S0000038LOG
----------------------------------------------------------------------------
----------------------------------------------------------------------------
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 S0000039LOG C0000007
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Comment:
Start Time: 20100103235608
End Time: 20100103235608
Status: A
----------------------------------------------------------------------------
EID: 82 Location: /data/palog/db2inst1/GGYY/NODE0000/C0000007/S0000039LOG
清除这些信息,需要使用 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
Database Connection Information
Database server = DB2/LINUX 970
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 S0000038LOG C0000007
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Comment:
Start Time: 20100103235553
End Time: 20100103235553
Status: A
----------------------------------------------------------------------------
EID: 80 Location: /data/palog/db2inst1/GGYY/NODE0000/C0000007/S0000038LOG
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
Database Connection Information
Database server = DB2/LINUX 970
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 S0000039LOG C0000007
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Comment:
Start Time: 20100103235608
End Time: 20100103235608
Status: A
----------------------------------------------------------------------------
EID: 82 Location: /data/palog/db2inst1/GGYY/NODE0000/C0000007/S0000039LOG
通过使用 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 S0000038LOG
-rw-r----- 1 db2inst1 db2iadm1 12288 2010-01-03 23:56 S0000039LOG
-rw-r----- 1 db2inst1 db2iadm1 12288 2010-01-03 23:56 S0000040LOG
-rw-r----- 1 db2inst1 db2iadm1 12288 2010-01-04 00:41 S0000041LOG
db2inst1@suse-db:~> db2 prune history 20100103235608 and delete
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 = 3
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
X D 20100103235618 1 D S0000040LOG C0000007
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Comment:
Start Time: 20100103235618
End Time: 20100103235618
Status: A
----------------------------------------------------------------------------
EID: 84 Location: /data/palog/db2inst1/GGYY/NODE0000/C0000007/S0000040LOG
db2inst1@suse-db:~> ls -l /data/palog/db2inst1/GGYY/NODE0000/C0000007
total 36
-rw-r----- 1 db2inst1 db2iadm1 12288 2010-01-03 23:55 S0000038LOG
-rw-r----- 1 db2inst1 db2iadm1 12288 2010-01-03 23:56 S0000040LOG
-rw-r----- 1 db2inst1 db2iadm1 12288 2010-01-04 00:41 S0000041LOG
可以看到,归档日志文件S0000039LOG已被删除,但S0000038LOG还存在,因为之前已经清除了S0000038LOG的相关条目。
尝试同时清除S0000040LOG和S0000041LOG:
db2inst1@suse-db:~> db2 list history archive log all for ggyy | tail -15
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
X D 20100104004127 1 D S0000041LOG C0000007
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Comment:
Start Time: 20100104004127
End Time: 20100104004128
Status: A
----------------------------------------------------------------------------
EID: 86 Location: /data/palog/db2inst1/GGYY/NODE0000/C0000007/S0000041LOG
db2inst1@suse-db:~> db2 prune history 20100104004127 and delete
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 = 1
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
X D 20100104004127 1 D S0000041LOG C0000007
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Comment:
Start Time: 20100104004127
End Time: 20100104004128
Status: A
----------------------------------------------------------------------------
EID: 86 Location: /data/palog/db2inst1/GGYY/NODE0000/C0000007/S0000041LOG
db2inst1@suse-db:~> ls -l /data/palog/db2inst1/GGYY/NODE0000/C0000007/
total 24
-rw-r----- 1 db2inst1 db2iadm1 12288 2010-01-03 23:55 S0000038LOG
-rw-r----- 1 db2inst1 db2iadm1 12288 2010-01-04 00:41 S0000041LOG
S0000041LOG依然存在,因为它是全备之后生成的。如果想要强制清除,可以使用 with force option 参数。
db2inst1@suse-db:~> db2 prune history 20100104004127 with force option and delete
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 = 0
db2inst1@suse-db:~> ls -l /data/palog/db2inst1/GGYY/NODE0000/C0000007/
total 12
-rw-r----- 1 db2inst1 db2iadm1 12288 2010-01-03 23:55 S0000038LOG
注意,这里连带着将数据库全备的条目也删除了,但备份文件还在:
db2inst1@suse-db:/data/backup> db2 list history backup all for ggyy
List History File for ggyy
Number of matching file entries = 0
db2inst1@suse-db:/data/backup> ls -l /data/backup
total 99994
-rw------- 1 db2inst1 db2iadm1 102293504 2010-01-04 00:41 GGYY0db2inst1NODE0000CATN000020100104004121001
此外,使用 db2 prune logfile 命令可以清除活动日志目录下的在线归档日志文件,但对离线归档日志文件无效,这里不再赘述。通文件查看记录关DB2数据库详细错误信息文件断增需要定期进行清理 通查看实例配置参数DIAGPATH确定db2diaglog文件放哪目录:db2 get dbm cfg Diagnostic data directory path(DIAGPATH) = /home/db2inst1/sqllib/db2dump则文件放/home/db2inst1/sqllib/db2dump目录文件系统/home使用率达80%-90%左右应及删除db2diaglog文件 请按确步骤 *** 作: 确认应用、DB2已经停止 原db2diaglog文件备份其文件系统 删除db2diaglog文件删除DB2自创建新文件
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)