然后,通过ASMlib提供的oracleasm将已经划分好的磁盘分区转化为ASM磁盘,例如: [root@node1 ~]#/etc/init.d/oracleasm createdisk ASMDISK1 /dev/sdc5 Marking disk "/dev/sdc5" as an ASM disk [ OK ] [root@node1 ~]#/etc/init.d/oracleasm createdisk ASMDISK2 /dev/sdc6 Marking disk "/dev/sdc6" as an ASM disk [ OK ] [root@node1 ~]#/etc/init.d/oracleasm createdisk ASMDISK3 /dev/sdc7 Marking disk "/dev/sdc7" as an ASM disk [ OK ] [root@node1 ~]#/etc/init.d/oracleasm createdisk ASMDISK4 /dev/sdc8 Marking disk "/dev/sdc8" as an ASM disk [ OK ] [root@node1 ~]#/etc/init.d/oracleasm createdisk ASMdisk5 /dev/sdc9 Marking disk "/dev/sdc9" as an ASM disk [ OK ]
2.启动ASM实例 无论在RAC环境中还是单实例环境,ASM实例都需要用到CSS进程,在RAC环境中,启动CRS后CSS已经运行,而在单实例环境下,需要以root用户运行脚本,初始化CSS服务,否则,在启动ASM实例时会报如下错误: ORA-29701: unable to connect to Cluster Manager 执行初始化脚本的过程如下: [root@node1 ~]#$ORACLE_HOME/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 Cleaning up Network socket directories Setting up Network socket directories Adding to inittab Startup will be queued to init within 30 seconds. Checking the status of new Oracle init process... Expecting the CRS daemons to be up within 600 seconds. Cluster Synchronization Services is active on these nodes. node1 Cluster Synchronization Services is active on all the nodes. Oracle CSS service is installed and running under init(1M)
然后启动ASM实例: [oracle@node1 ~]$export ORACLE_SID=+ASM [oracle@node1 ~]$sqlplus / as sysdba SQL> startup ASM instance started Total System Global Area 134217728 bytes Fixed Size 1218124 bytes Variable Size 107833780 bytes ASM Cache 25165824 bytes ORA-15110: no diskgroups mounted 因为首次启动ASM实例并没有创建ASM磁盘组,所以显示 15110错误是正常的。 3.管理ASM磁盘组 ASM磁盘组是作为逻辑单元进行统一管理的一组磁盘,在ASM实例中,可以创建和添加新的磁盘组,可以修改现有的磁盘组,在其中添加一个磁盘或者删除一个磁盘,也可以删除现有的磁盘组。
(1)添加磁盘组 SQL> create diskgroup FLASH_DISK external redundancy disk '/dev/oracleasm/disks/ASMDISK1' name flashdisk; Diskgroup created. SQL> create diskgroup ARCH_DISK external redundancy disk '/dev/oracleasm/disks/ASMDISK2' name archdisk1; Diskgroup created. SQL> create diskgroup DATA_DISK normal redundancy disk '/dev/oracleasm/disks/ASMDISK4' name datadisk1, '/dev/oracleasm/disks/ASMDISK5' name datadisk2; Diskgroup created.
(2)查看磁盘组状态 SQL> select name,state from v$asm_diskgroup; NAME STATE ------------------- -------------- FLASH_DISK MOUNTED ARCH_DISK MOUNTED DATA_DISK MOUNTED
(3)卸载FLASH_DISK磁盘组 SQL> alter diskgroup FLASH_DISK dismount; Diskgroup altered. SQL> select name,state from v$asm_diskgroup; NAME STATE --------------------------- ----------- FLASH_DISK DISMOUNTED ARCH_DISK MOUNTED DATA_DISK MOUNTED
(4)挂载FLASH_DISK磁盘组 SQL> alter diskgroup FLASH_DISK mount; Diskgroup altered. SQL> select name,state from v$asm_diskgroup; NAME STATE ------------------------------ ----------- FLASH_DISK MOUNTED ARCH_DISK MOUNTED DATA_DISK MOUNTED
(5)查看磁盘名与裸设备对应关系 SQL> select name,path from v$asm_disk_stat; NAME PATH ------------------- -------------------------------------- DATADISK3 /dev/oracleasm/disks/ASMDISK3 DATADISK2 /dev/oracleasm/disks/ASMDISK5 DATADISK1 /dev/oracleasm/disks/ASMDISK4 ARCHDISK1 /dev/oracleasm/disks/ASMDISK2 FLASHDISK /dev/oracleasm/disks/ASMDISK1
(7)备份ASM的metadata ASMCMD> md_backup /u01/oracle/datadisk.bak -G data_disk Disk group to be backed up: DATA_DISK 这样就把ASM的metadata备份到了文件系统上,通过查看datadisk.bak文件可以得知metadata的组织信息。