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

理解ASM(六)ASM文件管理

 

        ① ASM文件转化
       
        以创建的asmtest表空间为例
         
           ㈠  将os文件转换为ASM文件

sys@ORCL> create tablespace asmtest datafile size 10m;

Tablespace created.

sys@ORCL> alter tablespace asmtest offline;

Tablespace altered.

[oracle@localhost ~]$ rman target /


RMAN> backup as copy tablespace asmtest format '+DATA';


RMAN> switch tablespace asmtest to copy;

datafile 6 switched to datafile copy "+DATA/orcl/datafile/asmtest.256.798497595"


sys@ORCL> alter tablespace asmtest online;

Tablespace altered.


sys@ORCL> select file_name from dba_data_files where tablespace_name='ASMTEST';

FILE_NAME
----------------------------------------------------------------
+DATA/orcl/datafile/asmtest.256.798497595


ASMCMD> mkalias ASMTEST.256.798497595 asmtest.dbf

ASMCMD> ls -al
Type      Redund  Striped  Time             Sys  Name
DATAFILE  MIRROR  COARSE   NOV 04 20:00:00  Y    +DATA/ORCL/DATAFILE/asmtest.dbf => ASMTEST.256.798497595
                                            N    asmtest.dbf => +DATA/ORCL/DATAFILE/ASMTEST.256.798497595


 

           ㈡ 将数据文件从一个diskgroup迁移到另一个diskgroup

idle> select file_id  from dba_data_files where tablespace_name='ASMTEST';

   FILE_ID
----------
         6

idle> alter tablespace asmtest offline;


[oracle@localhost ~]$ rman target /

RMAN> backup as copy datafile 6 format '+THINK';


RMAN> switch datafile 6 to copy;


RMAN> recover datafile 6;


RMAN> sql "alter tablespace asmtest online";


ASMCMD> find THINK/ *
+THINK/ORCL/
+THINK/ORCL/DATAFILE/
+THINK/ORCL/DATAFILE/ASMTEST.256.798503425


 

           ㈢ 将ASM文件转发成OS文件

sys@ORCL> select file_name from dba_data_files where tablespace_name='ASMTEST';

FILE_NAME
----------------------------------------------------------------
+THINK/orcl/datafile/asmtest.256.798503425

sys@ORCL> alter tablespace asmtest offline;

sys@ORCL> create directory ossrc as '/home/oracle';

sys@ORCL> create directory  asmsrc as '+THINK/orcl/datafile';

sys@ORCL> begin
  2          dbms_file_transfer.copy_file('ASMSRC','ASMTEST.256.798503425','OSSRC','ASM.DBF');
  3         end;
  4  /

PL/SQL procedure successfully completed.

sys@ORCL> alter database rename file '+THINK/orcl/datafile/asmtest.256.798503425' to '/home/oracle/ASM.DBF';

[oracle@localhost ~]$ rman target /

RMAN> recover datafile 6;

RMAN> sql "alter tablespace asmtest online";


sys@ORCL> select file_name from dba_data_files where tablespace_name='ASMTEST';

FILE_NAME
----------------------------------------------------------------
/home/oracle/ASM.DBF


 

          ② ASM中的文件名
         
          ASM文件名,诸如: 
          +THINK/orcl/datafile/asmtest.256.798503