① 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.798503425
上述名稱的產生格式為:
+diskgroup/dbname/file_type/file_type_tag.file.incarnation
● +diskgroup :磁碟組名稱
● dbname :資料庫的DB_UNIQUE_NAME參數值
● file_type :建立的檔案類型,比如CONTROLFILE/DATAFILE/ONLINELOG/ARCHIVELOG/TEMPFILE/BACKUPSET/FLASHBACK等等
● file_type_tag :檔案類型的標籤,比如資料表空間對應的通常為該資料表空間名稱
● file.incarnation :檔案序號+incarnation,用來確保檔案的唯一
檔案建立時無法指定實際檔案名稱及路徑,完全由ORACLE的OMF控制和管理
例如:
sys@ORCL> alter tablespace asmtest add datafile '+DATA' size 10m;
Tablespace altered.
如果設定了初始化參數db_create_file_dest,甚至連磁碟組名都不需要寫了
其它類型檔案,比如重做記錄檔等,操作方式都是同理的
但像trace檔案、alert檔案、dump檔案等還不能直接被儲存到ASM中
oracle視頻教程請關注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html