理解ASM File Alias

原创 2012年03月29日 22:24:27

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

DB_FILE_NAME_CONVERT参数导致ORA-15124: ASM file name '...' containsan invalid alias name

RAC主库+单机DG环境中,一旦主备库之前有归档断裂,而恰恰这些归档可能由于种种原因被删除,如归档被清理了,备份集策略已经超出所需归档。也不用担心,可以按以下大致步骤做恢复: o 主库上做基于SCN的...
  • robo23
  • robo23
  • 2014年12月21日 20:21
  • 1106

关于oracle 11.2.0.4 使用asm磁盘组条件下对应用数据表空间文件的rename alias操作

在运维操作过程中会出现一些失误,针对在使用ASM磁盘管理下,给表空间添加数据文件,添加的数据文件不符合创建规则,因此需要对数据文件进行rename操作,关于使用文件系统的rename操作网上已经有很多...

ASM 翻译系列第四十弹:理解ASM中 REQUIRED_MIRROR_FREE_MB和USABLE_FILE_MB的含义

在我的课上一个经常被问到的问题是ASM如何计算磁盘组REQUIRED_MIRROR_FREE_MB和USABLE_FILE_MB的值,这个问题的答案跟很多复杂问题的答案一样:要看情况。...

异常信息ASM ClassReader failed to parse class file的问题解决

引言: 在基于Spring开发中碰到了一个异常,并解决之。

“asm/semaphore.h: No such file or directory”

今天编译发现一个error: “asm/semaphore.h: No such file or directory” ,发现2.6.19和2.6.31对这个信号量声明并不相同 [patch] ...
  • jw212
  • jw212
  • 2011年08月19日 16:02
  • 6472

Oracle ASM Cluster File Systems (ACFS)应用指南

ACFS是oracle database 11gR2的一个新特性。关于ACFS的更多信息请参考官方文档。这篇文章是基于RAC环境写的,不知道在非RAC环境中,还能不能使用ACFS呢,有兴趣的朋友可以测...

ORA-15061 reported while doing a file operation with 11.1 or 11.2 ASM after PSU applied in database

ORA-15061 reported while doing a file operation with 11.1 or 11.2 ASM after PSU applied in database ...

Create Oracle ASM Cluster File Systems (ACFS) in Oracle Database 11g Release 2

OS版本是Oracle Linux5.8 x86_64,Oracle Database和Grid Infrastructure版本是11.2.0.3,双节点RAC。 [root@vzwc1 ~]# ...

How to move a datafile from a file system to ASM

GOAL This note will guide a DBA in moving a datafile currently located on file system to an ASM...

使用DBMS_FILE_TRANSFER迁移ASM中的表空间和数据文件

这是一个存储过程包,是除了RMAN之外又一个用于执行迁移任务的工具包,可以完成如下的迁移:ASM->ASM、ASM->OS Flie、OS File->ASM、OS File->OS File。  ...
  • gtlions
  • gtlions
  • 2013年02月26日 06:24
  • 821
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:理解ASM File Alias
举报原因:
原因补充:

(最多只允许输入30个字)