查看ASM磁盤狀況oracle
SQL> select group_number,disk_number,mount_status,header_status,mode_status,state,failgroup,total_mb,free_mb,name,path from v$asm_disk;spa
查看ASM磁盤組狀況
SQL> select group_number,block_size,name,allocation_unit_size,state,type,total_mb,free_mb,offline_disks from v$asm_diskgroup;.net
建立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 orm
刪除ASM磁盤blog
[root@b1 ~]#/usr/sbin/oracleasm deletedisk disk4
Clearing disk header: doneip
建立ASM磁盤組it
a、建立外包冗餘磁盤組io
create diskgroup dg1 external redundancy disk 'ORCL:disk3','ORCL:disk4';asm
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;
轉自:http://blog.csdn.net/laoshangxyc/article/details/12320901