日期:2014-05-16  浏览次数:20469 次

ASM迁移(beta版)

环境:

sys@ORCL> select * from v$version where rownum=1;

BANNER
----------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod

sys@ORCL> !uname -a
Linux localhost.localdomain 2.6.18-308.el5xen #1 SMP Fri Jan 27 17:59:00 EST 2012 i686 i686 i386 GNU/Linux


    ① 规划

          +DG1:用于存放数据文件、控制文件、联机日志
          +DG2:用于存放联机日志
          +RECOVERY:用于recovery area

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

GROUP_NUMBER NAME       STATE                               TOTAL_MB    FREE_MB
------------ ---------- --------------------------------- ---------- ----------
           1 DG1        MOUNTED                                 3072       3016
           2 DG2        MOUNTED                                  768        718
           3 RECOVERY   MOUNTED                                 2304       2250


    ② 修改RDBMS参数

idle> alter system set db_recovery_file_dest='+RECOVERY' scope=both;

System altered.

idle> alter system set db_create_file_dest='+DG1' scope=both;

System altered.
idle> alter system set db_create_online_log_dest_1='+DG1' scope=both;

System altered.

idle> alter system set db_create_online_log_dest_2='+DG2' scope=both;

System altered.


 

    ③ 日志文件迁移

idle> alter database add logfile group 4 ('+DG1','+DG2') size 80m;

Database altered.

idle> alter database add logfile group 5 ('+DG1','+DG2') size 80m;

Database altered.

idle> alter database add logfile group 6 ('+DG1','+DG2') size 80m;

Database altered.


    日志组的状态为inactive时,删除才能成功

idle> alter system checkpoint;
idle> alter database drop logfile group 1;

Database altered.
idle> alter database drop logfile group 2;

Database altered.

idle> alter database drop logfile group 3;

Database altered.

idle> select group#,status from v$log;

    GROUP# STATUS
---------- ----------------
         4 INACTIVE
         5 CURRENT
         6 UNUSED
idle> select member from v$logfile;

MEMBER
-----------------------------
+DG1/orcl/onlinelog/group_4.256.798634749
+DG2/orcl/onlinelog/group_4.256.798634753
+DG1/orcl/onlinelog/group_5.259.798634795
+DG2/orcl/onlinelog/group_5.259.798634801
+DG1/orcl/onlinelog/group_6.260.798634825
+DG2/orcl/onlinelog/group_6.260.798634829


 

    ④ 临时文件迁移

idle> select file_name,tablespace_name from dba_temp_files;

FILE_NAME                                               TABLESPACE_NAME
------------------------------------------------------- ------------------------------
/u01/app/oracle/oradata/ORCL/datafile/o1_mf_temp_8050j3 TEMP
4j_.tmp


idle> alter tablespace temp add tempfile '+DG1';

Tablespace altered.

idle> select file_name,tablespace_name from dba_temp_files;

FILE_NAME                                               TABLESPACE_NAME
------------------------------------------------------- ------------------------------
+DG1/orcl/tempfile/temp.25