当前位置:   article > 正文

oracle中asm磁盘不足,oracleasm磁盘管理基础篇(一)

usage of the asm disk group expressed in %.

今天是2014-02-27,从今天开始准备记录一系列的asm笔记。在此记录一下。

(一)asm常见参数:

和database实例一样,asm同样具有启动实例的相关参数,具体如下:

asm_diskgroups:指定asm实例启动的时候需要mount的disk group名字:

asm_disktsring :指定一个asm实例寻找磁盘的路径名可以有通配符。

asm_power_limit:指定在磁盘组中平衡数据的时候默认的power大小。

asm_preferred_read_failure_groups:指定优先读取的故障组

diagnostic_dest:asm实例diagnostics的目录

instance_type:实例类型,对于asm实例必须为asm

remote_login_passwordfile:验证是否需要去读密码文件

(二)asm实例和数据库实例参数文件搜索过程:

对于asm实例在启动的时候需要参数文件,那么一般搜索过程为:

1、先根据GPNP profile文件指定的参数文件位置进行寻找

2、如果没有在GPNP profile中指定的目录找到,那么将寻找$ORACLE_HME/dbs/spfile+ASM.ora

3、如果没有spfile+ASM.ora,那么将寻找pfile文件。

如果上述没有找到则无法启动asm

对于数据库实例启动的时候需要参数文件,那么搜素过程为:

1、寻找 $ORACLE_HOME/dbs/spfile.ora,

2、寻找 $ORACLE_HOME/dbs/spfile.ora

3、寻找 $ORACLE_HOME/dbs/init.ora

如果上述没有找到参数文件,那么数据库实例无法启动。

(三)使用sql命令create diskgroup创建磁盘组

当创建磁盘组之前需要注意一下几点:

1、指定磁盘组的唯一名字(注:不要使用对象名字)

2、指定磁盘组的平衡等级,一旦自定将无法修改

3、指定的磁盘将被格式化为oracle asm磁盘组的磁盘

4、选择指定磁盘组属于指定的故障组

5、选择指定故障组的类型(有QUORUM和REGULAR故障组)

6、指定磁盘组的属性(如软件兼容版本或是au大小等)

注意:一个磁盘只能属于一个磁盘组,且所有刚刚创建的磁盘都是有唯一的地址路径不属于现有的所有磁盘组,如果一个磁盘原先属于一个磁盘组,但是坏掉 了当修复后,这个磁盘将不在是磁盘组的一部分,但是asm实例依然在磁盘组 中保留该磁盘的成员信息,可以使用force参数将该磁盘加入磁盘组。当drop的使用force,那么加入的时候使用force参数,如果在删除的时候没有使用force,那么就不使用force(或是noforce)。

The CREATE DISKGROUP statement mounts the disk group for the first time, and adds the disk group name to the ASM_DISKGROUPS initialization parameter if a server parameter file is being used. If a text initialization parameter file is being used and you want the disk group to be automatically mounted at instance startup, then you must remember to add the disk group name to the ASM_DISKGROUPS initialization parameter before you shut down and restart the Oracle ASM instance.

由于我是采用asmlib的方式管理asm磁盘,因此需要创建asm磁盘,如果采用/dev/udev绑定磁盘的方式,那么需要在/etc/udev/rules.d/xxx写相关策略保证在系统重启后设备名和磁盘组名对应关系,防止变化。

创建asm磁盘:

[root@oracle-one ~]# /etc/init.d/oracleasm createdisk ASMDISK7 /dev/sdj1Marking disk 'ASMDISK7' as an ASM disk: [ OK ][root@oracle-one ~]# /etc/init.d/oracleasm createdisk ASMDISK8 /dev/sdk1Marking disk 'ASMDISK8' as an ASM disk: [ OK ][root@oracle-one ~]# /etc/init.d/oracleasm createdisk ASMDISK9 /dev/sdl1Marking disk 'ASMDISK9' as an ASM disk: [ OK ][root@oracle-one ~]# /etc/init.d/oracleasm createdisk ASMDISK10 /dev/sdm1Marking disk 'ASMDISK10' as an ASM disk: [ OK ][root@oracle-one ~]#

查看创建磁盘信息:

SQL> select name,state,path from v$asm_disk;NAME STATE PATH------------------------- -------- ---------------------------------------- NORMAL /dev/oracleasm/disks/ASMDISK10 NORMAL /dev/oracleasm/disks/ASMDISK9 NORMAL /dev/oracleasm/disks/ASMDISK8 NORMAL /dev/oracleasm/disks/ASMDISK7 NORMAL /dev/oracleasm/disks/ASMDISK4 NORMAL /dev/oracleasm/disks/ASMDISK2 NORMAL /dev/oracleasm/disks/ASMDISK3DATAGROUP2_0002 NORMAL /dev/oracleasm/disks/ASMDISK6DATAGROUP2_0001 NORMAL /dev/oracleasm/disks/ASMDISK5DATAGROUP2_0000 NORMAL /dev/oracleasm/disks/ASMDISK110 rows selected.SQL>

