ASM实验手册22-13_Oracle数据库教程_清理一个ASM磁盘组中的数据
[font=Cambria]ASM实验手册22-13_Oracle数据库教程_清理一个ASM磁盘组中的数据1236 1237
[font=Cambria]附:[font=Cambria]ASM磁盘组基础操作创建磁盘组的语法如下:[table=98%,rgb(191, 191, 191)]
[td=475]CREATE DISKGROUP diskgroup_name[ { HIGH | NORMAL | EXTERNAL } REDUNDANCY ]{ [ FAILGROUP failgroup_name ]DISK qualified_disk_clause [, qualified_disk_clause]...} ...[ ATTRIBUTE { 'attribute_name' = 'attribute_value' }... ];qualified_disk_clause ::= search_string[ NAME disk_name ][ SIZE size_clause ][ FORCE | NOFORCE ]
创建sale磁盘组[table=98%,rgb(191, 191, 191)]
[td=486]CREATE DISKGROUP sale NORMAL REDUNDANCYFAILGROUP FG_SALE_01DISK 'ORCL:VOL_SDI' NAME SALESDI SIZE 500MFAILGROUP FG_SALE_02DISK 'ORCL:VOL_SDJ' NAME SALESDJ SIZE 500MATTRIBUTE 'compatible.asm' = '11.2','compatible.rdbms' = '11.2','compatible.advm' = '11.2';Diskgroup created.或:SQL> CREATE DISKGROUP test NORMAL REDUNDANCYDISK 'ORCL:VOL_TEST01' NAME TEST01 SIZE 2048MDISK 'ORCL:VOL_TEST02' NAME TEST02 SIZE 2048MATTRIBUTE 'compatible.asm' = '11.2','compatible.rdbms' = '11.2','compatible.advm' = '11.2';2 3 4 5 6 Diskgroup created.
报错过程:[table=98%,rgb(191, 191, 191)]
[td=625]SQL> CREATE DISKGROUP sale NORMAL REDUNDANCYFAILGROUP FG_SALE_01DISK 'ORCL:VOL_SDI' NAME SALESDI SIZE 500MFAILGROUP FG_SALE_02DISK 'ORCL:VOL_SDJ' NAME SALESDJ SIZE 500MATTRIBUTE 'compatible.asm' = '11.2','compatible.rdbms' = '11.2','compatible.advm' = '11.2';2 3 4 5 6 7 8 CREATE DISKGROUP sale NORMAL REDUNDANCY*ERROR at line 1:ORA-15018: diskgroup cannot be createdORA-15238: 11.2 is not a valid value for attribute compatible.advmORA-15477: cannot communicate with the volume driverSQL> host oerr ora 1547715477, 00000, "cannot communicate with the volume driver"// *Cause: An attempt was made to communicate with the volume driver.// *Action: Check that the ASM volume driver is loaded. If so, check the alert// log to identify the reason for failure and take necessary action // to prevent such failures in the future.//
解决:[table=98%,rgb(191, 191, 191)]
[td=617]如上的错误表示ASM volume driver没有加载。需要使用root用户手工加载。# u01/app/11.2.0/grid/bin/acfsload start -s
扩展磁盘组磁盘扩展磁盘组磁盘语法:[table=98%,rgb(191, 191, 191)]
[td=552]ALTER DISKGROUP diskgroup_name{ ADD{ [ FAILGROUP failgroup_name ]DISK qualified_disk_clause [, qualified_disk_clause ]...}...}[ REBALANCE [POWER integer] [WAIT | NOWAIT] ];
扩展SALE磁盘组[table=98%,rgb(191, 191, 191)]
[td=554]SQL> ALTER DISKGROUP sale ADD FAILGROUP FG_SALE_01DISK 'ORCL:VOL_SDK' NAME SALESDK SIZE 500M;Diskgroup altered.或SQL> ALTER DISKGROUP test ADD DISK 'ORCL:VOL_TEST03' SIZE 2048MDiskgroup altered.
Resize 磁盘组目前磁盘ORCL:VOL_SDI、ORCL:VOL_SDJ、ORCL:VOL_SDK各有1000M容量,从v$asm_disk.OS_MB可以看出,TOTAL_MB就是已经使用的容量.[table=98%,rgb(191, 191, 191)]
[td=546]Pl/sql developer工具提供语句:select g.name, d.os_mb, d.total_mb,d.name,d.failgroup,d.path,g.typefrom v$asm_disk d, v$asm_diskgroup gwhere d.group_number = g.group_numberand g.name = 'SALE';SALE 1019 500 SALESDI FG_SALE_01 ORCL:VOL_SDI NORMALSALE 1019 500 SALESDJ FG_SALE_02 ORCL:VOL_SDJ NORMALSALE 1019 500 SALESDK FG_SALE_01 ORCL:VOL_SDK NORMAL
以上三个磁盘Resize disk 到700M.[table=98%,rgb(191, 191, 191)]
[td=549]SQL> ALTER DISKGROUP sale RESIZE DISK SALESDI SIZE 700M;ALTER DISKGROUP sale RESIZE DISK SALESDJ SIZE 700M;ALTER DISKGROUP sale RESIZE DISK SALESDK SIZE 700M;Diskgroup altered.SQL> Diskgroup altered.SQL> Diskgroup altered.
查看已经RESIZE DISK:[table=98%,rgb(191, 191, 191)]
[td=595]Pl/sql developer工具提供语句:select g.name, d.os_mb, d.total_mb,d.name,d.failgroup,d.path,g.typefrom v$asm_disk d, v$asm_diskgroup gwhere d.group_number = g.group_numberand g.name = 'SALE';1 SALE 1019 700 SALESDI FG_SALE_01 ORCL:VOL_SDI NORMAL2 SALE 1019 700 SALESDJ FG_SALE_02 ORCL:VOL_SDJ NORMAL3 SALE 1019 700 SALESDK FG_SALE_01 ORCL:VOL_SDK NORMAL
从磁盘组删除磁盘[@more@]从磁盘组删除磁盘语法:[table=98%,rgb(191, 191, 191)]
[td=589]ALTER DISKGROUP diskgroup_name{ DROP{ DISKdisk_name [ FORCE | NOFORCE ][, disk_name [ FORCE | NOFORCE ] ]...| DISKS IN FAILGROUPfailgroup_name [ FORCE | NOFORCE ][, failgroup_name [ FORCE | NOFORCE ] ]...}}[ REBALANCE [POWER integer] [WAIT | NOWAIT] ];
从磁盘组中DROP磁盘.[table=98%,rgb(191, 191, 191)]
[td=579]SQL> ALTER DISKGROUP sale DROP DISK SALESDK;Diskgroup altered.
同时增加与删除磁盘操作同时增加与删除磁盘操作语法:[table=98%,rgb(191, 191, 191)]
[td=560]ALTER DISKGROUP diskgroup_name{ ADD ... }{ DROP ... }[ REBALANCE [POWER integer] [WAIT | NOWAIT] ];
添加磁盘与删除磁盘同时进行:[table=98%,rgb(191, 191, 191)]
[td=562]SQL> ALTER DISKGROUP sale2 ADD DISK 'ORCL:VOL_SDK NAME SALESDK SIZE 700M 3 DROP DISK SALESDJ;ADD DISK 'ORCL:VOL_SDK NAME SALESDK SIZE 700M*ERROR at line 2:ORA-01756: quoted string not properly terminatedSQL> c/'ORCL:VOL_SDK/'ORCL:VOL_SDK'2* ADD DISK 'ORCL:VOL_SDK' NAME SALESDK SIZE 700MSQL> /Diskgroup altered.
Undrop磁盘操作可以取消正在进行drop磁盘的操作,注意,已经完成drop操作以及drop带选项force的操作不能undrop.[table=98%,rgb(191, 191, 191)]
[td=560]ALTER DISKGROUP sale UNDROP DISKS;Diskgroup altered.
磁盘的挂载与卸载磁盘的挂载与卸载语法:[table=98%,rgb(191, 191, 191)]
[td=557]ALTER DISKGROUP{ diskgroup_name [, diskgroup_name ] ...| ALL}{ MOUNT [ RESTRICTED | NORMAL ][ FORCE | NOFORCE ]| DISMOUNT [ FORCE | NOFORCE ]};
卸载与挂载操作:[table=98%,rgb(191, 191, 191)]
[td=553]SQL> alter diskgroup sale dismount;Diskgroup altered.SQL> alter diskgroup sale mount;Diskgroup altered.
删除磁盘组删除磁盘组语法:[table=98%,rgb(191, 191, 191)]
[td=559]DROP DISKGROUP diskgroup_name[ FORCE INCLUDING CONTENTS| { INCLUDING | EXCLUDING } CONTENTS;
删除磁盘组(如果磁盘组有数据,不要轻易drop磁盘组,将导致数据库不能open):[table=98%,rgb(191, 191, 191)]
[td=559]SQL> DROP DISKGROUP sale INCLUDING CONTENTS;Diskgroup dropped.SQL> DROP DISKGROUP sale INCLUDING CONTENTS;Diskgroup dropped.DROP DISKGROUP sale FORCE INCLUDING CONTENTS;
磁盘online/offline[table=98%,rgb(191, 191, 191)]
[td=560]SQL> alter diskgroup test offline disk 'test01';Diskgroup altered.SQL> alter diskgroup test online disk 'test01';Diskgroup altered.
设置磁盘组属性[table=98%,rgb(191, 191, 191)]
[td=572]ALTER DISKGROUP test SET ATTRIBUTE 'disk_repair_time' = '4.5h';Diskgroup altered.ALTER DISKGROUP test SET ATTRIBUTE 'disk_repair_time' = '270m';Diskgroup altered.
DISK_REPAIR_TIME属性[table=98%,rgb(191, 191, 191)]
[td=575]1. 5分钟之后,offline的磁盘将被删除[color=#070c0][font=Courier]ALTER DISKGROUP data OFFLINE DISK DATA_001 DROP AFTER 5m;[font=Courier]SQL> ALTER DISKGROUP test OFFLINE DISK VOL_TEST03 DROP AFTER 5M;[font=Courier]Diskgroup altered.2. Offline的磁盘将应用属性disk_repair_time默认的时间[font=Courier]ALTER DISKGROUP data OFFLINE DISK DATA_001;
ASM Fast mirror resync(11g asm新特性:从其他冗余磁盘中,仅同步offine磁盘之后,Modfied Extent的数据.)ASM Fast mirror resync描述:[table=98%,rgb(191, 191, 191)]
[td=596]在10g的ASM中如果因为某些硬件故障(比如接口线,比如光纤卡,比如电源)导致Diskgroup中的某些磁盘无法正常读取,这些磁盘将处于offline状态,在offline之后不久ASM就会把这些磁盘从Diskgroup中删除,并且尝试利用冗余的extent来重新在其它磁盘中构建数据,这是一个比较耗时且耗资源的操作。当我们修复了磁盘,再将它们重新加回磁盘组中,又将是另外一次的数据重整操作。如果我们仅仅是例行的维护硬件,因为磁盘中的数据并没有真正的损坏,我们只是将磁盘取出来过一会儿再加回去,那么这样的两次数据重整操作无疑是没有必要的,在11g中ASM的Fast Mirror Resync功能允许我们设置磁盘的repair时间,在repair时间内ASM将不会尝试在磁盘间重新分配extent。 ALTER DISKGROUP dgroup SET ATTRIBUTE 'DISK_REPAIR_TIME'='3H'; 上述命令可以设置当磁盘组dgroup中的磁盘失效和重新有效之间的时间在3小时内的话,ASM就不会重新构建extent,当磁盘重新有效之后,ASM需要做的只是将这3小时内更改的extent重新同步到刚才失效的这些磁盘中就可以了。
ASM Fast mirror resync实现满足的条件:[table=98%,rgb(191, 191, 191)]
[td=597]1. Enabled when COMPATIBLE.RDBMS >= 11.12. ASM 镜像 (NORMAL or HIGH redundancy)模式,对EXTERNAL模式无效.3. 设定DISK_REPAIR_TIME的时间,该属性默认3.6小时.
Preferred Read Failure Groups(11g新特性:在RAC环境中,优先读取本地磁盘)Preferred Read Failure Groups描述:[table=98%,rgb(191, 191, 191)]
[td=595]在Oracle10g的自动存储管理中,当配置一个故障磁盘组的时候,通常都会从首要的镜像分配单元拷贝上读取数据。但是,从靠近一个节点的故障磁盘组读取分配单元效率会更高一些,即使是从次要的分配单元。尤其是针对于RAC扩展的集群配置,从本地节点的一个分配单元拷贝上读取数据将能够提高性能。对于Oracle11g数据库,就能够通过一个全新的实例级别的初始化参数ASM_PREFERRED_READ_FAILURE_GROUPS来配置首选镜像读取,这个参数将指定一个首选镜像读取的列表,在这些故障磁盘组中的磁盘都成为首选读取的磁盘。因此,每个节点都能读取其本地磁盘,这将极大的提高效率和性能,减少网络阻塞。这个初始化参数是个多值参数,如果设置有多个故障磁盘组,可以用逗号隔开,故障磁盘组的名字的指定必须是磁盘组名加上字符“.”。这个参数可以使用ALTER SYSTEM命令来动态修改,并且只能适用于自动存储管理的实例。当节点扩展到集群的时候,这个参数应该被设置为对应当前实例的本地的磁盘。 +ASM1.ASM_PREFERRED_READ_FAILURE_GROUPS = DG1.FG1, DG2.FG3+ASM2.ASM_PREFERRED_READ_FAILURE_GROUPS = DG1.FG2, DG2.FG4(DG1/2为磁盘组,FG1/2为故障组,其他类似)