Oracle Database ASM 10g Features

Introduction

ASM (Automatic Storage Management) is an integrated Volume Manager that is specifically built for Oracle Database files.
Key Features and Benefits:
  • Portable and High-Performance Cluster File System
  • Spread Data Across disks SAME Method
  • Mirrors Data for Fail over on per-file basis
  • Manages Oracle Database Files
  • Provides online disk reconfiguration and dynamic rebalancing
  • Is Clusterware and recommended in RAC installations
  • Provides performance of Raw with Easy Volume Management




Figure 1 shows relationships between various storage units inside Oracle databases that uses ASM.
  1. ASM has new components, at the top are ASM Disk Groups. Any single ASM file can only be contained in only one Disk group, however a Disk group can contain files belonging to many Databases and single database can also use multiple Disk groups.
  2. A single Disk group is made up of one or more ASM Disks and each ASM disk can only belong to one Disk group. ASM files are always spread across all of the disks assigned to the Disk group.
  3. ASM Disks are partitioned in Allocation Units(AU) of 1-MB each which is the smallest contiguous space ASM can allocation. However if the files are control files, redo logs you can created AU of 128K.
  4. ASM does not allow a single block to split across AUs. 

ASM File Types
ASM supports following File Types:
  1. Database Files
  2. Control Files
  3. Online Redo Logs
  4. Archived Redo Logs
  5. FRA Files
  6. RMAN Files (image copy & Backup)
  7. SP File

ASM Installation

  • Install VM Ware Workstation. You can download a 30-day evaluation copy from http://www.vmware.com/products/ws/, however I would suggest you buy the software.
  • Creation one Virtual machine, name it as OraWorld1.
  • Install Windows 2003 Enterprise Edition OS on OraWorld1.
  • Now you can Install Oracle 10g Release2 Software Only from the DVD, which is a pretty much straightforward method.
  • Shutdown OraWorld1 server and create a new Disk say 1GB of Size.
  • Start the server and go to Disk Administrator and follow the procedures given below to assign the newly created disk as a raw partition. Do not assign Drive Letter or Format the disk.
  • Now create additional Disks for future use.
  • You should have the following raw partitions defined.
Please go through the following pages to perform these tasks.
Create Virtual Disks from VM Ware software when server is down.
Choose Edit Virtual Machine Settings.
Click on Add button
Press Next and Highlight Hard Disk, then click Next
Check ‘Create a New Virtual Disk’
Choose SCSI as type
Select Size as 2 GB
Name the virtual disk as ‘ASMDBF1.vmdk’
Create additional disks as:
ASMDBF1.vmdk     for DBF files
ASMDBF2.vmdk     Failover group
ASMFRA.vmdk       Flash Back Recovery Area
ASMREDO.vmdk    Redo Log Area
ASMARCH.vmdk    Archived Logs


  • Start up the server OraWorld1
  • Go to Disk Management and you will be prompted with a screen which should display all five disks with a check mark. Accept defaults and Click next.
  • On second script all five will be unchecked, click Next
  • Press Finish to complete and you should see all 5 disks as Type Basic Unallocated. For each of the disk perform:
  1. Right click, New Partition, Extended Partition and Finish
  2. Right click, New Logical drive, Do not assign drive letter nor partition it.
  3. From command prompt type Diskpart and enter Automount On.
  4. From command prompt, configure basic CRS services  as
  5. C:\oracle\product\10.2.0\db_1>localconfig add
  6. C:\oracle\product\10.2.0\db_1>localconfig add
  7. Step 1:  creating new OCR repository
  8. Successfully accumulated necessary OCR keys.
  9. Creating OCR keys for user 'administrator', privgrp ''..
  10. Operation successful.
  11. Step 2:  creating new CSS service
  12. successfully created local CSS service
  13. successfully added CSS to home


  • Launch DBCA and choose Configure Storage Management.
  • Select Create New group, choose stamp disks which will show you all of your five disks. Configure ASM links to all these disks as:
  1. ORCLDISKASMDBF1    \Device\Harddisk1\Partition1
  2. ORCLDISKASMDBF2    \Device\Harddisk2\Partition1
  3. ORCLDISKASMFRA    \Device\Harddisk3\Partition1
  4. ORCLDISKASMREDO    \Device\Harddisk4\Partition1
  5. ORCLDISKASMARCH    \Device\Harddisk5\Partition1