创建不指定故障组的磁盘组:

如果在创建磁盘组的时候不指定故障组,那么会默认将每个磁盘作为一个故障组:

There are always failure groups even if they are not explicitly created. If you do not specify a failure group for a disk, then Oracle automatically creates a new failure group containing just that disk, except for disk groups containing disks on Oracle Exadata cells.

eg:

SQL> create diskgroup datagroup3 normal redundancy 2 disk'/dev/oracleasm/disks/ASMDISK7' NAME DATAGROUP3_DISK7, 3 4 '/dev/oracleasm/disks/ASMDISK8' NAME DATAGROUP3_DISK8, 5 '/dev/oracleasm/disks/ASMDISK9' NAME DATAGROUP3_DISK9, 6 '/dev/oracleasm/disks/ASMDISK10' NAME DATAGROUP3_DISK10 7 ATTRIBUTE 'au_size'='1M', 8 'compatible.rdbms'='11.2', 9 'compatible.asm'='11.2', 10 'sector_size'='512';Diskgroup created.SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 980 NORMAL DATAGROUP3_DISK10 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 977 NORMAL DATAGROUP3_DISK7 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 980 NORMAL DATAGROUP3_DISK8 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 978 NORMAL DATAGROUP3_DISK9 REGULAR /dev/oracleasm/disks/ASMDISK9SQL>

指定故障组创建磁盘组:

eg:

SQL> create diskgroup datagroup3 normal redundancy 2 failgroup failgroup_1 disk 3 '/dev/oracleasm/disks/ASMDISK7' NAME DATAGROUP3_DISK7 4 failgroup failgroup_2 disk 5 '/dev/oracleasm/disks/ASMDISK8' NAME DATAGROUP3_DISK8, 6 '/dev/oracleasm/disks/ASMDISK9' NAME DATAGROUP3_DISK9 7 failgroup failgroup_3 disk'/dev/oracleasm/disks/ASMDISK10' NAME DATAGROUP3_DISK10 8 9 ATTRIBUTE 'au_size'='1M','compatible.rdbms'='11.2', 10 11 'compatible.asm'='11.2', 12 'sector_size'='512';Diskgroup created.SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 993 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 990 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL>

A quorum failure group is not considered when determining redundancy requirements in respect to storing user data. However, a quorum failure group counts when mounting a disk group.

注意故障磁盘组有两种一种是quorum一种是regular,不同之处是quorum不包含用户数据。

如创建quorum故障组的磁盘组:

eg:

SQL> drop diskgroup datagroup3 including contents;Diskgroup dropped.SQL> create diskgroup datagroup3 normal redundancy 2 failgroup failgroup_1 disk 3 '/dev/oracleasm/disks/ASMDISK7' NAME DATAGROUP3_DISK7 4 failgroup failgroup_2 disk 5 '/dev/oracleasm/disks/ASMDISK8' NAME DATAGROUP3_DISK8, 6 '/dev/oracleasm/disks/ASMDISK9' NAME DATAGROUP3_DISK9quorum failgroup failgroup_3 disk 7 8 '/dev/oracleasm/disks/ASMDISK10' NAME DATAGROUP3_DISK10 9 ATTRIBUTE 'au_size'='1M', 10 'compatible.rdbms'='11.2', 11 'compatible.asm'='11.2', 12 'sector_size'='512';Diskgroup created.SQL> SQL> SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 1017 NORMAL FAILGROUP_3 QUORUM /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 992 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 991 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL>

(四)删除磁盘组

对于磁盘组使用alter diskgroup命令进行相应维护,但在磁盘组中无论是删除磁盘、添加磁盘还是重置磁盘大小,那么都是在线的不影响正常使用。在每次磁盘组信息进行改变的时候oracle都会自动的rebalance磁盘组中的数据,当我们执行alter diskgroup 之后的sql命令执行提示,并不是在完成rebalance数据之后才返回的。而是数据的rebalance是在后台进行的,如果要等到平衡数据完成 后才告知命令执行情况,可以考虑添加rebalance wait参数。另外要注意,当我们使用alter diskgoup命令的时候突然按ctrl+c,那么oracle是不会取消磁盘的删除、添加、重定义大小和平衡操作。而是在后台执行。

删除磁盘组中的磁盘:

eg:

SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 1017 NORMAL FAILGROUP_3 QUORUM /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 992 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 991 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL> alter diskgroup datagroup3 drop disk DATAGROUP3_DISK10;SQL> alter diskgroup datagroup3 drop disk datagroup3_disk7;Diskgroup altered.SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 1017 NORMAL FAILGROUP_3 QUORUM /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 DROPPING FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 992 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 991 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL>

