ITPub博客

首页 > Linux操作系统 > Linux操作系统 > How to use Files in place of Real Disk Devices for ASM - (Windows)

How to use Files in place of Real Disk Devices for ASM - (Windows)

原创 Linux操作系统 作者:jackjw 时间:2008-09-18 15:30:49 0 删除 编辑

[@more@]

How to use Files in place of Real Disk Devices for ASM - (Windows)

by Jeff Hunter, Sr. Database Administrator


Contents

  1. Overview
  2. Creating Files for use by ASM
  3. Create ASM Disk Groups


Overview Creating Files for use by ASM http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl

This article provides the steps to create and configure blank files (instead of real disk devices) for use in testing Oracle's Automatic Storage Manager (ASM) on the Windows platform. This is a handy trick that can be used when the DBA needs to test ASM on a machine that has no free disk partitions or no free disk devices available. Please note that this is intended for testing purposes only!


The first step is to identify an already partitioned and formatted hard disk that contains enough space to contain the blank files to be used as ASM disk devices.

For the purpose of this example, I already have an ASM instance running on the same node named "+ASM".

For a detailed article on configuring ASM, see my article: "Manually Creating an ASM Instance".

For the purpose of this example, I have enough room on my local hard disk (C:) to create four files at 100MB each. I want to create one disk group that contains four disks. The disk group will contain two failure groups and each failure group will be created using two disks.

From within the Windows O/S platform, perform the following actions:

  1. Set Initialization Parameter

    As already mentioned, I have an ASM instance already running on the node named "+ASM". We need to set the following initialization parameters in the ASM instance to allow ASM to use a device rather than a RAW / Logical disk (in our case, a blank text file) and to discover from a non-default location:

    SQL> alter system set "_asm_allow_only_raw_disks"=false scope=spfile;
    SQL> alter system set asm_diskstring='c:asmdisks_file*' scope=both;

  2. Bounce the ASM Instance

    SQL> shutdown
    SQL> startup

  3. Create New Directory for Device Files

    mkdir C:asmdisks

  4. Create Files for ASM Disks

    Now the cool part, to make four 100MB text files using Perl. You can use the Perl binary that came installed with Oracle or download ActivePerl using the following location:

    Here is the Perl script:

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

    Now, run the Perl script using your favorite Perl interpreter:

    C:oracleproduct10.1.0db_1perl5.6.1binMSWin32-x86perl CreateTextFiles.pl


Create ASM Disk Groups

Ok, so now that we have devices that can be seen by the O/S, we can now discover these disks within ASM and then create our ASM disk group.


Let's start by determining if Oracle can find these four new disks: The view V$ASM_DISK can be queried from the ASM instance to determine which disks are being used or may potentially be used as ASM disks. Note that you must log into the ASM instance with SYSDBA privileges. Here is the query that I ran from the ASM instance as the oracle user account:

The following assumes you have the initialization parameter asm_diskstring set properly for the ASM instance. For the purpose of this example, my asm_diskstring parameter is set as follows:
*.asm_diskstring='C:ASMDISKS_FILE*'

set oracle_sid=+ASM
sqlplus "/ as sysdba"

SQL> SELECT group_number, disk_number, mount_status, header_status, state, path
  2  FROM   v$asm_disk

GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU STATE   PATH
------------ ----------- ------- ------------ ------- -----------------------
           0           0 CLOSED  CANDIDATE    NORMAL  C:ASMDISKS_FILE_DISK1
           0           1 CLOSED  CANDIDATE    NORMAL  C:ASMDISKS_FILE_DISK2
           0           2 CLOSED  CANDIDATE    NORMAL  C:ASMDISKS_FILE_DISK3
           0           3 CLOSED  CANDIDATE    NORMAL  C:ASMDISKS_FILE_DISK4
Note the value of zero in the GROUP_NUMBER column for all four disks. This indicates that a disk is available but hasn't yet been assigned to a disk group. The next section details the steps for creating a disk group.


Using SQL*Plus, the following will create a disk group with normal redundancy and two failure groups:

set oracle_sid=+ASM

sqlplus "/ as sysdba"

SQL> CREATE DISKGROUP testdb_data1 NORMAL REDUNDANCY
  2  FAILGROUP controller1 DISK 'C:ASMDISKS_FILE_DISK1', 'C:ASMDISKS_FILE_DISK2'
  3  FAILGROUP controller2 DISK 'C:ASMDISKS_FILE_DISK3', 'C:ASMDISKS_FILE_DISK4';

Diskgroup created.


Now, let's take a look at the new disk group and disk details:

SQL> select group_number, name, total_mb, free_mb, state, type
  2  from v$asm_diskgroup;

GROUP_NUMBER NAME             TOTAL_MB    FREE_MB STATE       TYPE
------------ -------------- ---------- ---------- ----------- ------
           1 TESTDB_DATA1          396        290 MOUNTED     NORMAL

SQL> select group_number, disk_number, mount_status, header_status, state, path, failgroup
  2  from v$asm_disk;

GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU STATE    PATH                    FAILGROUP
------------ ----------- ------- ------------ -------- ----------------------- ------------
           1           0 CACHED  MEMBER       NORMAL   C:ASMDISKS_FILE_DISK1 CONTROLLER1
           1           1 CACHED  MEMBER       NORMAL   C:ASMDISKS_FILE_DISK2 CONTROLLER1
           1           2 CACHED  MEMBER       NORMAL   C:ASMDISKS_FILE_DISK3 CONTROLLER2
           1           3 CACHED  MEMBER       NORMAL   C:ASMDISKS_FILE_DISK4 CONTROLLER2

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3907/viewspace-1010796/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: index table (IOT)
下一篇: liunx下RAC的管理
请登录后发表评论 登录
全部评论

注册时间:2008-09-19

  • 博文量
    39
  • 访问量
    99386