Now make Change Disk Discovery Path as Null and you should see all disks.
Now create Disk groups as :
ARCH    \\.\ORCLDISKASMARCH    External 1GB
REDO    \\.\ORCLDISKASMREDO    External 1GB
FRA        \\.\ORCLDISKASMFRA    External 2GB
DBF (MAIN GROUP WITH 2 SUB-GROUPS) Must create as Normal Redundancy
DBFP    \\.\ORCLDISKASMDBF1    External 2GB
DBFS    \\.\ORCLDISKASMDBF2    External 2GB
You now have a running ASM instance on the server.

  • Checking ASM instance

You can always use DBCA to check settings of ASM.
Alternatively, go to command prompt:
Set ORACLE_SID=+ASM
Sqlplus /nolog
Connect sys/password as sysdba
Show sga (80MB)
Total System Global Area   83886080 bytes
Fixed Size                  1247420 bytes
Variable Size              57472836 bytes
ASM Cache                  25165824 bytes
SQL>create pfile from spfile
You can then check C:\oracle\product\10.2.0\db_1\database for these files. You can also view v$parameter for all possible values for ASM instance.
+asm.asm_diskgroups='DATA1','ARCH','REDO','FRA','DBF'#Manual Mount
*.asm_diskgroups='DATA1','ARCH','REDO','FRA','DBF'
*.asm_diskstring=''
*.background_dump_dest='C:\oracle\product\10.2.0\admin\+ASM\bdump'
*.core_dump_dest='C:\oracle\product\10.2.0\admin\+ASM\cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='C:\oracle\product\10.2.0\admin\+ASM\udump'
You can change some of the values like large pool and even db cache size. You can also manually create the disk group as:
Create diskgroup DBF NORMAL redundancy
Failgroup flgrp1 disk ‘\\.\ORCLDISKDATA0’, ‘\\.\ORCLDISKDATA1’
Failgroup flgrp2 disk ‘\\.\ORCLDISKDATA2’, ‘\\.\ORCLDISKDATA3’;


Check Candidate disks:

select group_number, disk_number, mount_status, header_status, state, path from v$asm_disk;

Other useful queries:

Select group_number, name, total_mb, free_mb, state, type
From v$asm_diskgroup;
Select group_number, disk_number, mount_status, header_status, state, path, failgroup
From v$asm_disk;

You can use sql commands to perform most of the ASM tasks, however EM console can also be used here


Oracle Database Installation

  • Launch DBCA
  • Choose Create Database and select OLTP type
  • Name it as ORCL2, choose ASM as file system, select all disk groups to be used.
  • Use oracle managed files as:+DBF press Next
  • Specify Flash Recovery Area as +FRA
  • Enable archiving at +ARCH
  • Choose Auto SGA as 55% of memory
  • Leave else default and complete DB creation.
  • Launch NetConfig and define Listener with default settings.

Database ORCL2 is created with the following attributes:
NAME:    ORCL2
SPFILE:    +ARCH/ORCL2/spfileORCL2.ora
URL:    http://oraworld1:1158/em

ASM Maintenance


  • Open access for ASM Instance

By default ASM instance is not an open database, but in a mount state and listener will block it from outside access. What you can do is add the following lines to your listener.ora and reload the listener. Afterwards from a client running OEM or any gui utility to access the database, make sure to create a tnsnames entry in the client machine for the asm sid.
 (SID_DESC =
      (GLOBAL_DBNAME = +ASM)
      (ORACLE_HOME = C:\oracle\product\10.2.0\db_1)
      (SID_NAME = +ASM)
    )

  • Create Disk Groups

