ASM中添加磁盘组:
例如,我们原来RAC环境中归档日志放在本机上,现在希望添加一个ASM磁盘组FAL2,把归档放到共享ASM磁盘组中:
在有asm lib的情况下,添加磁盘组,需要先创建asm磁盘,以root权限执行 /etc/init.d/oracleasm create。
#/etc/init.d/oracleasm createdisk  VOL3 /dev/sda9
# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
 
$export ORACLE_SID=orcl1
$export ORACLE_HOME=$ORA_ASM_HOME
$sqlplus /nolog
SQL> conn /as sysdba
Connected.
SQL> create diskgroup FAL2 external redundancy disk 'ORCL:VOL3';
Diskgroup created.
SQL> select name,state from v$asm_diskgroup;
NAME                   STATE
------------------------------ -----------
DATA                   MOUNTED
FAL2                   MOUNTED
FLA                     MOUNTED
注意:本例中是单节点,添加磁盘组以后ASM会把磁盘组自动mount,如果有其他节点,需要在其他节点手工把磁盘组mount上:alter diskgroup fal2 mount;
编辑$ORACLE_BASE/admin/+ASM/pfile/init.ora,找到asm_diskgroups= 添加'FAL2‘,使磁盘组能够被自动挂载。
更改归档路径:
$sqlplus /nolog
SQL>alter system set log_archive_dest_1='location=+FAL2/'
磁盘组中添加磁盘:
ASM磁盘组支持动态扩展,我们可以向现有的磁盘组动态加入新的磁盘,新磁盘加入后,Oracle通过后台RBAL进行Rebalance,将当前的数据均衡到新增加的磁盘上。Drop磁盘亦会Rebalance。
asm_power_limit 参数用于控制Rebalance的速度,取值1~11,数字越大,平衡速度越快,默认值是1。如果该数字很大,则可能因为Rebalance而影响性能。
也可以通过在alter diskgroup .. add/drop disk命令中通过rebalance power [1~11]选项控制Rebalance的速度。

Ora10gASM-> sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 28 20:11:39 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> col name format a15
SQL> col failgroup format a20
SQL> col path format a30
SQL> select name,failgroup,path from v$asm_disk;

NAME FAILGROUP PATH
--------------- -------------------- ------------------------------
ORCL:VOL4
VOL1 VOL1 ORCL:VOL1
VOL2 VOL2 ORCL:VOL2
VOL3 VOL3 ORCL:VOL3

SQL> select name from v$asm_diskgroup;

NAME
---------------
DATA
FRA
DATA2

SQL> select name,total_mb,free_mb from v$asm_disk;

NAME TOTAL_MB FREE_MB
--------------- ---------- ----------
511 0
VOL1 4094 1872
VOL2 4094 3867
VOL3 511 358

加入磁盘ORCL:VOL4到DATA2磁盘组

SQL> alter diskgroup DATA2 add disk 'ORCL:VOL4' rebalance power 1;
Diskgroup altered.

Rebalance后磁盘空间使用情况

SQL> select name,total_mb,free_mb from v$asm_disk;

NAME TOTAL_MB FREE_MB
--------------- ---------- ----------
VOL1 4094 1872
VOL2 4094 3867
VOL3 511 433
VOL4 511 434

Drop 磁盘操作

SQL> select name,failgroup,path from v$asm_disk;
NAME FAILGROUP PATH
--------------- -------------------- ------------------------------
VOL1 VOL1 ORCL:VOL1
VOL2 VOL2 ORCL:VOL2
VOL3 VOL3 ORCL:VOL3
VOL4 VOL4 ORCL:VOL4

SQL> alter diskgroup DATA2 drop disk 'VOL4' rebalance power 11;
Diskgroup altered.

SQL> select name,failgroup,path from v$asm_disk;
NAME FAILGROUP PATH
--------------- -------------------- ------------------------------
VOL1 VOL1 ORCL:VOL1
VOL2 VOL2 ORCL:VOL2
VOL3 VOL3 ORCL:VOL3
VOL4 VOL4 ORCL:VOL4

SQL> select name,total_mb,free_mb from v$asm_disk;
NAME TOTAL_MB FREE_MB
--------------- ---------- ----------
511 0
VOL1 4094 1872
VOL2 4094 3867
VOL3 511 358

SQL> select name,failgroup,path from v$asm_disk;
NAME FAILGROUP PATH
--------------- -------------------- ------------------------------
ORCL:VOL4
VOL1 VOL1 ORCL:VOL1
VOL2 VOL2 ORCL:VOL2
VOL3 VOL3 ORCL:VOL3

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Ora10gASM-> ps -ef | grep rbal
oracle 5291 1 0 19:30 ? 00:00:03 asm_rbal_+ASM
oracle 5469 1 0 19:44 ? 00:00:01 ora_rbal_benbo
oracle 5970 4700 0 20:25 pts/1 00:00:00 grep rbal
Ora10gASM->
删除磁盘组
1、如果要删除的磁盘组中有数据文件,需要先把数据文件迁移到其他的磁盘组中:
SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/orcl/datafile/system.260.675705525
+DATA/orcl/datafile/undotbs1.264.675705527
+DATA/orcl/datafile/sysaux.265.675705527
+DATA/orcl/datafile/users.263.675705527
+FAL2/orcl/datafile/hxre.277.675956263
比如,我们把+FAL2/orcl/datafile/hxre.277.675956263迁移到+DATA磁盘组中
利用RMAN迁移数据文件:
$rman target sys/oracle@orcl
RMAN> sql "alter database datafile 5 offline";

sql statement: alter database datafile 5 offline

RMAN> run
2> {
3> copy datafile 5 to '+DATA';
4> }                               
通过asmcmd查看一下在+DATA中数据文件的名称,然后用rman switch datafile
RMAN> run
2> {
3> switch datafile 5 to datafilecopy '+DATA/ORCL/DATAFILE/HXRE.266.676029249';
4> }
RMAN>recover datafile 5;
RMAN>sql "alter database datafile 5 online";
2、删除磁盘组:
$export ORACLE_SID=+ASM1
$export ORACLE_HOME=$ORA_ASM_HOME
$sqlplus /nolog
>conn /as sysdba
>drop diskgroup FAL2 including contents;
3、编辑$ORACLE_BASE/admin/+ASM/pfile/init.ora删除FAL2
======================================================
,在启动asm实例的时候提示:
 ORA-29701 :unable to connect to Cluster Manager 的处理方法:
--------
Please run the following batch files in the $ORACLE_HOME/bin directory
localconfig delete
localconfig add
This will help you to solve your problem
问题解决了,asm实例可以启动了
--------------------