正好刚整理了一个这方面的资料,先贴给你吧. 准备ASM环境 ASM使用一个名叫“+ASM”的数据库实例来管理ASM磁盘,因此在配置ASM磁盘之前,需要先启动ASM实例。另外还需要注意,ASM 实例必须要先于数据库实例启动,和数据库实例同步运行,迟于数据库实例关闭。ASM 实例的创建和删除可以用DBCA 工具来操作。在DBCA的第一个界面选择配置自动存储管理就可以进入ASM配置的界面。 根据提示运行脚本就可以配置和启动CSS(Cluster Synchronization Service)了,注意要以root的身份运行这个脚本,运行情况如下: # /u01/app/oracle/product/10.2.0/db_1/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. s1 CSS is active on all nodes. Oracle CSS service is installed and running under init(1M) ASM可以使用裸设备或者ASMLib方式, 因为裸设备的维护更罗嗦一些,本文只讨论ASMLib方式。为了在Linux系统中使用ASMLib方式准备ASM磁盘,需要安装相关的软件,下载链接如下:
# rpm -ivh oracleasm* 现在安装oracleasm模块可能会报错,像我因为没有找到对应我的内核版本的oracleasm软件就遇到了这个问题。经过一番查找,发现软件将oracleasm的模块文件oracleasm.ko安装到了目录/lib/modules/2.6.18-164.el5/kernel/drivers/addon/oracleasm中,而我的默认的模块文件路径应该是/lib/modules/2.6.18-155.el5,因此决定手工建立相关的目录和文件。 # mkdir -p /lib/modules/2.6.18-155.el5/kernel/drivers/addon/oracleasm # cp oracleasm.ko /lib/modules/2.6.18-155.el5/kernel/drivers/addon/oracleasm 然后再安装oracleasm的模块文件就可以通过了: # depmod -a # modprobe oracleasm 最后进行oracleasm服务的初始配置 # service 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]: Writing Oracle ASM library driver configuration: done Initializing the Oracle ASMLib driver: [ OK ] Scanning the system for Oracle ASMLib disks: [ OK ] 好了,现在已经有了初步的ASM配置环境,接下来就可以准备磁盘了。 添加ASM磁盘组 为了实现ASM的磁盘负载均衡和冗余能力,我准备使用四个磁盘建立ASM的磁盘组,因此需要为Linux系统添加四个磁盘。为了搭建这个环境,我使用的是VMware环境,因此添加磁盘就非常容易了。只需要在VMware的设置中选择添加硬件即可,而且现在的VMware版本是可以支持磁盘的热插拔的。无需关闭Linux系统,直接添加磁盘即可。添加完四个磁盘之后,为了让Linux系统马上识别这几个磁盘,可以运行如下命令: # echo 'scsi add-single-device 0 0 1 0' > /proc/scsi/scsi # echo 'scsi add-single-device 0 0 2 0' > /proc/scsi/scsi # echo 'scsi add-single-device 0 0 3 0' > /proc/scsi/scsi # echo 'scsi add-single-device 0 0 4 0' > /proc/scsi/scsi 运行fdisk -l命令可以看到系统中增加了/dev/sdb、/dev/sdc、/dev/sdd、/dev/sde四个磁盘。使用fdisk工具在这个四个磁盘上各建立一个分区(具体步骤略,不熟悉的可以查阅Linux的fdisk命令用法)。 然后运行oracleasm createdisk命令添加ASM磁盘: # oracleasm createdisk VOL1 /dev/sdb1 Writing disk header: done Instantiating disk: done 依次添加/dev/sdb1、/dev/sdc1、/dev/sdd1、/dev/sde1四个磁盘分区,完成后检查如下: # oracleasm listdisks VOL1 VOL2 VOL3 VOL4 这时运行DBCA工具的ASM配置向导就可以建立ASM磁盘组了。进入DBCA向导后,选择“Configure Automatic Storage Management”,然后单击“Create New”按钮,可以看到ASM磁盘组的配置界面。输入磁盘组的名称,如“dg1”,关于冗余级别,我选择了Norma,并且将VOL1和VOL2设置为一个Failure Group,而VOL3和VOL4设置为一个Failure Group。 以上操作也可以使用sqlplus连接到ASM实例上,使用命令完成。 为了连接到ASM实例上,首先需要设置ORACLE_SID环境变量,然后再使用sqlplus进行连接:
# ORACLE_SID=+ASM # sqlplus / as sysdba 创建Disk Group的语句如下: SQL> create diskgroup dg1 normal redundancy failgroup fg1 disk 'ORCL:VOL1','ORCL:VOL2' failgroup fg2 disk 'ORCL:VOL3','ORCL:VOL4'; 至此,ASM磁盘组的准备已经完成,终于可以在ASM上建立数据库了。还是使用DBCA工具,选择“Create Database”进入创建数据库的向导。按照向导操作,只是在选择存储机制时,选择ASM类型。