达梦的参数ARCH_RESERVE_TIME测试
前面有提到和oracle相比,达梦的归档日志相关参数有个比较特别,可以通过设置它去规定归档日志的保留时间。
ARCH_RESERVE_TIME:归档日志保留时间,单位分钟,取值范围 0~2147483647。只对本地归档有效。服务器每隔 5 分钟检查是否存在超过保留时间的归档并删除。缺省为 0,表示不删除归档。
基础环境
OS版本:
Red Hat Enterprise Linux Server release 7.9 (Maipo)
DB版本:
DM Database Server 64 V8
DB Version: 0x7000c
03134284132-20240115-215128-20081
1 测试环境准备
当前数据库已经开启归档模式,归档路径为/dm8/arch,该路径下已经有照相日志生成。
[dmdba@test arch]$ disql sysdba/Dameng123服务器[LOCALHOST:5236]:处于普通打开状态
登录使用时间 : 3.452(ms)
disql V8
SQL> select name,status$,arch_mode from v$database;行号 NAME STATUS$ ARCH_MODE
---------- ------ ----------- ---------
1 DAMENG 4 Y已用时间: 0.222(毫秒). 执行号:1401.
SQL> select ARCH_NAME,ARCH_TYPE,ARCH_DEST,ARCH_FILE_SIZE,ARCH_RESERVE_TIME from v$dm_arch_ini;行号 ARCH_NAME ARCH_TYPE ARCH_DEST ARCH_FILE_SIZE ARCH_RESERVE_TIME
---------- -------------- --------- --------- -------------- -----------------
1 ARCHIVE_LOCAL1 LOCAL /dm8/arch 64 0已用时间: 0.221(毫秒). 执行号:1402.[dmdba@test arch]$ pwd
/dm8/arch
[dmdba@test arch]$ ll
total 65552
-rw-r--r-- 1 dmdba dinstall 16384 Apr 8 19:42 ARCHIVE_LOCAL1_0x59BEDBAC_EP0_2024-04-08_19-41-20.log
-rw-r--r-- 1 dmdba dinstall 67108864 Apr 8 19:45 ARCHIVE_LOCAL1_0x59BEDBAC_EP0_2024-04-08_19-43-15.log
2 设置参数ARCH_RESERVE_TIME
修改dmarch.ini配置文件,添加ARCH_RESERVE_TIME = 5,并重启数据库。
--修改配置文件
vi dmarch.ini
[ARCHIVE_LOCAL1]ARCH_TYPE = LOCALARCH_DEST = /dm8/archARCH_FILE_SIZE = 64ARCH_SPACE_LIMIT = 0ARCH_FLUSH_BUF_SIZE = 0ARCH_HANG_FLAG = 1ARCH_RESERVE_TIME = 5--重启数据库
[dmdba@test arch]$ DmServiceDMSERVER restart
Stopping DmServiceDMSERVER: [ OK ]
Starting DmServiceDMSERVER: [ OK ]
[dmdba@test arch]$ disql sysdba/Dameng123 服务器[LOCALHOST:5236]:处于普通打开状态
登录使用时间 : 5.708(ms)
disql V8
SQL> select ARCH_NAME,ARCH_RESERVE_TIME from v$dm_arch_ini;行号 ARCH_NAME ARCH_RESERVE_TIME
---------- -------------- -----------------
1 ARCHIVE_LOCAL1 5已用时间: 1.386(毫秒). 执行号:501.
观察归档日志,发现归档日志已正常被清理。
查看数据库日志,日志中也有相关提示“archive files exceeded the time limit 5 minutes begin removing”,说明该参数是生效的。
2024-04-08 20:00:40.650 [INFO] database P0000022360 T0000000000000022398 archive files exceeded the time limit 5 minutes begin removing......
2024-04-08 20:00:40.650 [INFO] database P0000022360 T0000000000000022398 local archive delete before time [2024-04-08 19:55:40] start......
2024-04-08 20:00:40.650 [INFO] database P0000022360 T0000000000000022398 rafil_file_delete_low delete file[/dm8/arch/ARCHIVE_LOCAL1_0x59BEDBAC_EP0_2024-04-08_19-43-15.log]
2024-04-08 20:00:40.650 [INFO] database P0000022360 T0000000000000022398 delete local archive file[/dm8/arch/ARCHIVE_LOCAL1_0x59BEDBAC_EP0_2024-04-08_19-43-15.log].
2024-04-08 20:00:40.650 [INFO] database P0000022360 T0000000000000022398 rafil_file_delete_low delete file[/dm8/arch/ARCHIVE_LOCAL1_0x59BEDBAC_EP0_2024-04-08_19-41-20.log]
2024-04-08 20:00:40.650 [INFO] database P0000022360 T0000000000000022398 delete local archive file[/dm8/arch/ARCHIVE_LOCAL1_0x59BEDBAC_EP0_2024-04-08_19-41-20.log].
2024-04-08 20:00:40.650 [INFO] database P0000022360 T0000000000000022398 local archive delete before time [2024-04-08 19:55:40] end.
2024-04-08 20:00:40.650 [INFO] database P0000022360 T0000000000000022398 remote archive delete before time [2024-04-08 19:55:40] start......
2024-04-08 20:00:40.650 [INFO] database P0000022360 T0000000000000022398 remote archive delete before time [2024-04-08 19:55:40] end.
2024-04-08 20:00:40.650 [INFO] database P0000022360 T0000000000000022398 archive files exceeded the time limit 5 minutes removed, total files 2......
2024-04-08 20:01:40.718 [INFO] database P0000022360 T0000000000000022417 checkpoint requested by CKPT_INTERVAL, rlog free space[536846336], used space[16384]
2024-04-08 20:01:40.718 [INFO] database P0000022360 T0000000000000022417 checkpoint generate by ckpt_interval
总结:
通过ARCH_RESERVE_TIME参数,我们可以在配置归档时,顺便配置其其保留的时间,不再需要额外配置脚本去清理归档日志。
谨记:心存敬畏,行有所止。