查看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]#
[root@b1 redhat 5.4-64]#
[root@b1 redhat 5.4-64]#
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]#
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
[root@b1 redhat 5.4-64]#
DISK1
DISK2
刪除ASM磁碟
[root@b1 ~]#
Clearing disk header: done
建立ASM磁碟組
a、建立外包冗餘磁碟組
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 dg1 rebalance;
alter diskgroup dg1 rebalance 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;
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}]);
建立模板
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;