码迷,mamicode.com
首页 > 其他好文 > 详细

使用文件模拟ASM磁盘

时间:2015-02-09 10:50:44      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:

      尽管Oracle缺省都是使用裸设备来创建ASM磁盘,但其实Oracle也允许使用普通文件来创建ASM磁盘,

当然这种方法最好只用在测试环境下或者学习环境下,不能用在生产环境下。之所以必须要用裸设备,

是因为有一个隐含参数_asm_allow_only_raw_disks在起作用。

 

通过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命令创建几个文件

[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_diskstring

--注意asm_diskstrint参数设置

[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实例

[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参数指定的设置!!!

 

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 集群 高可用性 备份与恢复>>

 

使用文件模拟ASM磁盘

标签:

原文地址:http://www.cnblogs.com/myrunning/p/4280845.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!