在oracle11g中,配置asm實例會用到raw(裸設備)或者asmlib或者直接使用磁盤分區(這個特性也是11g的特性)。由於oracle11g中,已經將asm和數據庫完全脫離,這句話的意思就是以前在10g的時候,asm實例是在安裝oracle軟件之後,才配置實例(藉助dbca),而在oracle11g中,asm實例已經由grid單獨安裝來配置了,也是11g中的第一大特性。
Linux 5下的操作:
1) 使用raw設備
在創建3個分區 sda8,sda9,sda10之後,start_udev (具體如何在linux5下創建raw,在此不介紹),從而有了3個raw,即 /dev/raw/raw1 /dev/raw/raw2 /dev/raw/raw3
2) 使用asmlib
在創建了3個分區之後,可以使用如下命令,創建3個asmdisk:
#/etc/init.d/oracleasm createdisk asmdisk01 /dev/sda8
#/etc/init.d/oracleasm createdisk asmdisk02 /dev/sda9
#/etc/init.d/oracleasm createdisk asmdisk03 /dev/sda10
查看asmdisk:
#/etc/init.d/oracleasm listdisks
ASMDISK01
ASMDISK02
ASMDISK03
3) 直接使用磁盤分區,由於這個比較簡單,只需要安裝grid時,測試一下即可。
如上,現在已經建好了兩種方式下的asm可用disk,現在安裝grid的過程中,可能由於磁盤組的問題,最終導致沒有安裝成功,但crs已經沒有問題了,如下:
[grid@yanfa2 dbs]$ crs_stat -t -v
Name Type R/RA F/FT Target State Host
----------------------------------------------------------------------
ora....ER.lsnr ora....er.type 0/5 0/ ONLINE ONLINE yanfa2
ora.cssd ora.cssd.type 0/5 0/5 ONLINE ONLINE yanfa2
ora.diskmon ora....on.type 0/10 0/5 ONLINE ONLINE yanfa2
但asm實例確不能啓動,錯誤信息如下:
SQL> startup
ORA-00099: warning: no parameter file specified for ASM instance
ASM instance started
Total System Global Area 283930624 bytes
Fixed Size 2212656 bytes
Variable Size 256552144 bytes
ASM Cache 25165824 bytes
ORA-15110: no diskgroups mounted
此時有兩個問題,第一個就是沒有asm實例啓動需要的參數文件,目前使用的默認值,還有第二個問題就是沒有diskgroup,用asmcmd也可以查看到,目前實例是沒有diskgroup的。
解決辦法就是用創建diskgroup,可以用asmca,打開頁面之後,能看到6塊disk,其中3塊是/dev/raw/raw* 格式的,另3塊是 ORCL:ASMDISK0* 格式的,如果此時選擇ORCL:這樣的disk,那麼此diskgroup是不會創建成功的,換成用/dev/raw/raw* 的,create asm時就可以成功了。然後在實例起來之後,也可以用命令創建另一個diskgroup,如下:
CREATE DISKGROUP fra EXTERNAL REDUNDANCY DISK 'ORCL:ASMDISK03';
CREATE DISKGROUP fra EXTERNAL REDUNDANCY DISK 'ORCL:ASMDISK03'
*
ERROR at line 1:
ORA-15018: diskgroup cannot be created
ORA-15072: command requires at least 1 failure groups, discovered only 0
此時,再查看以下信息:
SQL> create diskgroup fra external redundancy disk '/dev/raw/raw3';
Diskgroup created.
SQL> select PATH, MOUNT_STATUS, HEADER_STATUS, MODE_STATUS, STATE from V$ASM_DISK;
PATH
--------------------------------------------------------------------------------
MOUNT_S HEADER_STATU MODE_ST STATE
------- ------------ ------- --------
ORCL:ASMDISK03
CLOSED UNKNOWN ONLINE NORMAL
ORCL:ASMDISK01
CLOSED UNKNOWN ONLINE NORMAL
ORCL:ASMDISK02
CLOSED UNKNOWN ONLINE NORMAL
PATH
--------------------------------------------------------------------------------
MOUNT_S HEADER_STATU MODE_ST STATE
------- ------------ ------- --------
/dev/raw/raw2
CACHED MEMBER ONLINE NORMAL
/dev/raw/raw1
CACHED MEMBER ONLINE NORMAL
/dev/raw/raw3
CACHED MEMBER ONLINE NORMAL
6 rows selected.
可以看出,一旦使用/dev/raw/raw* 的disk是可以創建成功的,再來看下ORCL:ASMDISK0* 的header_status的狀態爲 UNKNOWN。根據metalink上的一篇文章【ID 396015.1】,如下:
Applies to:
Oracle Server - Enterprise Edition - Version: 10.2.0.1 to 10.2.0.4 - Release: to 10.2
Information in this document applies to any platform.
Symptoms
When a diskgroup with external redundancy needs to be created on a NetApps with iSCSI following errors might occur:
CREATE DISKGROUP KNVB EXTERNAL
REDUNDANCY DISK 'ORCL:DISK1';
CREATE DISKGROUP KNVB EXTERNAL REDUNDANCY DISK 'ORCL:DISK1'
*
ERROR at line 1:
ORA-15018: diskgroup cannot be created
ORA-15072: command requires at least 1 failure groups, discovered only 0
Error message from bdump alert log file
=======================================
...
Wed Oct 18 15:45:46 2006
ORA-15186: ASMLIB error function = [asm_open], error = [1], mesg = [Operation not permitted]
Wed Oct 18 15:45:46 2006
ORA-15186: ASMLIB error function = [asm_open], error = [1], mesg = [Operation not permitted]
The disk HEADER_STATUS from V$ASM_DISK is UNKNOWN instead of CANDIDATE or PROVISIONED
Cause
Oracleasm is able to create and stamp the ASM disk, because the soft link from the mapper,
but the ASM instance cannot see the disks (HEADER_STATUS is UKNOWN instead of PROVISONED) as the soft links were mounted in /etc/fstab as /data/...
If NetApp is used, then the /etc/fstab file should be checked.
The disks stammped by oracleasm should not be present in this file.
If EMC based storage but use the normal Linux multipath driver is used, then the following map settings should be set in /etc/sysconfig/oracleasm
# ORACLEASM_SCANORDER: Matching patterns to order disk scanning
ORACLEASM_SCANORDER="multipath sd"
# ORACLEASM_SCANEXCLUDE: Matching patterns to exclude disks from scan ORACLEASM_SCANEXCLUDE="sd"
Solution
1. If the customer is using NetApp check the /etc/fstab file for any mount points including the NetApp disks
E.g: umount /data/....
Connect to the ASM instance
conn / as sysdba
select PATH, MOUNT_STATUS, HEADER_STATUS, MODE_STATUS, STATE from V$ASM_DISK;
You should see the HEADER_STATUS as PROVISIONED instead of UNKNOWN.
Now you can create the diskgroup with external redundancy
Eg:CREATE DISKGROUP KNVB EXTERNAL REDUNDANCY DISK 'ORCL:DISK1';
2. If EMC based storage but use the normal Linux multipath driver is used, then please make the following changes in the /etc/sysconfig/oracleasm file.
# ORACLEASM_SCANORDER: Matching patterns to order disk scanning
ORACLEASM_SCANORDER="multipath sd"
# ORACLEASM_SCANEXCLUDE: Matching patterns to exclude disks from scan ORACLEASM_SCANEXCLUDE="sd"
Note that the asm_diskstring should be set to "ORCL:*"
以上信息爲文章內容,根據提示,可以將 /etc/sysconfig/oracleasm修改下,並且我在asm的$ORACLE_HOME/dbs 下創建了一個參數文件 init+ASM.ora ,內容只有
*.asm_diskgroups = ‘DATA’
*.asm_diskstring = ‘ORCL:*’
經過如上修改,在restart oracleasm之後,asm終於正常了。
SQL> ALTER DISkgroup fra mount;
Diskgroup altered.
SQL> select PATH, MOUNT_STATUS, HEADER_STATUS, MODE_STATUS, STATE from V$ASM_DISK;
PATH
--------------------------------------------------------------------------------
MOUNT_S HEADER_STATU MODE_ST STATE
------- ------------ ------- --------
ORCL:ASMDISK01
CACHED MEMBER ONLINE NORMAL
ORCL:ASMDISK02
CACHED MEMBER ONLINE NORMAL
ORCL:ASMDISK03
CACHED MEMBER ONLINE NORMAL