Oracle 归档目录满了怎么办?

        最近处理一个小事故,归档满了。这个我事先说明不是兄弟我没检查好,定期做清理,是有人突然把归档目录下面放了大量软件安装包。这个事情我是第一次遇到,还好之前看过关于这方面的资料。我今天把这个过程重演下,算是一次”抢修经验“好了。

         演示之前先交代下环境,这个处理方法从10g就是这样处理了。

[root@shu1 ~]# su - oracle
[oracle@shu1 ~]$ export ORACLE_SID=PROD
[oracle@shu1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sun Jun 8 09:55:37 2014

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  897740800 bytes
Fixed Size                  2258440 bytes
Variable Size             574622200 bytes
Database Buffers          314572800 bytes
Redo Buffers                6287360 bytes
Database mounted.
Database opened.
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     3
Next log sequence to archive   5
Current log sequence     
SQL> alter system set log_archive_dest_1='location=/u01/archTest';

System altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  897740800 bytes
Fixed Size                  2258440 bytes
Variable Size             574622200 bytes
Database Buffers          314572800 bytes
Redo Buffers                6287360 bytes
Database mounted.
Database opened.
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/archTest
Oldest online log sequence     3
Next log sequence to archive   5
Current log sequence           5
SQL> 
            为了马上能看出效果,我把归档目录特意放在只有500M的地方。

[root@shu1 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       26G   18G  6.0G  76% /
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                 1.1G     0  1.1G   0% /dev/shm
/dev/sdb1             496M   11M  460M   3% /u01/archTest
[root@shu1 ~]# 
[root@shu1 ~]# 
[root@shu1 ~]# chown -R oracle:oinstall /u01/archTest/
[root@shu1 ~]# ll
[root@shu1 /]# cd /
[root@shu1 /]# ll /u01
total 5
drwxr-xr-x 4 oracle oinstall 4096 Mar  8 22:32 app
drwxr-xr-x 3 oracle oinstall 1024 Jun  8 09:45 archTest
[root@shu1 /]# 
            从上面来看,归档目录/u01/archTest下面至少还有460M可以用。


       步骤一:装满归档目录/u01/archTest

[root@shu1 archTest]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       26G   19G  4.9G  80% /
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                 1.1G  233M  842M  22% /dev/shm
/dev/sdb1             496M  471M     0 100% /u01/archTest
           我随便找了一个490+M的文件之间放满了。然后就在数据库里面一直切换online redo log等着出错吧

     

     步骤二:切换在线日志数据库卡住,看alert日志

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;      

System altered.

SQL> /

System altered.

SQL> /
        切着切着就卡住了啊,去看看日志吧,重新开一个session看看alert路径

[oracle@shu1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sun Jun 8 10:25:38 2014

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select value from v$diag_info where name ='Diag Trace';

VALUE
--------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/prod/PROD/trace

SQL> 
SQL> 
SQL> 
SQL> alter database backup controlfile to trace as '/home/oracle/controlfile.txt';  

Database altered.

SQL> 
          知道alert文件的路径就好办了

Thread 1 advanced to log sequence 21 (LGWR switch)
  Current log# 3 seq# 21 mem# 0: /u01/app/oracle/oradata/PROD/redo03.log
Sun Jun 08 10:22:38 2014
Archived Log entry 18 added for thread 1 sequence 20 ID 0xf1cebfd dest 1:
Sun Jun 08 10:24:30 2014
Thread 1 advanced to log sequence 22 (LGWR switch)
  Current log# 1 seq# 22 mem# 0: /u01/app/oracle/oradata/PROD/redo01.log
Sun Jun 08 10:24:30 2014
Unable to create archive log file '/u01/archTest/1_21_841704832.dbf'
ARC1: Error 19504 Creating archive log file to '/u01/archTest/1_21_841704832.dbf'
ARCH: Archival stopped, error occurred. Will continue retrying
ORACLE Instance PROD - Archival Error
ORA-16038: log 3 sequence# 21 cannot be archived
ORA-19504: failed to create file ""
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/PROD/redo03.log'
Sun Jun 08 10:24:30 2014
ARCH: Archival stopped, error occurred. Will continue retrying
ORACLE Instance PROD - Archival Error
ORA-16014: log 3 sequence# 21 not archived, no available destinations  --出现问题描述了
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/PROD/redo03.log'
Thread 1 advanced to log sequence 23 (LGWR switch)
  Current log# 2 seq# 23 mem# 0: /u01/app/oracle/oradata/PROD/redo02.log
Sun Jun 08 10:24:32 2014
Archiver process freed from errors. No longer stopped
Thread 1 cannot allocate new log, sequence 24
Checkpoint not complete
  Current log# 2 seq# 23 mem# 0: /u01/app/oracle/oradata/PROD/redo02.log
ORACLE Instance PROD - Cannot allocate log, archival required
Thread 1 cannot allocate new log, sequence 24
All online logs need archiving
Examine archive trace files for archiving errors
  Current log# 2 seq# 23 mem# 0: /u01/app/oracle/oradata/PROD/redo02.log

 

    

        步骤三:删除硬盘多余文件

[root@shu1 archTest]# ll
total 431522
-rw-r----- 1 oracle oinstall      1536 Jun  8 10:20 1_10_841704832.dbf
-rw-r----- 1 oracle oinstall      2048 Jun  8 10:20 1_11_841704832.dbf
-rw-r----- 1 oracle oinstall      1536 Jun  8 10:22 1_12_841704832.dbf
-rw-r----- 1 oracle oinstall      1024 Jun  8 10:22 1_13_841704832.dbf
-rw-r----- 1 oracle oinstall      1024 Jun  8 10:22 1_14_841704832.dbf
-rw-r----- 1 oracle oinstall      1024 Jun  8 10:22 1_15_841704832.dbf
-rw-r----- 1 oracle oinstall      1024 Jun  8 10:22 1_16_841704832.dbf
-rw-r----- 1 oracle oinstall      1024 Jun  8 10:22 1_17_841704832.dbf
-rw-r----- 1 oracle oinstall      1024 Jun  8 10:22 1_18_841704832.dbf
-rw-r----- 1 oracle oinstall      1024 Jun  8 10:22 1_19_841704832.dbf
-rw-r----- 1 oracle oinstall      1024 Jun  8 10:22 1_20_841704832.dbf
-rw-r----- 1 oracle oinstall   3042304 Jun  8 10:14 1_7_841704832.dbf
-rw-r----- 1 oracle oinstall      1024 Jun  8 10:15 1_8_841704832.dbf
-rw-r----- 1 oracle oinstall    568320 Jun  8 10:20 1_9_841704832.dbf
-rw-r--r-- 1 oracle oinstall 215926219 Mar 19 20:24 ɨ????????1.zip
-rw-r--r-- 1 oracle oinstall         0 Nov  5  2013 compat-libstdc++-33-3.2.3-61.x86_64.rpm
-rw-r--r-- 1 oracle oinstall         0 Nov  5  2013 gcc-c++-4.1.2-48.el5.x86_64.rpm
-rw-r--r-- 1 oracle oinstall   4276224 Nov  5  2013 glibc-2.5-49.i686.rpm
-rw-r--r-- 1 oracle oinstall    372341 Nov  5  2013 libstdc++-4.1.2-48.el5.i386.rpm
drwx------ 2 oracle oinstall     12288 Jun  8 09:45 lost+found
drwxr-xr-x 2 oracle oinstall      1024 Jun  8 10:21 mylib
-rw-r--r-- 1 oracle oinstall 215926219 Mar 19 20:24 ɨ????????.zip
[root@shu1 archTest]# 
[root@shu1 archTest]# rm 1_20_841704832.dbf 
rm: remove regular file `1_20_841704832.dbf'? y
[root@shu1 archTest]# rm 1_19_841704832.dbf 
rm: remove regular file `1_19_841704832.dbf'? yes
[root@shu1 archTest]# rm 1_18_841704832.dbf 
rm: remove regular file `1_18_841704832.dbf'? y
      一般都在放归档日志的,为了演示归档满了,这里删除3个归档日志
[oracle@shu1 archTest]$ rm *.rpm
[oracle@shu1 archTest]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       26G   19G  4.9G  80% /
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                 1.1G  223M  853M  21% /dev/shm
/dev/sdb1             496M  467M  4.1M 100% /u01/archTest
[oracle@shu1 archTest]$ df *.zip
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sdb1               507732    477360      4159 100% /u01/archTest
/dev/sdb1               507732    477360      4159 100% /u01/archTest
[oracle@shu1 archTest]$ rm *.zip
[oracle@shu1 archTest]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       26G   19G  4.9G  80% /
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                 1.1G  223M  853M  21% /dev/shm
/dev/sdb1             496M   53M  418M  12% /u01/archTest

       删除了多余的文件,一般大家都会去删除没用的归档日志的,我就是做个例子演示下。

     

     步骤四:同步逻辑层面

[oracle@shu1 ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Sun Jun 8 10:33:31 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PROD (DBID=253543165)


RMAN> crosscheck archivelog all; --用这个命令检查归档日志是否在硬盘

released channel: ORA_DISK_1
released channel: ORA_DISK_2
released channel: ORA_DISK_3
released channel: ORA_DISK_4
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=146 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=17 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=138 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=22 device type=DISK
validation succeeded for archived log
archived log file name=/u01/archTest/1_7_841704832.dbf RECID=5 STAMP=849694499
validation succeeded for archived log
archived log file name=/u01/archTest/1_8_841704832.dbf RECID=6 STAMP=849694501
validation succeeded for archived log
archived log file name=/u01/archTest/1_9_841704832.dbf RECID=7 STAMP=849694827
validation succeeded for archived log
archived log file name=/u01/archTest/1_10_841704832.dbf RECID=8 STAMP=849694832
validation succeeded for archived log
archived log file name=/u01/archTest/1_11_841704832.dbf RECID=9 STAMP=849694835
validation succeeded for archived log
archived log file name=/u01/archTest/1_12_841704832.dbf RECID=10 STAMP=849694922
validation succeeded for archived log
archived log file name=/u01/archTest/1_13_841704832.dbf RECID=11 STAMP=849694924
validation succeeded for archived log
archived log file name=/u01/archTest/1_14_841704832.dbf RECID=12 STAMP=849694948
validation succeeded for archived log
archived log file name=/u01/archTest/1_15_841704832.dbf RECID=13 STAMP=849694950
validation succeeded for archived log
archived log file name=/u01/archTest/1_16_841704832.dbf RECID=14 STAMP=849694952
validation succeeded for archived log
archived log file name=/u01/archTest/1_17_841704832.dbf RECID=15 STAMP=849694954
Crosschecked 11 objects

validation failed for archived log   --检查失败 不存在的提示
archived log file name=/u01/archTest/1_18_841704832.dbf RECID=16 STAMP=849694955
validation failed for archived log
archived log file name=/u01/archTest/1_19_841704832.dbf RECID=17 STAMP=849694956
validation failed for archived log
archived log file name=/u01/archTest/1_20_841704832.dbf RECID=18 STAMP=849694958
Crosschecked 3 objects


RMAN> delete expired archivelog all; --删除检查失效的

released channel: ORA_DISK_1
released channel: ORA_DISK_2
released channel: ORA_DISK_3
released channel: ORA_DISK_4
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=146 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=17 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=138 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=22 device type=DISK
List of Archived Log Copies for database with db_unique_name PROD --再次确认是否这3个,是啊 就是他们 我上面rm的3个归档。。
=====================================================================

Key     Thrd Seq     S Low Time 
------- ---- ------- - ---------
16      1    18      X 08-JUN-14
        Name: /u01/archTest/1_18_841704832.dbf

17      1    19      X 08-JUN-14
        Name: /u01/archTest/1_19_841704832.dbf

18      1    20      X 08-JUN-14
        Name: /u01/archTest/1_20_841704832.dbf


Do you really want to delete the above objects (enter YES or NO)? yes --
deleted archived log
archived log file name=/u01/archTest/1_18_841704832.dbf RECID=16 STAMP=849694955
deleted archived log
archived log file name=/u01/archTest/1_19_841704832.dbf RECID=17 STAMP=849694956
deleted archived log
archived log file name=/u01/archTest/1_20_841704832.dbf RECID=18 STAMP=849694958
Deleted 3 EXPIRED objects


RMAN> 

    通过crosscheck命令,找到实际不存在的归档文件,删除掉。

    版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!

   



  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值