SQL> alter system set log_archive_dest_1='location=/u01/app/oracle/oradata/archivelog'; ---修改归档路径
System altered.
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/oradata/archivelog ---归档路径已经变化
Oldest online log sequence 110
Next log sequence to archive 115
Current log sequence 115
SQL> alter system switch logfile; ---手工切换归档日志
System altered.
检查文件系统下的归档日志,发现在/u01/app/oracle/oradata/archivelog目录下已经生成归档日志
[oracle@lsq archivelog]$ ll
total 43652
-rw-r----- 1 oracle oinstall 44699136 Mar 19 14:13 1_115_1124643686.dbf
截止目前的情况是在/u01/app/oracle/oradata目录下有一个1_102_1124643686.dbf,在/u01/app/oracle/oradata/archivelog目录下有1_115_1124643686.dbf。
4.模拟删除日志
[oracle@lsq archivelog]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Wed Mar 19 14:13:53 2025
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: LSQ (DBID=3389915302)
RMAN> delete archivelog all; ---删除所有的日志
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1154 device type=DISK
List of Archived Log Copies for database with db_unique_name LSQ
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - ---------
1 1 115 A 14-JUN-23
Name: /u01/app/oracle/oradata/archivelog/1_115_1124643686.dbf
Do you really want to delete the above objects (enter YES or NO)? yes ---确认是要删除的日志,输入yes
deleted archived log
archived log file name=/u01/app/oracle/oradata/archivelog/1_115_1124643686.dbf RECID=1 STAMP=1196172826
Deleted 1 objects
发现没有删除/u01/app/oracle/oradata目录下有一个1_102_1124643686.dbf,在生产环境可能造成空间的浪费。
5.规范删除旧归档日志
RMAN> catalog start with '/u01/app/oracle/oradata'; ---使用rman的catalog找到目录下的文件
searching for all files that match the pattern /u01/app/oracle/oradata
List of Files Unknown to the Database
=====================================
File Name: /u01/app/oracle/oradata/1_102_1124643686.dbf
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/oradata/1_102_1124643686.dbf
RMAN> delete archivelog all; ---然后就可以删除文件了
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1154 device type=DISK
List of Archived Log Copies for database with db_unique_name LSQ
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - ---------
2 1 102 A 14-FEB-23
Name: /u01/app/oracle/oradata/1_102_1124643686.dbf
Do you really want to delete the above objects (enter YES or NO)? yes
deleted archived log
archived log file name=/u01/app/oracle/oradata/1_102_1124643686.dbf RECID=2 STAMP=1196172872
Deleted 1 objects