Thursday, September 8, 2011

ASM diskgroup creation on windows with dummy disks

Today I needed to setup a small test Oracle database on Windows with Oracle ASM storage. Because I didn't have unused disk partitions that I could spare for Oracle ASM, I decided to use cooked files instead.

Note: Using cooked files instead of raw disks is unsupported by Oracle and should not be used on development and production systems! I needed a quick (and dirty) way to do some testing with ASM, I would never use cooked files in development and/or production


Step 1: Install oracle 10g Software only



1a Configure Cluster Synchronization Servie

C:\>D:\oracle\product\ 10.2.0\db_ 1\BIN\localconfig add

Step 1: stopping local CSS stack
Step 2: deleting OCR repository
Step 3: creating new OCR repository
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'ap\arogyaa' , privgrp ''..
Operation successful.
Step 4: creating new CSS service
successfully created local CSS service
successfully reset location of CSS setup
Step 2 Creating a dummy disks

D:\>mkdir asmdisks
D:\>cd asmdisks
Creating disk
D:\asmdisks>asmtool -create D:\asmdisks\disk1 700M
D:\asmdisks>asmtool -create D:\asmdisks\disk2 700M
D:\asmdisks>asmtool -create D:\asmdisks\disk3 700M

Now you have 3 disks(dummy) of 700mb each which can be used to create a ASM disk group.

Step3 Create ASM instance
Option 1 you can run a DBCA and select aconfigure Automatic storage management an enter the password for ASM.  NOTE:  If you choose option 1 then you don’t need do below manual step 3

OR Option 2 MANUALLY

3a Creating folder
<ORACLE_HOME>\admin\+ASM\bdump
<ORACLE_HOME>\admin\+ASM\cdump
<ORACLE_HOME>\admin\+ASM\udump
 

3b Creating ASM parameter file
Create file with name of INIT+asm.ora at <ORACLE_HOME>\database\ INIT+asm.ora and paste below parameter.
_asm_allow_only_raw_disks=FALSE
asm_diskstring='D:\asmdisks\*'
background_dump_dest='D:\oracle\product\10.2.0\admin\+ASM\bdump'
core_dump_dest='D:\oracle\product\10.2.0\admin\+ASM\cdump'
instance_type='asm'
large_pool_size=12M
remote_login_passwordfile='SHARED'
user_dump_dest='D:\oracle\product\10.2.0\admin\+ASM\udump'

3c Create service and password file
oradim will create an ASM instance and start it automatically.
c:\> orapwd file=C:\oracle\ product\10. 2.0\db_1\ database\ PWD+ASM.ora password=asm
c:\> oradim -NEW -ASMSID +ASM -STARTMODE auto

3d Change PFILE to SPFILE if you setup manually
On command prompt
C:\> set ORACLE_SID=+ASM

SQL> startup
SQL> create spfile from pfile;
SQL> startup force;

 Step 4  Add ASM Diskgroup and other parameter
On command prompt
C:\> set ORACLE_SID=+ASM

SQL> alter system set  asm_diskgroups=data scope=spfile;
Note: if you create disk group from DBCA then you dont need to add above parameter.
 
SQL> alter system set  "_asm_allow_only_raw_disks"=FALSE scope=spfile
SQL> alter system set  asm_diskstring='D:\asmdisks\*'
SQL> startup force;

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

Step 5 Create ASM disk group
First verify that your disk can be seen. As you see below output, this means your disks are discovered and now you can make the diskgroup.
SQL> select path, mount_status from v$asm_disk;
PATH MOUNT_S
------------ --------- --------- --
D:\ASMDISKS\ DISK1 CLOSED
D:\ASMDISKS\ DISK3 CLOSED
D:\ASMDISKS\ DISK2 CLOSED

SQL> create diskgroup data external redundancy disk
          'D:\ASMDISKS\ DISK1', 'D:\ASMDISKS\ DISK2', 'D:\ASMDISKS\ DISK3';

Diskgroup created.

Step 6 Create Database on ASM 
 
Now here you task is completed and now you can run dbca to create database.
screen1 
create a database  --> click next

screen2 
general Purpose  --> click next

screen3 
global database name = orcl 
SID = orcl  --> click next

screen4
--> click next

screen5
password = oracle1 --> click next

screen6
Select ASM --> click next

screen7
select diskgroup --> click next

screen8
Select Oracle Managed Files--> click next

screen9
if you need Flash recover area selected --> click next

now
--> click next
--> click next
--> click next


Another method is also from oracle metalink

ASM Using OS Files Instead of Real Raw Devices On Windows. [ID 602620.1]


1) If the ASM instance was not created, then create an ASM instance thru the DBCA .