当我们进行磁盘组操作的时候,如果在删除磁盘的时候需要取消,那么可以使用alter diskgroup undrop disks命令,以此进行取消,类似于此时的磁盘数据restore

如下当磁盘状态是droping的时候,再次执行undrop;

eg:

SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 1017 NORMAL FAILGROUP_3 QUORUM /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 DROPPING FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 992 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 991 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL> r 1 SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4* AND B.NAME LIKE 'DATAGROUP3%'G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 1017 NORMAL FAILGROUP_3 QUORUM /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 DROPPING FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 992 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 991 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL> alter diskgroup datagroup3 undrop disks;Diskgroup altered.SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 1017 NORMAL FAILGROUP_3 QUORUM /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 992 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 991 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL>

删除故障组中的所有磁盘:

注意:

A normal redundancy disk group must contain at least two failure groups. A high redundancy disk group must contain at least three failure groups.

eg:

SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 994 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 989 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL> alter diskgroup datagroup3 drop disks in failgroup failgroup_2;Diskgroup altered.SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 1003 DROPPING FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 999 DROPPING FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL> r 1 SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4* AND B.NAME LIKE 'DATAGROUP3%'G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 1017 DROPPING FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 1017 DROPPING FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL> r 1 SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4* AND B.NAME LIKE 'DATAGROUP3%'G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK8 0 1019 966 DROPPING FAILGROUP_2 REGULARDATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK9 0 1019 966 DROPPING FAILGROUP_2 REGULARSQL> r 1 SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4* AND B.NAME LIKE 'DATAGROUP3%'G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10SQL>

另外,如果删除磁盘组的磁盘,那么该磁盘组将故障磁盘的数据进行再次平衡,这时要保证磁盘空间足以容纳故障磁盘的数据进行镜像,否则会失败。至此可以通过添加磁盘和删除磁盘both的形式,保证磁盘组有足够的空间完成数据的rebalance。

eg:

SQL> r 1 SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4* AND B.NAME LIKE 'DATAGROUP3%'G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10SQL> alter diskgroup datagroup3 drop disk datagroup3_disk10 add failgroup failgroup_2 disk '/dev/oracleasm/disks/ASMDISK8';Diskgroup altered.SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_0001 1019 1019 966 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7SQL>

If you specify the FORCE clause for the drop operation, the disk is dropped even if Oracle ASM cannot read or write to the disk. You cannot use the FORCE flag when dropping a disk from an external redundancy disk group.

Caution:A DROP FORCE operation leaves data at reduced redundancy until the subsequent rebalance operation completes. This increases your exposure to data loss if there is a subsequent disk failure during rebalancing. Use DROP FORCE with caution.

(五)向磁盘组中添加磁盘和故障组

当向现有的磁盘组添加磁盘的时候也是在线的rebalance数据,可以通过v$asm_operation视图查看进度:

eg:

SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_0001 1019 1019 966 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7SQL> alter diskgroup datagroup3 add disk '/dev/oracleasm/disks/ASMDISK9' NAME datagroup3_disk9 ;Diskgroup altered.SQL> select b.group_number group_number, a.name name, 2 3 b.operation operation, 4 b.state state, 5 b.power power, 6 b.actual actual, 7 b.sofar sofar, 8 b.est_work ext_work, 9 b.est_rate est_rate, 10 b.est_minutes est_minutes 11 from v$asm_diskgroup a, v$asm_operation b 12 where a.group_number = b.group_number 13 and a.name like 'DATAGROUP3%';GROUP_NUMBER NAME OPERA STAT POWER ACTUAL SOFAR EXT_WORK EST_RATE EST_MINUTES------------ ------------------------- ----- ---- ---------- ---------- ---------- ---------- ---------- ----------- 2 DATAGROUP3 REBAL RUN 2 2 2 69 265 0SQL>

可以看到,目前添加磁盘组的状态为rebalance,正在运行run,当时平衡力度为2,正常使用的为2,目前平衡了2个au,需要69个au进行rebalance,每分钟可以完成265个au的平衡。

添加故障组:

eg:

SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_0001 1019 1019 966 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 966 NORMAL DATAGROUP3_DISK9 REGULAR /dev/oracleasm/disks/ASMDISK9SQL> ALTER DISKGROUP DATAGROUP3 ADD FAILGROUP FAILGROUP_4 DISK '/dev/oracleasm/disks/ASMDISK10';Diskgroup altered.SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_0003 1019 1019 982 NORMAL FAILGROUP_4 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_0001 1019 1019 977 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 978 NORMAL DATAGROUP3_DISK9 REGULAR /dev/oracleasm/disks/ASMDISK9DATAGROUP3 DATAGROUP3_DISK7 1019 1019 978 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7SQL>

