查看ASM磁盘情况
SQL> select group_number,disk_number,mount_status,header_status,mode_status,state,failgroup,total_mb,free_mb,name,path from v$asm_disk;
查看ASM磁盘组情况
SQL> select group_number,block_size,name,allocation_unit_size,state,type,total_mb,free_mb,offline_disks from v$asm_diskgroup;
创建ASM磁盘
[root@b1 redhat 5.4-64]#/usr/sbin/oracleasm createdisk disk1 /dev/sdb1
[root@b1 redhat 5.4-64]#/usr/sbin/oracleasm createdisk disk2 /dev/sdb2
[root@b1 redhat 5.4-64]#/usr/sbin/oracleasm querydisk /dev/sdb*
Device "/dev/sdb" is not marked as an ASM disk
Device "/dev/sdb1" is marked an ASM disk with the label "DISK1"
Device "/dev/sdb2" is marked an ASM disk with the label "DISK2"
[root@b1 redhat 5.4-64]#/usr/sbin/oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
[root@b1 redhat 5.4-64]#/usr/sbin/oracleasm listdisks
DISK1
DISK2
删除ASM磁盘
[root@b1 ~]#/usr/sbin/oracleasm deletedisk disk4
Clearing disk header: done
创建ASM磁盘组
a、创建外包冗余磁盘组
create diskgroup dg1 external redundancy disk 'ORCL:disk3','ORCL:disk4';
b、创建普通冗余磁盘组(至少两块磁盘)
create diskgroup dg1 normal redundancy failgroup fg1 disk 'ORCL:disk3' failgroup fg2 disk 'ORCL:disk4';
c、创建高冗余磁盘组(至少三块磁盘)
create diskgroup dg1 high redundancy
failgroup fg1 disk 'ORCL:disk3' name dg1_a
failgroup fg2 disk 'ORCL:disk4' name dg1_b
failgroup fg3 disk 'ORCL:disk5' name dg1_c;
删除ASM磁盘组
drop diskgroup dg1;
drop diskgroup dg1 including contents;
向ASM磁盘组中增加磁盘
a、向高冗余磁盘组中添加磁盘成员
alter diskgroup dg1
add failgroup fg1 disk 'ORCL:diskd1'
add failgroup fg2 disk 'ORCL:diskd2'
add failgroup fg3 disk 'ORCL:diskd3';
b、向外部冗余磁盘组中添加磁盘成员
alter diskgroup dg2 add disk 'ORCL:diske2';
从ASM磁盘组中删除磁盘
alter diskgroup dg1 drop disk diskd1,diskd2,diskd3; --删除的时候注意冗余模式,视情况而删除
alter diskgroup dg2 drop disk diske2 add disk 'ORCL:DISKE3'; --删除磁盘时同时添加磁盘,可减少重平衡次数
删除故障组(即删除故障组中的所有磁盘)
alter diskgroup dg1 drop disks in failgroup fg3;
添加故障组
alter diskgroup dg1 add failgroup fg3 disk 'ORCL:disk5';
删除磁盘时同时添加故障组
alter diskgroup dg1 drop disks in failgroup fg3 add failgroup fg4 disk 'ORCL:disk6';
停止磁盘从一个磁盘组中删除‘
ALTER DISKGROUP dgroup_01 UNDROP DISKS;
平衡磁盘数据
alter diskgroup dg1 rebalance;
alter diskgroup dg1 rebalance wait; --wait即等到数据平衡结束才在命令行提示结束
alter diskgroup dg1 rebalance power 11;
停止平衡磁盘数据
alter diskgroup dg1 rebalance power 0;
挂载和卸载磁盘组
alter diskgroup dg1 mount;
alter diskgroup dg1 dismount;
alter diskgroup dg1 dismount force;
重置磁盘大小
ALTER DISKGROUP dg1 RESIZE ALL SIZE 512M; --把dg1中所有磁盘置为512M
ALTER DISKGROUP dg1 RESIZE disk diskd4 SIZE 564M;
检测磁盘组一致性
ALTER DISKGROUP dg1 CHECK ALL;
ALTER DISKGROUP dg1 CHECK ALL REPAIR;--检测一致性,并修复错误
ASM目录管理
增加目录
SQL> alter diskgroup DG2 add directory '+DG2/datafile';
重命名目录
SQL> alter diskgroup DG2 rename directory '+DG2/datafile' to '+DG2/datafiles';
删除目录
SQL> alter diskgroup DG2 drop directory '+DG2/datafiles';
ASM别名管理
asm文件添加别名
SQL> alter diskgroup data add alias '+data/c1/datafile/system01.dbf' for '+data/c1/datafile/SYSTEM.260.803945885';
Diskgroup altered.
asm文件修改别名
alter diskgroup data rename alias '+data/c1/datafile/system01.dbf' to '+data/c1/datafile/system02.dbf';
asm文件删除别名
alter diskgroup DG1 drop alias '+data/c1/datafile/system02.dbf';
ASM模板管理
查看默认asm模板的冗余级别和条带化
select * from v$asm_template;
查看以使用的模板
select name,redundancy,striped
from v$asm_alias a,v$asm_file b
where a.file_number=b.file_number
and a.group_number=b.group_number
order by a.file_number;
创建asm模板的语法
ALTER DISKGROUP disk_group_name ADD TEMPLATE template_name
ATTRIBUTES ([{MIRROR|HIGH|UNPROTECTED}] [{FINE|COARSE}]);
--attributes:第一列指冗余,第二列指条带
创建模板
alter diskgroup dg1 add template template1 attributes (high fine);
alter diskgroup dg1 add template template2 attributes (unprotected coarse);
修改模板
alter diskgroup dg1 alter template template1 attributes (coarse);
删除模板
alter diskgroup dg1 drop template template1;
使用模板
create tablespace test datafile '+DG1(template1)' size 50M;