How to clear the archive log

来源:互联网 发布:杭州网站设计宣盟网络 编辑:程序博客网 时间:2024/05/05 20:03

Some time, the archive is full, we have to clear the archive log and then make the database normal.

The following way, maybe is useful to you.

1. For NO-DATAGUARD:

--- 1. Check the archivelog folder

# df -k

# su - oracle

$ sqlplus / as  sysdba

SQL> archive log  list;

 

--- 2. Move some old history archivelog files to the  other folder which have enough free space

Maybe sometimes, we  can't login the database or the rman, so, we must move some old archivelog  files to the other folder, so that we can login the rman.

 

--- 3. Clear the history archivelog

# su - oracle

$ rman target /

RMAN> delete  noprompt archivelog until time 'sysdate-1';

RMAN> crosscheck  archivelog all;

RMAN> delete  obsolete;

RMAN> exit;

sqlplus / as sysdba

SQL> alter  system switch logfile;

 

--- 4. Please finish a FULL backup for the current  database.

The old full backup  have become to invalid, we must backup the current database.

 

 

 

2. For DATAGUARD:

--- 1. Check the following on the  primary database and the standby database

On the primary database:

# su - oracle

$ sqlplus / as sysdba

SQL> archive log list;

On the standby database:

# su - oracle

$ sqlplus / as sysdba

SQL> set linesize 400

SQL> archive log list;

SQL> select process,status,thread#,sequence#,block#,blocks from  v$managed_standby;

 

--- 2. If the archivelog folder  close to full on the standby database

On the standby database:

You can clear archive log using the above steps.

 

--- 3. If the archivelog folder  close to full on the primary database

On the primary database:

# su - oracle

$ rman target /

RMAN> delete noprompt archivelog until time 'sysdate -1'backed up 1 times to device type disk;  <===== If there  are some archvielog files which didn’t move to the standby database after had  finished the full rman backup in the primary database, will be move, and have to rebuild the  standby database.

If there are some old history archivelog can't delete, and show  warning:RMAN-08137

Please don't remove them directly, because of they didn't were moved to  the standby database, we have to check status of the standby database.

RMAN> crosscheck archivelog all;

RMAN> delete obsolete;

RMAN> exit;