在SQLPLUS中对ASM实例进行操作

 

1、查看ASM磁盘组状况

SELECT GROUP_NUMBER, NAME, TYPE, STATE, TOTAL_MB, FREE_MB, OFFLINE_DISKS FROM V$ASM_DISKGROUP;

GROUP_NUMBER NAME       TYPE   STATE         TOTAL_MB    FREE_MB OFFLINE_DISKS

------------ ---------- ------ ----------- ---------- ---------- -------------

           1 DG1        NORMAL MOUNTED         102365     102208

 

2、查看ASM磁盘信息

SELECT GROUP_NUMBER, DISK_NUMBER, LABEL, STATE, FAILGROUP, NAME, PATH, TOTAL_MB, FREE_MB FROM V$ASM_DISK;

GROUP_NUMBER DISK_NUMBER LABEL STATE    FAILGROUP  NAME

------------ ----------- ----- -------- ---------- ----------

PATH                        TOTAL_MB    FREE_MB

------------------------- ---------- ----------

           1           4       NORMAL   DG1_0004   DG1_0004

/dev/oracleasm/disks/D5        20473      20443

           1           3       NORMAL   DG1_0003   DG1_0003

/dev/oracleasm/disks/D4        20473      20443

           1           2       NORMAL   DG1_0002   DG1_0002

/dev/oracleasm/disks/D3        20473      20442


GROUP_NUMBER DISK_NUMBER LABEL STATE    FAILGROUP  NAME

------------ ----------- ----- -------- ---------- ----------

PATH                        TOTAL_MB    FREE_MB

------------------------- ---------- ----------

           1           1       NORMAL   DG1_0001   DG1_0001

/dev/oracleasm/disks/D2        20473      20439

           1           0       NORMAL   DG1_0000   DG1_0000

/dev/oracleasm/disks/D1        20473      20441

3、增加磁盘组:

CREATE DISKGROUP dgd NORMAL REDUNDANCY

FAILGROUP failgroup1 DISK

'/dev/raw/raw1' NAME diskA1 SIZE 120G FORCE,

'/dev/raw/raw2',

'/dev/raw/raw3'

FAILGROUP failgroup2 DISK

'/dev/raw/raw4',

'/dev/raw/raw5',

'/dev/raw/raw6';


4、增加fail组:

ALTER DISKGROUP dg1 ADD FAILGROUP fail3 DISK '/dev/raw/raw22' name disk5 REBALANCE POWER 11;


5、添加ASM磁盘:

ALTER DISKGROUP dg1 add failgroup fail1 DISK '/dev/raw/raw19' name disk3;


6、删除ASM磁盘:

ALTER DISKGROUP dg1 DROP DISK disk4;


7、卸载磁盘组,要先关闭安装在ASM上的rdbms数据库实例

ALTER DISKGROUP dg2 DISMOUNT;


8、检测磁盘组或磁盘:

ALTER DISKGROUP dg1 CHECK ALL;

ALTER DISKGROUP DG1 CHECK DISK VOL1;


7、控制均衡容错组数据的速度:

ALTER DISKGROUP dg2 REBALANCE POWER 11;

平衡速度控制参数:

asm_power_limit = 1~11


8、检查数据库平衡速度:

SELECT GROUP_NUMBER, OPERATION, STATE, EST_WORK, SOFAR, EST_RATE, EST_MINUTES FROM V$ASM_OPERATION;


9、删除磁盘组:

DROP DISKGROUP GROUP1 INCLUDING CONTENTS;


10、取消删除:

ALTER DISKGROUP group1 UNDROP DISKS;


11、添加目录:

ALTER DISKGROUP DG1 ADD DIRECTORY '+DG1/ad';

CREATE TABLESPACE T1 DATAFILE '+DG1/ad/t1.dbf' SIZE 100M AUOEXTEND ON;


12、重命名目录:表空间不受任何影响

ALTER DISKGROUP DG1 RENAME DIRECTORY '+DG1/ad' to '+DG1/add';


13、删除目录:

ALTER DISKGROUP DG1 DROP DIRECTORY '+DG1/ad/demo' FORCE;


14、创建别名:

ALTER DISKGROUP DG1 ADD ALIAS '+DG1/ad/spfilead.ora' FOR '+DG1/ad/parameterfile/spfile.269.777212438';


15、重命名别名:

alter diskgroup dg1 rename alias '+DG1/ASMDB/spfile.ora' to '+DG1/ASMDB/spfileasmdb.ora';


16、删除别名:删除别名文件不会被删除

DROP DISKGROUP DG1 DROP ALIAS '+DG1/ASMDB/spfileasmdb.ora';