日期:2014-05-16  浏览次数:20523 次

Oracle ASM操作管理

查看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 pow