使用文件模擬ASM磁盤

      儘管Oracle缺省都是使用裸設備來建立ASM磁盤,但其實Oracle也容許使用普通文件來建立ASM磁盤,sql

固然這種方法最好只用在測試環境下或者學習環境下,不能用在生產環境下。之因此必需要用裸設備,oracle

是由於有一個隱含參數_asm_allow_only_raw_disks在起做用。app

 

經過SQL查看ASM參數:學習

set lines 120
col name for a30
col value for a10
col DESCRIPTION for a50

SQL> select x.ksppinm name,y.ksppstvl value,x.ksppdesc description
  2  from x$ksppi x,x$ksppcv y
  3  where x.inst_id=userenv('Instance') 
  4  and y.inst_id=userenv('Instance')
  5  and x.indx=y.indx
  6  and x.ksppinm like '_asm_allow_only_raw_disks%'
  7  order by name;

NAME                           VALUE      DESCRIPTION
------------------------------ ---------- --------------------------------------------------
_asm_allow_only_raw_disks      TRUE       Discovery only raw devices

只要把這個參數改爲FALSE,咱們就能夠使用文件來建立ASM了。試驗以下:測試

 

1.使用dd命令建立幾個文件spa

[oracle@std u02]$ mkdir asmfile
[oracle@std u02]$ cd asmfile/
[oracle@std asmfile]$ dd if=/dev/zero of=cp1 bs=1M count=500
500+0 records in
500+0 records out
524288000 bytes (524 MB) copied, 5.50622 seconds, 95.2 MB/s
[oracle@std asmfile]$ dd if=/dev/zero of=cp2 bs=1M count=500
500+0 records in
500+0 records out
524288000 bytes (524 MB) copied, 7.13052 seconds, 73.5 MB/s
[oracle@std asmfile]$ dd if=/dev/zero of=cp3 bs=1M count=500
500+0 records in
500+0 records out
524288000 bytes (524 MB) copied, 6.60984 seconds, 79.3 MB/s
[oracle@std asmfile]$ dd if=/dev/zero of=cp4 bs=1M count=500
500+0 records in
500+0 records out
524288000 bytes (524 MB) copied, 5.31099 seconds, 98.7 MB/s
[oracle@std asmfile]$ ls -l
total 2050016
-rw-r--r-- 1 oracle oinstall 524288000 Feb  2 16:23 cp1
-rw-r--r-- 1 oracle oinstall 524288000 Feb  2 16:24 cp2
-rw-r--r-- 1 oracle oinstall 524288000 Feb  2 16:24 cp3
-rw-r--r-- 1 oracle oinstall 524288000 Feb  2 16:24 cp4

 

2.建立asm參數文件並修改asm_diskstringcode

--注意asm_diskstrint參數設置orm

[oracle@std dbs]$ cp init+ASM.ora  init+ASM2.ora
[oracle@std dbs]$ vi init+ASM2.ora 
[oracle@std dbs]$ cat init+ASM2.ora 
*.asm_diskstring='/u02/asmfile/cp*'
*.instance_type='asm'
*.large_pool_size=24M
*.remote_login_passwordfile='SHARED'
*.background_dump_dest='/u02/app/admin/+ASM2/bdump'
*.core_dump_dest='/u02/app/admin/+ASM2/cdump'
*.user_dump_dest='/u02/app/admin/+ASM2/bdump'

 

3.啓動ASM實例blog

[oracle@std dbs]$ export ORACLE_SID=+ASM2
[oracle@std dbs]$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.4.0 - Production on Mon Feb 2 16:32:47 2015

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to an idle instance.

SQL> startup
ASM instance started

Total System Global Area   96468992 bytes
Fixed Size                  1265984 bytes
Variable Size              70037184 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted


SQL> select path from v$asm_disk;

no rows selected

啓動ASM實例後還看不到咱們asm_diskstring參數指定的設置!!!ip

 

4.修改隱含參數,重啓ASM實例

[oracle@std dbs]$ vi init+ASM2.ora 
[oracle@std dbs]$ cat init+ASM2.ora 
*.asm_diskstring='/u02/asmfile/cp*'
*.instance_type='asm'
*.large_pool_size=24M
*.remote_login_passwordfile='SHARED'
*.background_dump_dest='/u02/app/admin/+ASM2/bdump'
*.core_dump_dest='/u02/app/admin/+ASM2/cdump'
*.user_dump_dest='/u02/app/admin/+ASM2/bdump' _asm_allow_only_raw_disks= FALSE

 