(六)重置大小。

磁盘组的resize有如下情况

1、重置整个磁盘组所有磁盘的大小

eg:

SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_0003 1019 1019 982 NORMAL FAILGROUP_4 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_0001 1019 1019 977 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 978 NORMAL DATAGROUP3_DISK9 REGULAR /dev/oracleasm/disks/ASMDISK9DATAGROUP3 DATAGROUP3_DISK7 1019 1019 978 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7SQL> SQL> SQL> SQL> alter diskgroup datagroup3 resize all size 512M;Diskgroup altered.SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_0003 1019 512 475 NORMAL FAILGROUP_4 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_0001 1019 512 470 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 512 471 NORMAL DATAGROUP3_DISK9 REGULAR /dev/oracleasm/disks/ASMDISK9DATAGROUP3 DATAGROUP3_DISK7 1019 512 471 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7

2、重置磁盘组中指定磁盘的大小

SQL> alter diskgroup datagroup3 resize disk datagroup3_0003 size 1019M;Diskgroup altered.SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER AND B.NAME LIKE 'DATAGROUP3%'; 4 G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_0003 1019 1019 979 NORMAL FAILGROUP_4 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_0001 1019 512 470 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 512 472 NORMAL DATAGROUP3_DISK9 REGULAR /dev/oracleasm/disks/ASMDISK9DATAGROUP3 DATAGROUP3_DISK7 1019 512 473 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7

3、重置磁盘组中指定故障组中所有磁盘的大小。

SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER AND B.NAME LIKE 'DATAGROUP3%'; 4 G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 993 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 990 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL> alter diskgroup datagroup3 resize disks in failgroup failgroup_2 size 512M;Diskgroup altered.SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 512 485 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 512 484 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL>

当指定故障组中一个磁盘大小之后,重新指定故障组所有磁盘大小如果默认没有size,那么将按照最大的操作系统磁盘进行resize 。

If you do not specify a new size in the SIZE clause, then Oracle ASM uses the size of the disk as returned by the operating system.

eg:

SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 512 485 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 512 484 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL> alter diskgroup datagroup3 resize disk datagroup3_disk8 size 1019M;Diskgroup altered.SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 986 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 512 490 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL> alter diskgroup datagroup3 resize disks in failgroup failgroup_2;Diskgroup altered.SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%';G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH--------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ----------------------------------------DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7DATAGROUP3 DATAGROUP3_DISK8 1019 1019 990 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8DATAGROUP3 DATAGROUP3_DISK9 1019 1019 993 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9SQL>

注意:oracle建议故障组大小最好保证一致提高更好的性能实用。

(七)手动平衡数据

可以通过手动执行alter diskgroup rebalance 进行数据的平衡,如果默认情况下不指定power,那么将采用asm_power_limit参数值,如果手动将忽略参数文件中的该参数

如下:

SQL> show parameter asm_power_limit;NAME TYPE VALUE------------------------------------ ----------- ------------------------------asm_power_limit integer 2SQL> alter diskgroup datagroup3 rebalance;Diskgroup altered.SQL> select b.group_number group_number, 2 a.name name, 3 b.operation operation, 4 b.state state, 5 b.power power, 6 b.actual actual, 7 b.sofar sofar, 8 b.est_work ext_work, 9 b.est_rate est_rate, 10 b.est_minutes est_minutes 11 from v$asm_diskgroup a, v$asm_operation b where a.group_number = b.group_number 12 13 and a.name like 'DATAGROUP3%';GROUP_NUMBER NAME OPERA STAT POWER ACTUAL SOFAR EXT_WORK EST_RATE EST_MINUTES------------ ------------------------- ----- ---- ---------- ---------- ---------- ---------- ---------- ----------- 2 DATAGROUP3 REBAL REAP 2 2 0 0 0 0SQL> SQL> alter diskgroup datagroup3 rebalance power 10;Diskgroup altered.SQL> select b.group_number group_number, 2 a.name name, 3 b.operation operation, 4 b.state state, 5 b.power power, 6 b.actual actual, 7 b.sofar sofar, 8 b.est_work ext_work, 9 b.est_rate est_rate, 10 b.est_minutes est_minutes 11 from v$asm_diskgroup a, v$asm_operation b 12 where a.group_number = b.group_number 13 and a.name like 'DATAGROUP3%';GROUP_NUMBER NAME OPERA STAT POWER ACTUAL SOFAR EXT_WORK EST_RATE EST_MINUTES------------ ------------------------- ----- ---- ---------- ---------- ---------- ---------- ---------- ----------- 2 DATAGROUP3 REBAL REAP 10 10 0 0 0 0SQL>

That's all !

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/346996?site
推荐阅读
相关标签
  

闽ICP备14008679号