1> 操作系统版本:
[root@node1 oracle]# uname -a
Linux node1.cn1 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:21 EST 2007 i686 i686 i386 GNU/Linux

2> 安装oracleasmlib程序包。从OTN下载ASM库,并以root用户身份安装ASM RPM。
http://www.oracle.com/technetwork/topics/linux/asmlib/index-101839.html
下载软件包:
 oracleasm-2.6.18-8.el5-2.0.4-1.el5.i686.rpm
 oracleasmlib-2.0.4-1.el5.i386.rpm
 oracleasm-support-2.1.7-1.el5.i386.rpm

3> 查询软件包是否被安装,安装软件包:
[root@node1 opt]# rpm -qa |grep oracleasm
[root@node1 opt]# rpm -ivh oracleasmlib-2.0.4-1.el5.i386.rpm oracleasm-support-2.1.7-1.el5.i386.rpm oracleasm-2.6.18-8.el5-2.0.4-1.el5.i686.rpm
4> 查询安装结果:
[root@node1 opt]# rpm -qa |grep oracleasm
oracleasm-2.6.18-8.el5-2.0.4-1.el5
oracleasm-support-2.1.7-1.el5
oracleasmlib-2.0.4-1.el5
5> 配置ASMLib
[root@node1 /]# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets ('[]').  Hitting <ENTER> without typing an
answer will keep that current value.  Ctrl-C will abort.
Default user to own the driver interface []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver:                     [  OK  ]
Scanning the system for Oracle ASMLib disks:               [  OK  ]

注:启用或禁用oracleasm自动启动方法:
# /etc/init.d/oracleasm disable
# /etc/init.d/oracleasm enable

6> 开启CSS服务
[root@node1 /]# /u01/oracle/product/10g/bin/localconfig add
/etc/oracle does not exist. Creating it now.
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Configuration for local CSS has been initialized
Adding to inittab
Startup will be queued to init within 90 seconds.
Checking the status of new Oracle init process...
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
 node1
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)

7> 物理磁盘分区
[root@node1 /]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 1044.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): +2048M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (251-1044, default 251):
Using default value 251
Last cylinder or +size or +sizeM or +sizeK (251-1044, default 1044): +2048M

Command (m for help): P
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         250     2008093+  83  Linux
/dev/sdb2             251         500     2008125   83  Linux

Command (m for help): W
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@node1 /]# fdisk -l
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         250     2008093+  83  Linux
/dev/sdb2             251         500     2008125   83  Linux

8> 创建ASM磁盘
[root@node1 /]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk "VOL1" as an ASM disk:                        [  OK  ]
[root@node1 /]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdb2
Marking disk "VOL2" as an ASM disk:                        [  OK  ]

注:删除磁盘语句:
# /etc/init.d/oracleasm deletedisk VOL1
查看ASM磁盘
[root@node1 /]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
[root@node1 /]# /etc/init.d/oracleasm querydisk -p VOL1
Disk "VOL1" is a valid ASM disk
/dev/sdb1: LABEL="VOL1" TYPE="oracleasm"

9> 创建初始化参数文件
注:asm_diskstring必需配置成'ORCL:'开头.
# su - oracle
$ export ORACLE_SID=+ASM
$ vi $ORACLE_HOME/dbs/init$ORACLE_SID.ora
asm_diskstring='ORCL:*'
background_dump_dest='/u01/oracle/product/admin/+ASM/bdump'
core_dump_dest='/u01/oracle/product/admin/+ASM/cdump'
user_dump_dest='/u01/oracle/product/admin/+ASM/udump'
instance_type='asm'
large_pool_size=12M
remote_login_passwordfile='SHARED'

10> 建立密码文件
[oracle@node1 10g]$ $ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password='oracledb' force=y

11> 建立需要的目录
[oracle@node1 oracle]$ mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/bdump
[oracle@node1 oracle]$ mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/cdump
[oracle@node1 oracle]$ mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/udump

12> 启动ASM实例
[oracle@node1 oracle]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Sep 16 11:36:17 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size      1217836 bytes
Variable Size     57502420 bytes
ASM Cache     25165824 bytes
ORA-15110: no diskgroups mounted
注:首次启动ASM实例, 还没有创建diskgroup, 所以显示15110 错误是正常的.

13> 创建SPFILE文件
SQL> create spfile from pfile; (会自动读取pfile:$ORACLE_HOME/dbs/init$ORACLE_SID.ora)

14> 创建磁盘组:DATA1
SQL> create diskgroup data1 normal redundancy
  2  failgroup fg1 disk 'ORCL:VOL1' name VOL1
  3  failgroup fg2 disk 'ORCL:VOL2' name VOL2;

SQL> select name,state,total_mb,free_mb from v$asm_diskgroup;

NAME          STATE      TOTAL_MB  FREE_MB
------------------------------ ----------- ---------- ----------
DATA1          MOUNTED   3922     3820

注:若没有自动挂在,则需要手工挂载或者卸载:
SQL>alter diskgroup all dismount;
SQL>alter diskgroup all mount;
SQL> alter diskgroup DATA1 dismount;  
SQL> alter diskgroup DATA1 mount; 

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

NAME          STATE   TOTAL_MB    FREE_MB MODE_ST
------------------------------ -------- ---------- ---------- -------
VOL1          NORMAL       1961  1910 ONLINE
VOL2          NORMAL       1961  1910 ONLINE

SQL> show parameter asm

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups        string  DATA1
asm_diskstring        string  ORCL:*
asm_power_limit        integer  1
SQL>shutdown immediate;

添加删除磁盘
为diskgroup增加disk
SQL> alter diskgroup DATA1 add disk  'ORCL:VOL1' name VOL1,'ORCL:VOL2' name VOL2;
从diskgroup删除disk
SQL> alter diskgroup DATA1 drop disk VOL1;
取消删除disk的命令,只能在上述命令没执行完成的时候有效
ALTER DISKGROUP DATA1 UNDROP DISKS;

 检查配置情况:
# /etc/init.d/oracleasm querydisk VOL1
# /etc/init.d/oracleasm querydisk /dev/sdb1
# /etc/init.d/oracleasm listdisks
# ls -l /dev/oracleasm/disks/*
# /etc/init.d/oracleasm status

SQL>alter diskgroup dskgrp1 rebalance power 5;
SQL>select * from v$asm_diskgroup;
SQL>select * from v$asm_disk;
SQL>select * from v$asm_client;
SQL>select * from v$asm_file;
SQL>select * from v$asm_operation;
SQL>select group_number, name, TOTAL_MB, FREE_MB from V$asm_disk_stat;

启动 ASM 数据库的步骤
由于启动 ASM 数据库必须要先启动ASM 实例, 所以基本上启动步骤如下.
先启动ASM实例
$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
SQL> startup;
SQL> exit;

再启动数据库
$ export ORACLE_SID=oradb
$ sqlplus / as sysdba
SQL> startup;
SQL> exit;