[oracle@std dbs]$ export ORACLE_SID=+ASM2
[oracle@std dbs]$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.4.0 - Production on Mon Feb 2 16:37:38 2015

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to an idle instance.

SQL> startup
ASM instance started

Total System Global Area   96468992 bytes
Fixed Size                  1265984 bytes
Variable Size              70037184 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted


SQL> select path from v$asm_disk;

PATH
--------------------------------------------------------------------------------
/u02/asmfile/cp4
/u02/asmfile/cp1
/u02/asmfile/cp2
/u02/asmfile/cp3

如今能夠看到修改參數後能夠看到asm_diskstring參數指定的磁盤了,如今看一下是否可以建立磁盤組

 

5.建立磁盤組

--注意這些建立的磁盤組不會寫入init+ASM2.ora,由於咱們當前使用的是pfile,重啓實例會丟失。

SQL> create diskgroup dg normal redundancy disk
  2  '/u02/asmfile/cp1','/u02/asmfile/cp2' name dg_data;

Diskgroup created.

SQL> create diskgroup back normal redundancy
  2  disk '/u02/asmfile/cp3','/u02/asmfile/cp4' name backup_data;

Diskgroup created.

 

--每一個磁盤都分配了名字

SQL> select name,path from v$asm_disk;

NAME                 PATH
-------------------- --------------------------------------------------
BACKUP_DATA          /u02/asmfile/cp4
BACK_0000            /u02/asmfile/cp3
DG_DATA              /u02/asmfile/cp2
DG_0000              /u02/asmfile/cp1

 

 

6.查看磁盤組的屬性

SQL> select name,block_size,allocation_unit_size from v$asm_diskgroup;

NAME                 BLOCK_SIZE ALLOCATION_UNIT_SIZE
-------------------- ---------- --------------------
DG                         4096              1048576
BACK                       4096              1048576

上面的SQL查詢了磁盤組的數據塊大小及分配單元,其實這兩個屬性也是由隱含參數控制的,

 

--查詢ASM的隱含參數,這些參數沒有十足的把握儘可能不要修改

SQL> set lines 120
SQL> col name for a30
SQL> col value for a10
SQL> col DESCRIPTION for a50
SQL> select x.ksppinm name,y.ksppstvl value,x.ksppdesc description
  2  from x$ksppi x,x$ksppcv y
  3  where x.inst_id=userenv('Instance') 
  4  and y.inst_id=userenv('Instance')
  5  and x.indx=y.indx
  6  and x.ksppinm like '_asm%'
  7  order by name;

NAME                           VALUE      DESCRIPTION
------------------------------ ---------- --------------------------------------------------
_asm_acd_chunks                1          initial ACD chunks created
_asm_allow_only_raw_disks      FALSE      Discovery only raw devices
_asm_allow_resilver_corruption FALSE      Enable disk resilvering for external redundancy
_asm_ausize 1048576    allocation unit size   --指定了分配單元
_asm_blksize 4096       metadata block size    --指定了數據塊大小
_asm_disk_repair_time          14400      seconds to wait before dropping a failing disk
_asm_droptimeout               60         timeout before offlined disks get dropped (in 3s t
                                          icks)

_asm_emulmax                   10000      max number of concurrent disks to emulate I/O erro
                                          rs

NAME                           VALUE      DESCRIPTION
------------------------------ ---------- --------------------------------------------------

_asm_emultimeout               0          timeout before emulation begins (in 3s ticks)
_asm_kfdpevent                 0          KFDP event
_asm_libraries                 ufs        library search order for discovery
_asm_maxio                     1048576    Maximum size of individual I/O request
_asm_skip_resize_check         FALSE      skip the checking of the clients for s/w compatibi
                                          lity for resize

_asm_stripesize                131072     ASM file stripe size
_asm_stripewidth               8          ASM file stripe width
_asm_wait_time                 18         Max/imum time to wait before asmb exits

NAME                           VALUE      DESCRIPTION
------------------------------ ---------- --------------------------------------------------
_asmlib_test                   0          Osmlib test event
_asmsid                        asm        ASM instance id

18 rows selected.

SQL> 

 

 

致謝:本文章參考了張曉明<<大話Oracle RAC 集羣 高可用性 備份與恢復>>

相關文章
相關標籤/搜索