ASM别名可以看作是OMF的扩展,先了解文件系统的OMF
[oracle@Oracle ~]$ export ORACLE_SID=test
[oracle@Oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 29 21:12:48 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> show parameter db_create_file
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string
SQL> create tablespace test;
create tablespace test
*
ERROR at line 1:
ORA-02199: missing DATAFILE/TEMPFILE clause
SQL> create tablespace test datafile '/u01/app/oracle/oradata/test/test01.dbf' size 2m;
Tablespace created.
SQL> drop tablespace test;
Tablespace dropped.
SQL> !
[oracle@Oracle ~]$ ls /u01/app/oracle/oradata/test/test*
/u01/app/oracle/oradata/test/test01.dbf
[oracle@Oracle ~]$
[oracle@Oracle ~]$ exit
exit
SQL>
SQL> create tablespace test datafile '/u01/app/oracle/oradata/test/test01.dbf' size 2m;
Tablespace created.
SQL> drop tablespace test including contents and datafiles;
Tablespace dropped.
SQL>
SQL> !
[oracle@Oracle ~]$ ls /u01/app/oracle/oradata/test/test*
ls: /u01/app/oracle/oradata/test/test*: No such file or directory
[oracle@Oracle ~]$ exit
exit
SQL> alter system set db_create_file_dest='/u01/app/oracle/oradata/test/' scope=both;
System altered.
SQL> create tablespace test;
Tablespace created.
SQL> select name,bytes/1024/1024 from v$datafile;
NAME
--------------------------------------------------------------------------------
BYTES/1024/1024
---------------
/u01/app/oracle/oradata/test/TEST/datafile/o1_mf_test_7q8rf6yw_.dbf
100
SQL> drop tablespace test;
Tablespace dropped.
[oracle@Oracle ~]$ ls /u01/app/oracle/oradata/test/TEST/datafile/
[oracle@Oracle ~]$
ASM上的OMF
[oracle@Oracle ~]$ export ORACLE_SID=orcl
[oracle@Oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 29 21:26:26 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
+DG1/orcl/controlfile/control01
+DG1/orcl/controlfile/control02
+DG1/orcl/controlfile/control03
SQL> create tablespace worry datafile '+dg1/worry.dbf' size 2m;
Tablespace created.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DG1/orcl/datafile/system.258.779226255
+DG1/orcl/datafile/undotbs1.261.779226303
+DG1/orcl/datafile/sysaux.259.779226283
+DG1/orcl/datafile/users.262.779226311
+DG1/orcl/datafile/example.260.779226297
+DG1/worry.dbf
SQL> select file_incarnation from v$asm_alias where name like '%worry%';
FILE_INCARNATION
----------------
779233409
SQL> select name from v$asm_alias where file_incarnation=779233409;
NAME
------------------------------------------------
WORRY.272.779233409
worry.dbf
SQL> select * from (select file_number,file_incarnation,'+'||gname||sys_connect_by_path(aname,'/') as full_alias_path from (select a.file_number file_number,a.file_incarnation file_incarnation,g.name gname,a.parent_index pindex,a.name aname,a.reference_index rindex from v$asm_alias a,v$asm_diskgroup g where a.group_number=g.group_number)start with (mod(pindex,power(2,24)))=0 connect by prior rindex=pindex order by 1,2) a where file_incarnation=&d;
Enter value for d: 779233409
old 1: select * from (select file_number,file_incarnation,'+'||gname||sys_connect_by_path(aname,'/') as full_alias_path from (select a.file_number file_number,a.file_incarnation file_incarnation,g.name gname,a.parent_index pindex,a.name aname,a.reference_index rindex from v$asm_alias a,v$asm_diskgroup g where a.group_number=g.group_number)start with (mod(pindex,power(2,24)))=0 connect by prior rindex=pindex order by 1,2) a where file_incarnation=&d
new 1: select * from (select file_number,file_incarnation,'+'||gname||sys_connect_by_path(aname,'/') as full_alias_path from (select a.file_number file_number,a.file_incarnation file_incarnation,g.name gname,a.parent_index pindex,a.name aname,a.reference_index rindex from v$asm_alias a,v$asm_diskgroup g where a.group_number=g.group_number)start with (mod(pindex,power(2,24)))=0 connect by prior rindex=pindex order by 1,2) a where file_incarnation=779233409
FILE_NUMBER FILE_INCARNATION
----------- ----------------
FULL_ALIAS_PATH
--------------------------------------------------------------------------------
272 779233409
+DG1/worry.dbf
272 779233409
+DG1/ORCL/DATAFILE/WORRY.272.779233409
SQL> create tablespace space datafile '+dg1' size 2m;
Tablespace created.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DG1/orcl/datafile/system.258.779226255
+DG1/orcl/datafile/undotbs1.261.779226303
+DG1/orcl/datafile/sysaux.259.779226283
+DG1/orcl/datafile/users.262.779226311
+DG1/orcl/datafile/example.260.779226297
+DG1/worry.dbf
+DG1/orcl/datafile/space.274.779234001
7 rows selected.
[oracle@Oracle ~]$ export ORACLE_SID=+ASM
[oracle@Oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 29 21:53:54 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> alter diskgroup dg1 add alias '+dg1/space.dbf' for '+DG1/orcl/datafile/space.274.779234001';
Diskgroup altered.
SQL>
SQL> select * from (select file_number,file_incarnation,'+'||gname||sys_connect_by_path(aname,'/') as full_alias_path from (select a.file_number file_number,a.file_incarnation file_incarnation,g.name gname,a.parent_index pindex,a.name aname,a.reference_index rindex from v$asm_alias a,v$asm_diskgroup g where a.group_number=g.group_number)start with (mod(pindex,power(2,24)))=0 connect by prior rindex=pindex order by 1,2) a where file_incarnation=&d;
Enter value for d: 779234001
old 1: select * from (select file_number,file_incarnation,'+'||gname||sys_connect_by_path(aname,'/') as full_alias_path from (select a.file_number file_number,a.file_incarnation file_incarnation,g.name gname,a.parent_index pindex,a.name aname,a.reference_index rindex from v$asm_alias a,v$asm_diskgroup g where a.group_number=g.group_number)start with (mod(pindex,power(2,24)))=0 connect by prior rindex=pindex order by 1,2) a where file_incarnation=&d
new 1: select * from (select file_number,file_incarnation,'+'||gname||sys_connect_by_path(aname,'/') as full_alias_path from (select a.file_number file_number,a.file_incarnation file_incarnation,g.name gname,a.parent_index pindex,a.name aname,a.reference_index rindex from v$asm_alias a,v$asm_diskgroup g where a.group_number=g.group_number)start with (mod(pindex,power(2,24)))=0 connect by prior rindex=pindex order by 1,2) a where file_incarnation=779234001
FILE_NUMBER FILE_INCARNATION
----------- ----------------
FULL_ALIAS_PATH
--------------------------------------------------------------------------------
274 779234001
+DG1/space.dbf
274 779234001
+DG1/ORCL/DATAFILE/SPACE.274.779234001
SQL>
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DG1/orcl/datafile/system.258.779226255
+DG1/orcl/datafile/undotbs1.261.779226303
+DG1/orcl/datafile/sysaux.259.779226283
+DG1/orcl/datafile/users.262.779226311
+DG1/orcl/datafile/example.260.779226297
+DG1/worry.dbf
+DG1/orcl/datafile/space.274.779234001
[oracle@Oracle ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Mar 29 21:58:51 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1306991326)
RMAN> backup as copy tablespace worry;
Starting backup at 29-MAR-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=151 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00006 name=+DG1/worry.dbf
output filename=+RECOVERY/orcl/datafile/worry.256.779234357 tag=TAG20120329T215914 recid=14 stamp=779234356
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:04
Finished backup at 29-MAR-12
RMAN>
SQL> select * from (select file_number,file_incarnation,'+'||gname||sys_connect_by_path(aname,'/') as full_alias_path from (select a.file_number file_number,a.file_incarnation file_incarnation,g.name gname,a.parent_index pindex,a.name aname,a.reference_index rindex from v$asm_alias a,v$asm_diskgroup g where a.group_number=g.group_number)start with (mod(pindex,power(2,24)))=0 connect by prior rindex=pindex order by 1,2) a where file_incarnation=&d;
Enter value for d: 779234357
old 1: select * from (select file_number,file_incarnation,'+'||gname||sys_connect_by_path(aname,'/') as full_alias_path from (select a.file_number file_number,a.file_incarnation file_incarnation,g.name gname,a.parent_index pindex,a.name aname,a.reference_index rindex from v$asm_alias a,v$asm_diskgroup g where a.group_number=g.group_number)start with (mod(pindex,power(2,24)))=0 connect by prior rindex=pindex order by 1,2) a where file_incarnation=&d
new 1: select * from (select file_number,file_incarnation,'+'||gname||sys_connect_by_path(aname,'/') as full_alias_path from (select a.file_number file_number,a.file_incarnation file_incarnation,g.name gname,a.parent_index pindex,a.name aname,a.reference_index rindex from v$asm_alias a,v$asm_diskgroup g where a.group_number=g.group_number)start with (mod(pindex,power(2,24)))=0 connect by prior rindex=pindex order by 1,2) a where file_incarnation=779234357
FILE_NUMBER FILE_INCARNATION
----------- ----------------
FULL_ALIAS_PATH
--------------------------------------------------------------------------------
256 779234357
+RECOVERY/ORCL/DATAFILE/WORRY.256.779234357
RMAN> list copy
2> ;
using target database control file instead of recovery catalog
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
14 6 A 29-MAR-12 581216 29-MAR-12 +RECOVERY/orcl/datafile/worry.256.779234357
RMAN> backup as copy tablespace space;
Starting backup at 29-MAR-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=145 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00007 name=+DG1/orcl/datafile/space.274.779234001
output filename=+RECOVERY/orcl/datafile/space.258.779235121 tag=TAG20120329T221200 recid=16 stamp=779235122
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:04
Finished backup at 29-MAR-12