手工清理ASM裡面的垃圾檔案

趙宇發表於2008-04-24

我們在資料庫刪除以後,用DBCA或者是drop database等,資料檔案會相應的被刪除,但是我們的備份以及當前的日誌,在ASM裡面都被留了下來,當再次使用ASM的時候,需要手工清理.

ASMCMD> rm -r controlfile
You may delete multiple files and/or directories.
Are you sure? (y/n) y
ORA-15032: ?????????
ORA-15028: ??? ASM ?? '+disk_group2/devdb/controlfile/Current.289.652879209'; ????????? (DBD ERROR: OCIStmtExecute)
ORA-15032: ?????????
ORA-15177: ??????????? (DBD ERROR: OCIStmtExecute)

由於對當前的controlfile做了刪除操作,報錯,這點要比UNIX下面要好,否則要恢復


ASMCMD> cd controlfile
ASMCMD> ls
Current.289.652879209
ASMCMD> ls -l
Type         Redund  Striped  Time              Sys  Name
CONTROLFILE  UNPROT  FINE     4?  24 11:00:00   Y    Current.289.652879209
ASMCMD> pwd
+disk_group2/devdb/controlfile
ASMCMD> cd ..
ASMCMD> ls
ARCHIVELOG/
CONTROLFILE/
ONLINELOG/
ASMCMD> cd onlinelog
ASMCMD> ls
group_1.277.642080697
group_1.331.652879217
group_2.333.652879223
group_3.334.652879231
ASMCMD> cd ..
ASMCMD> ls
ARCHIVELOG/
CONTROLFILE/
ONLINELOG/
ASMCMD> cd  onlinelog
ASMCMD> ls
group_1.277.642080697
group_1.331.652879217
group_2.333.652879223
group_3.334.652879231
ASMCMD> ls -l
Type       Redund  Striped  Time              Sys  Name
ONLINELOG  UNPROT  FINE     4?  09 09:00:00   Y    group_1.277.642080697
ONLINELOG  UNPROT  FINE     4?  24 11:00:00   Y    group_1.331.652879217
ONLINELOG  UNPROT  FINE     4?  24 11:00:00   Y    group_2.333.652879223
ONLINELOG  UNPROT  FINE     4?  24 11:00:00   Y    group_3.334.652879231
ASMCMD> rm group_1.277.642080697
ASMCMD> ls
group_1.331.652879217
group_2.333.652879223
group_3.334.652879231
ASMCMD> ls -l
Type       Redund  Striped  Time              Sys  Name
ONLINELOG  UNPROT  FINE     4?  24 11:00:00   Y    group_1.331.652879217
ONLINELOG  UNPROT  FINE     4?  24 11:00:00   Y    group_2.333.652879223
ONLINELOG  UNPROT  FINE     4?  24 11:00:00   Y    group_3.334.652879231
ASMCMD> cd ..
ASMCMD> ls
ARCHIVELOG/
CONTROLFILE/
ONLINELOG/
ASMCMD> cd archivelog
ASMCMD> ls
2008_03_31/
2008_04_02/
2008_04_03/
2008_04_07/
2008_04_08/
2008_04_24/
ASMCMD> rm -r 2008_03*
You may delete multiple files and/or directories.
Are you sure? (y/n) y
ASMCMD> ls
2008_04_02/
2008_04_03/
2008_04_07/
2008_04_08/
2008_04_24/
ASMCMD> rm -r 2008_04_0*

也支援UNXI命令,批量刪除不需要的目錄

 

SQL> select group_number,name,total_mb,free_mb from v$asm_diskgroup;

GROUP_NUMBER NAME                             TOTAL_MB    FREE_MB
------------ ------------------------------ ---------- ----------
           1 DISK_GROUP1                          6144       4818
           2 DISK_GROUP2                          6144       5865

呵呵,檢查剩餘空間,還是不少的.

ASM建庫的優點:

SQL> show parameter control_file

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      +DISK_GROUP1/devdb/controlfile
                                                 /current.447.652879209, +DISK_
                                                 GROUP2/devdb/controlfile/curre
                                                 nt.289.652879209

controlfile被分在兩個磁碟組

SQL>  select * from v$logfile;


    GROUP# STATUS  TYPE    MEMBER
---------- ------- ------- -----------------------------------------------------------------------------------
         3         ONLINE  +DISK_GROUP1/devdb/onlinelog/group_3.259.652879227
         3         ONLINE  +DISK_GROUP2/devdb/onlinelog/group_3.334.652879231
         2         ONLINE  +DISK_GROUP1/devdb/onlinelog/group_2.290.652879221
         2         ONLINE  +DISK_GROUP2/devdb/onlinelog/group_2.333.652879223
         1         ONLINE  +DISK_GROUP1/devdb/onlinelog/group_1.444.652879213
         1         ONLINE  +DISK_GROUP2/devdb/onlinelog/group_1.331.652879217

已選擇6行。

日誌每個成員分配在不同的磁碟組,平衡IO.

SQL> select name from v$datafile;

NAME
---------------------------------------------------
+DISK_GROUP1/devdb/datafile/system.289.652879115
+DISK_GROUP1/devdb/datafile/undotbs1.257.652879115
+DISK_GROUP1/devdb/datafile/sysaux.256.652879115
+DISK_GROUP1/devdb/datafile/users.258.652879115
+DISK_GROUP1/devdb/datafile/example.268.652879257

資料檔案肯定是指定哪組就在哪組

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/175005/viewspace-250395/,如需轉載,請註明出處,否則將追究法律責任。

相關文章