From VMWare edit settings for the machine, create a new virtual disk call it ‘testasmdisk’. As before, register the new partition in Windows Storage Admin as raw disk. Now from command prompt run ‘ASMTOOLG’ command, add new label and assign a new asm link name as:
    ORCLDISKTESTASMDISK    \Device\Harddisk6\Partition1
    ORCLDISKTESTASMDISKM \Device\Harddisk7\Partition2
Now you should be able to see the candidate once it is stamped with ASMTOOLG with the following query:
select * from V$ASM_DISK;
CREATE DISKGROUP SPARE1 EXTERNAL REDUNDANCY  DISK '\\.\ORCLDISKTESTASMDISK‘

  • Drop Disk Groups

DROP DISKGROUP SPARE1 INCLUDING CONTENTS;
You can use Alter DISKGROUP to add/drop/modify disks etc.
For various disk group command see url:http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_5008.htm
You can also use EM console to manage ASM instance and from there extract the SQL that will be run for specific ASM Maintenance tasks. Instead of remembering SQL syntax I used this approach all the time.  


  • Notes:
  1. On windows platform, I faced problems when starting up the ASM and had to remove the disk group Data1 from the init file. This group appeared as default which I never created.
  2. Although oracle services are all auto start and the auto value is set to true in registry, at the server reboot, asm and database instances never started automatically. You can easily write a script to accomplish that.
  3. I did a test where I have created a new diskgroup with normal redundancy of two disks, and then created a tablespace, tables, inserts some data, all under this group. Later while database was up and running, dropped one disk member from Windows Storage admin. Under EM I could see the disk member as Hung, however after a few seconds, these actions crashed database instance. Later I added another new disk and restarted the database and added the second disk, I could see the balancing going on under v$asm_operation view. However the HUNG disk was not able to remove, had to restart the asm instance, again tried to remove the HUNG disk with force and balance power of 2, this time it went successul.
  4. To configure EM Job system, install Terminal service, create a new admin, assign log as batch and service and then register this user in the EM to submit jobs.

  • Commanding ASM

ASM data files can also be viewed from outside ASM instance via ASMCMD –p command. To run this command you need to setup ORACLE_SID and ORACLE_HOME. Afterwards run the command prompt as asmcmd –p. You will be able to see all the disk groups and you can user basic UNIX commands like ls –l and cd to change directory, mkdir etc.
set ORACLE_SID=+_ASM
set ORACLE_HOME=C:\oracle\product\10.2.0\db_1
ASMCMD –P
Ls –l
In the output of ls –l you should see Name column where both aliases and real names are seen, alias can be like control01.ora where it will point to some machine generated name.
You can use du command to check the size of the folder.
ASM is not a database but a storage instance, and you can use the command lsct to know how many databases are connected to your asm instance.
You can also use FTP command to the ASM instance, for example you can shutdown the database instance, ftp all the database files by ftp to asm, and then start a non-asm database in another machine. Although you can use RMAN against ASM instance.
You can not use standard FTP feature against ASM, it has to be via XML database that is why you must have XML DB option enabled for the databases using ASM Storage.
By default ftp and http services run on port 21 and 80, however for asm ftp we will use different ports.


To set up the FTP access, I must first set up the Oracle XML DB access to the ASM folders. I can do this by executing the catxdbdbca.sql script, found in the $ORACLE_HOME/rdbms/admin directory. The script takes two parameters: the port numbers for the FTP and HTTP services, respectively. So I run the script as follows under sys account.
@catxdbdbca 7787 8080
ftp
Open oraworld1 7787
Now provide system/password and then cd  to sys.
From http service use http://oraworld1:8080/
Command-line ASM management with ASMCMD requires no SQL. It also opens up possibilities for scripting ASM operations. The FTP and HTTP interfaces—available through Oracle XML DB—provide access to ASM files and the ability to copy them and use them as conventional OS files.

  • Converting a Database from ASM to non-ASM environment

ASM Database settings:
Database/Instance Name:    ORCL2
ASM Instance:        +ASM
Server:            oraworld1

Cloned Database settings:
Database/Instance Name:    ORCL2C
Server:            oraworld1