2) Update the initialization parameter file with the next hidden parameter:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining options


INSTANCE_NAME
----------------
+asm

SQL> alter system set "_asm_allow_only_raw_disks"=false scope=spfile;
System altered.

3) If you have real raw devices you will see them after create the ASM instance:
SQL> select path from v$asm_disk;

PATH
-------------------------------------------------------------------
\\.\ORCLDISKDG0
\\.\ORCLDISKDG1
\\.\ORCLDISKDATA0
\\.\ORCLDISKDATA1
\\.\ORCLDISKDATA2
\\.\ORCLDISKDATA3
\\.\ORCLDISKFRA0
\\.\ORCLDISKFRA1
8 rows selected.

4) Create the new directory to allocate the fake files/disks:
SQL> host mkdir d:\asmfake

5) Update the ASM instance with the new path associated with the fake directory:

SQL> alter system set asm_diskstring='\\.\ORCLDISK*','d:\asmfake\*' scope=both;

System altered.

6) Shutdown and startup the ASM instance to apply the changes:
SQL> shutdown
ASM diskgroups dismounted
ASM instance shutdown


SQL> startup
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size                  1289028 bytes
Variable Size              57431228 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted
SQL> show parameter asm

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
_asm_allow_only_raw_disks            boolean     FALSE
asm_diskgroups                       string      DATADG, FRADG
asm_diskstring                       string      \\.\ORCLDISK*, d:\asmfake\*
asm_power_limit                      integer     1

7) In order to create fake files to be used as ASM disks you will need to create them thru the dd command, therefore please install the dd command for windows, you can download it from:
http://www.chrysocome.net/dd

8) Then create the desired fake disks/files on the fake directory:
SQL> host dd if=/dev/zero of=d:\asmfake\fakeasm1 bs=1k count=1000000

1000000+0 records in
1000000+0 records out

SQL> host dd if=/dev/zero of=d:\asmfake\fakeasm2 bs=1k count=1000000

1000000+0 records in
1000000+0 records out

SQL> host dd if=/dev/zero of=d:\asmfake\fakeasm3 bs=1k count=1000000

1000000+0 records in
1000000+0 records out

SQL> host dd if=/dev/zero of=d:\asmfake\fakeasm4 bs=1k count=1000000

1000000+0 records in
1000000+0 records out


SQL> host dir d:\asmfake\*
 Volume in drive D is New Volume
 Volume Serial Number is 94B6-1FC7

 Directory of d:\asmfake

06/11/2008  03:00 PM    <DIR>          .
06/11/2008  03:00 PM    <DIR>          ..
06/11/2008  02:58 PM     1,024,000,000 fakeasm1
06/11/2008  02:59 PM     1,024,000,000 fakeasm2
06/11/2008  03:00 PM     1,024,000,000 fakeasm3
06/11/2008  03:01 PM     1,024,000,000 fakeasm4
               4 File(s)  4,096,000,000 bytes
               2 Dir(s)  19,148,734,464 bytes free

9) Connect to the ASM instance and make sure the fake disks are visible:

SQL> select path from v$asm_disk;
 
PATH
----------------------------------------------------------
D:\ASMFAKE\FAKEASM1
D:\ASMFAKE\FAKEASM2
D:\ASMFAKE\FAKEASM3
D:\ASMFAKE\FAKEASM4

\\.\ORCLDISKDG0
\\.\ORCLDISKDG1
\\.\ORCLDISKDATA0
\\.\ORCLDISKDATA1
\\.\ORCLDISKDATA2
\\.\ORCLDISKDATA3
\\.\ORCLDISKFRA0
\\.\ORCLDISKFRA1

12 rows selected.

10) Then create diskgroup(s) using the fake disks:
SQL> create diskgroup TEST external redundancy disk 'D:\ASMFAKE\FAKEASM1',
  2  'D:\ASMFAKE\FAKEASM2',
  3  'D:\ASMFAKE\FAKEASM3',
  4  'D:\ASMFAKE\FAKEASM4';

Diskgroup created.

SQL> select name, state from v$asm_diskgroup;
NAME                           STATE
------------------------------ -----------
DATADG                         MOUNTED
FRADG                          MOUNTED
TEST                           MOUNTED
 
SQL> select name, path from v$asm_disk where group_number =3;
NAME                           PATH
------------------------------ ----------------------------------
TEST_0000                      D:\ASMFAKE\FAKEASM1
TEST_0001                      D:\ASMFAKE\FAKEASM2
TEST_0002                      D:\ASMFAKE\FAKEASM3
TEST_0003                      D:\ASMFAKE\FAKEASM4 

No comments:

Post a Comment