然后,通過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的組織信息。