You can use traditional rman command line method to clone a database, there is no such difference whether source database is ASM which is our case. What I have done is used EM control to clone a database which gathers all of the information and then submit a clone database job.
However more interesting part would be to convert a non-asm database to ASM database, which I prefer to do manually as shown below:

  • Converting a Database from Non-ASM to ASM environment

Non-ASM Database settings:
Database/Instance Name:    ORCL2C
ASM Instance:        +ASM
Server:            oraworld1
ASM Disk Group:        ASMORCL2C
Here we will be converting (not cloning) the existing Non-Asm instance to ASM.


Backup non-asm database as copies to ASM Disk Group:
rman target /
run{
  allocate channel c1 type disk;
  allocate channel c2 type disk;
  backup as copy incremental level 0 database
    format '+ASMORCL2' tag ‘ASM_MIGRATION’;
}
sql 'alter system archive log current';
Make sure you are using spfile and not pfile, else first configure your instance to use spfile.

Create a Copy of spfile in ASM Disk group:
rman target /
rman target /
run {
  backup as backupset spfile;
  restore spfile to '+ASMORCL2/spfile';
}
Modify the initORCL2.ora to contain
SPFILE=+ASMORCL2/spfile
shutdown immediate;
STARTUP NOMOUNT PFILE=initORCL2.ora
Migrate control file to ASM:
alter system set control_files='+ASMORCL2/control01.ctl' scope=spfile;
shutdown immediate;
STARTUP NOMOUNT PFILE=initORCL2.ora

Use RMAN to physically create control fine in ASM Storage:
Migrate control file to ASM:
restore controlfile from ‘c:\...\control01.ctl';
alter database mount;
switch database to copy;
recover database;
Migrate temp files to ASM.
run {
  set newname for tempfile 1 to '+ASMORCL2';
  switch tempfile all;
}
alter database open;

Migrate Online Logs of Primary Database to ASM. (Taken from Metalink Notes)
set serveroutput on
declare
   cursor rlc is
      select group# grp, thread# thr, bytes/1024 bytes_k, 'NO' srl
        from v$log
      union
      select group# grp, thread# thr, bytes/1024 bytes_k, 'YES' srl
        from v$standby_log
      order by 1;
   stmt     varchar2(2048);
   swtstmt  varchar2(1024) := 'alter system switch logfile';
   ckpstmt  varchar2(1024) := 'alter system checkpoint global';
begin
   for rlcRec in rlc loop
      if (rlcRec.srl = 'YES') then
         stmt := 'alter database add standby logfile thread ' ||
                 rlcRec.thr || ' ''+TESTDB_DATA1'' size ' ||
                 rlcRec.bytes_k || 'K';

execute immediate stmt;
         stmt := 'alter database drop standby logfile group ' || rlcRec.grp;
         execute immediate stmt;
      else
         stmt := 'alter database add logfile thread ' ||
                 rlcRec.thr || ' ''+TESTDB_DATA1'' size ' || 
                 rlcRec.bytes_k || 'K';
         execute immediate stmt;
         begin
            stmt := 'alter database drop logfile group ' || rlcRec.grp;
            dbms_output.put_line(stmt);
            execute immediate stmt;
         exception
            when others then
               execute immediate swtstmt;
               execute immediate ckpstmt;
               execute immediate stmt;
         end;      end if;
   end loop;

end;

Should you use ASM? As with any new feature, it should be thoroughly tested to ensure that it will work in your environment with proper testing. I have used ASM in both RAC and non-RAC environments and with the exception of couple of issues which were resolved by applying 10.2.0.3 patch set, I would strongly recommend to use it for OLTP Type Databases.

Click here to download PowerPoint Presentation.


Copyright © 2007 www.OracleFusions.com All rights reserved. For Educational Purpose Only

The information contained in this document represents my personal view on the issues discussed as of the date of publication, and I can not guarantee the accuracy of any information presented after the date of publication.

This document is for informational purposes only. I MAKE NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT.

For further information, please contact at Support@OracleFusions.com

Click here to Go Back to Resources Section.