使用普通檔案建立ASM例項

woodnan發表於2008-03-23

平臺:WinXP SP2
資料庫版本:10.2.0.1

注:由於itpub的blog會遮蔽反斜槓,以下反斜槓都用斜槓代替了

實驗需要perl建立檔案來模擬asm磁碟,perl解析器可以從下面的地址下載

1、建立以下perl指令碼,建立4個200m的檔案模擬4塊asm磁碟,指令碼儲存為h:/asmdisk.txt

[@more@]

my $s='0' x 2**20;
open(DF1,">h:/asmdisks/_file_disk1") || die "Cannot create file - $!n";
open(DF2,">h:/asmdisks/_file_disk2") || die "Cannot create file - $!n";
open(DF3,">h:/asmdisks/_file_disk3") || die "Cannot create file - $!n";
open(DF4,">h:/asmdisks/_file_disk4") || die "Cannot create file - $!n";
for (my $i=1; $i<200; $i++) {
print DF1 $s;
print DF2 $s;
print DF3 $s;
print DF4 $s;
}
exit

2、執行剛才建立的perl指令碼
C:/WINDOWS>perl h:/asmdisk.txt

3、配置CSS服務。asm在實際的工作中需要Oracle Cluster Synchronization Services在資料庫和asm之間同步資料和訊息,所以在建立asm例項之前,必須配置CSS服務
C:/WINDOWS>localconfig add
Step 1: creating new OCR repository
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'administrator', privgrp ''..
Operation successful.
Step 2: creating new CSS service
successfully created local CSS service
successfully added CSS to home

4、建立asm例項的管理目錄
%ORACLE_BASE%/admin/+asm/bdump
%ORACLE_BASE%/admin/+asm/cdump
%ORACLE_BASE%/admin/+asm/hdump
%ORACLE_BASE%/admin/+asm/pfile
%ORACLE_BASE%/admin/+asm/udump

5、建立asm例項的引數檔案F:/oracle/product/admin/+asm/pfile/init+asm.ora。由於是透過檔案模擬磁碟,需要用到asm的一個隱含引數_asm_allow_only_raw_disks,預設情況下這個引數的值為true,僅允許裸裝置作為asm的磁碟;這裡將該引數設定為false,可以用檔案模擬asm磁碟
_asm_allow_only_raw_disks=false
asm_diskstring='h:/asmdisks/_file*'
background_dump_dest='F:/oracle/product/admin/+asm/bdump'
core_dump_dest='F:/oracle/product/admin/+asm/cdump'
user_dump_dest='F:/oracle/product/admin/+asm/udump'
instance_type=asm
compatible=10.2.0.1.0
large_pool_size=12M
remote_login_passwordfile=exclusive

6、使用oradim建立asm例項,windows下必須,linux和unix下不需要
C:/WINDOWS>oradim -new -asmsid +asm
Instance created..

7、啟動asm例項,並建立asm例項的spfile
C:/WINDOWS>set ORACLE_SID=+asm

C:/WINDOWS>sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Mar 22 20:39:02 2008

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

idle>startup nomount pfile='F:/oracle/product/admin/+asm/pfile/init+asm.ora'
asm instance started

Total System Global Area 83886080 bytes
Fixed Size 1247420 bytes
Variable Size 57472836 bytes
asm Cache 25165824 bytes

idle>create spfile from pfile='F:/oracle/product/admin/+asm/pfile/init+asm.ora';

File created.

8、重啟資料庫例項,在shutdown和startup時出現ORA-15100和ORA-15110是因為目前還沒有建立diskgroup,沒有任何問題
idle>shut immediate
ORA-15100: invalid or missing diskgroup name

asm instance shutdown
idle>startup
asm instance started

Total System Global Area 83886080 bytes
Fixed Size 1247420 bytes
Variable Size 57472836 bytes
asm Cache 25165824 bytes
ORA-15110: no diskgroups mounted

9、建立diskgroup,假設DISK1、DISK2在一個failgroup,DISK3、DISK4在另一個failgroup
idle>create diskgroup test normal redundancy
2 failgroup controller1 disk 'H:/asmDISKS/_FILE_DISK1','H:/asmDISKS/_FILE_DISK2'
3 failgroup controller2 disk 'H:/asmDISKS/_FILE_DISK3','H:/asmDISKS/_FILE_DISK4';

Diskgroup created.


從v$asm_disk檢視檢視asm disk的情況

idle>col group_number heading gNo for 99
idle>col disk_number heading dNo for 99
idle>col mount_status heading mstatus for a6
idle>col header_status heading hstatus for a9
idle>col path for a40

idle>SELECT group_number, disk_number, mount_status, header_status, state, path from v$asm_disk;

gNo dNo mstatu hstatus STATE PATH
--- --- ------ --------- ---------------- ----------------------------------------
1 1 CACHED MEMBER NORMAL H:/asmDISKS/_FILE_DISK2
1 2 CACHED MEMBER NORMAL H:/asmDISKS/_FILE_DISK3
1 3 CACHED MEMBER NORMAL H:/asmDISKS/_FILE_DISK4
1 0 CACHED MEMBER NORMAL H:/asmDISKS/_FILE_DISK1

從v$asm_diskgroup檢視檢視asm diskgroup的情況
idle>select group_number, name, total_mb, free_mb, state, type from v$asm_diskgroup;

gNo NAME TOTAL_MB FREE_MB STATE TYPE
--- ---------- ---------- ---------- ---------------------- ------------
1 TEST 796 641 MOUNTED NORMAL

asm例項建立成功,以後可以再新增、刪除磁碟和磁碟組。在透過DBCA建立資料庫時,就可以選擇這裡建立好的磁碟組做為儲存選項了

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/175187/viewspace-1001365/,如需轉載,請註明出處,否則將追究法律責任。

相關文章