As Published In

Oracle Magazine
May/June 2004
TECHNOLOGY: Management

Add Storage, Not Projects
By Jonathan Gennick

Automatic Storage Management lets DBAs do their jobs and keep their weekends.

DBAs spend a lot of time managing disk space. To maximize I/O rates, we spread the data we manage across many physical disks. Often we do this by working with a system administrator who uses a logical volume manager (LVM) to combine many physical disks into a single logical volume for use by Oracle Database. Then, when those logical volumes run out of space, we may spend part of our weekend unloading data, adding a new drive to the volume, and reloading data to balance it across all drives. The more adventuresome of us will plumb the mysteries of raw devices in order to eke out a 10 to 15 percent increase in performance. What a lot of work! Wouldn't it be great if we could just throw a basket of disk drives at the database and let the database sort out the details? Oracle Database 10g moves us toward that goal in the form of a new feature called Automatic Storage Management (ASM).

What Is ASM?

ASM is a combination of a logical volume manager and a file system embedded within the database. Using ASM, you define groups of disks that are analogous to the volumes you would otherwise create by using an LVM. Then you can place datafiles, logfiles, and even control files onto those groups. ASM creates the necessary files in Oracle's file system and stripes your data across all the disks in a group. ASM can mirror data for you, and it rebalances data as you add disks to and remove them from a group. Because ASM understands the contents of the files it manages, it can rebalance data in ways an LVM cannot. Because ASM eliminates the LVM and the operating system's file system from the disk group stack, you reap a potential performance gain similar to what you get from using raw devices. However, ASM is far more convenient to use than raw devices.

Figure 1 shows a high-level view of the ASM architecture. ASM storage is managed and apportioned out to database instances via a new type of instance called an ASM instance. One ASM instance manages ASM storage for all the database instances on a given server. Database instances still read and write their own data, but the ASM instance reads and writes data during rebalancing operations.

Figure 1

Figure 1: ASM architecture

Your first step toward using ASM is to create an ASM instance on your database server. Then you tag disks for use as ASM disks, create disk groups, and create datafiles and other database files on those groups.

Creating an ASM Instance

If you're installing Oracle Database 10g and creating a brand-new database, creating an ASM instance is easy. You just select a check box on one of the Database Creation Assistant screens; the assistant creates an ASM instance for you, as well as a new database that uses ASM storage. However, if you're upgrading to Oracle Database 10g and you want to migrate all or part of an existing database to ASM, you'll want to know how to manually create an ASM instance and also how to create and use disk groups.

Creating an ASM instance is quite simple. Begin by creating an administrative directory tree for the new instance. My existing database instance was named ORCL10, and the dumpfile and parameter file directories all fell under C:\oracle\admin\orcl10. I created an identical directory tree under C:\oracle\admin\asm10. ASM10 was the name I chose for my new ASM instance.

Next, create an instance parameter file. Most parameters do not apply to ASM instances, so this file can be blissfully short. You'll likely be fine if you accept the default sizes for the buffer cache, shared pool, and other SGA memory structures. I created initasm10.ora, with only the following:

instance_type=asm
background_dump_dest=C:\oracle\admin\
asm10\bdump
core_dump_dest=C:\oracle\admin\asm10\
cdump
user_dump_dest=C:\oracle\admin\asm10\
udump
compatible=10.1.0.1.0
asm_diskstring='\\.\*:'

The instance_type is a new parameter for distinguishing between database and ASM instances. The asm_diskstring parameter specifies where the ASM instance should look to find drives it can use. The \\.\*: notation is in the Universal Naming Convention (UNC), often used in networking. The dot represents the local node, so \\. gets you to the server on which ASM runs. The asterisk followed by a colon (*:) matches drive names in the form D:, E:, and so on. You can specify multiple locations. For example, I could have used asm_diskstring='\\.\D:','\\.\E:',..., but using a wildcard is much easier.

If you're on Windows, you need to create a Windows service to run the new instance. Do this by using the ORADIM utility, which enables you to create both the instance and the service at one time. I used the following command, which specifies the new -ASMSID option, to create an ASM instance:

ORADIM -NEW -ASMSID asm10 -SYSPWD 
nevertell -PFILE C:\oracle\admin\asm10\pfile\
initasm10.ora

Another Windows-only task is to tag drives you want to use for ASM storage by using a new utility named asmtool that ships with Oracle Database 10g. You can run asmtool before or after you start your ASM instance. It initializes drive headers and marks drives for use by ASM, reducing the risk of clobbering a drive (such as your boot drive!) that you use for operating system files. Consult the production documentation for Oracle Database 10g on Windows for details on invoking asmtool.

All that remains is to start the instance, create a server parameter file, and bounce the instance so that it comes up using that new file. Listing 1 shows these tasks. (You can ignore messages about disk groups not being mounted at this point in the process.) Using a server parameter file enables the ASM instance to automatically record new disk group names in the ASM_DISKGROUPS parameter, so that those disk groups can be automatically mounted whenever the ASM instance is started. After you start the new ASM instance, any database instances on the same server will automatically find it.

Creating Disk Groups

create disk groups and add and remove storage while connected to the ASM instance. Be sure to connect as SYSDBA. You can query V$ASM_DISK to see which disks you are using or may potentially use. A group number of 0 indicates that a disk is available and hasn't yet been assigned to a disk group. Listing 2 shows the creation of a new disk group named MYDATA, followed by a query to V$ASM_DISKGROUP to show details of the new group.

The MYDATA disk group contains four disks. The keywords NORMAL REDUNDANCY result in two-way mirroring of all files on the disk group. You can specify EXTERNAL REDUNDANCY if your disks each map to a RAID array managed externally or if you do not care to mirror the files at all. You can be extra cautious and specify HIGH REDUNDANCY to get three-way mirroring.

The MYDATA disk group consists of two failure groups, which define sets of disks that should never contain more than one copy of mirrored data. Any data files that ASM places on drives F: and G: must therefore be mirrored on drives H: and I:. Data on F: can never be mirrored on G:. If two drives share a controller or any other such resource, be it hardware or software, you should put them into the same failure group to ensure against failure of that common resource. Assuming that F: and G: are on the same controller, that controller can fail, with H: and I:, both on a different controller, picking up the load.

Placing Data on a Disk Group

Placing new objects on a disk group is simple. You can use disk group names in place of filenames when you create database files, redo log members, and so on. Even though you're now using ASM storage, you perform these operations while connected to your database instance. For example,

CREATE TABLESPACE geo_names
   DATAFILE '+MYDATA' SIZE 100M;

CREATE TABLE geo_names (
   state         VARCHAR2(2),
   feature_name   VARCHAR2(80),
   feature_type   VARCHAR2(9),
   county        VARCHAR2(60)
) TABLESPACE geo_names;

The plus sign (+) in front of the name MYDATA indicates that the name is a disk group name, not an operating system filename. Your database instance queries the ASM instance for a new file in that disk group and uses that file for the tablespace data—in this case, striping the geo_names table data across all the drives in 1-megabyte chunks. (Redo log and control files use a 128K stripe size.)

Migrating existing database files to ASM is a bit more of a challenge. Traditionally, you move database files by using operating system commands, but your operating system can't read from and write to Oracle's file system, so you need another method for moving existing files onto ASM. You can migrate redo logs to ASM storage by creating a new member in each log group, placing those new members on ASM disk groups, forcing a log switch, and then dropping all the non-ASM log members. For datafiles and control files, the solution for migrating to ASM lies in using RMAN. For detailed procedures for using RMAN to move files into and out of ASM storage, see the Backup and Recovery Advanced User's Guide, especially Chapter 12, "Migrating Databases to and from ASM with Recovery Manager."

Adding and Removing Storage

You can easily add disks to or remove them from a group. To add disks to a group, first add them to your server (or to your storage network or disk array), change them to be owned by the same user that owns the Oracle Database software, tag them with asmtool (for Windows only), and then issue an ALTER DISK GROUP command from your ASM instance. The following example adds two disks to MYDATA, one to each failure group:

ALTER DISKGROUP mydata
  ADD FAILGROUP mydata01 DISK '\\.\J:'
      FAILGROUP mydata01 DISK '\\.\K:';

It's not necessary to add disks to all failure groups within a disk group. You can add a disk to just one failure group, leaving the others unchanged, but it's good practice to keep the amount of space in the failure groups close to equal. Otherwise, you might not have the room you need for mirroring data.

When you add a disk to a group, ASM automatically rebalances the data stored in that group, so that each disk in the group uses the same amount of its capacity, percentagewise. For example, if your data consumes 30 percent of the total space in the disk group, that data will be spread across all drives, so that each is 30 percent full. There's much less I/O involved in ASM's rebalancing process than if you were to unload and reload all the data in the tablespace. You can view ongoing rebalancing operations by querying V$ASM_OPERATION from the ASM instance, as shown in Listing 3. The SOFAR and EST_WORK columns refer to allocation units, which are 1MB chunks for datafiles. EST_WORK is the total number of units to move, and SOFAR is the number of units moved so far during the rebalance operation. EST_RATE is the current number of units per minute being moved by the rebalance operation, and EST_MINUTES gives an estimate of the remaining time, in minutes.
Next Steps

READ ASM documentation
Oracle Database Administrator's Guide: Chapter 12, "Using Automatic Storage Management"
Backup and Recovery Advanced User's Guide: Chapter 12, "Migrating Databases to and from ASM with Recovery Manager"

LEARN more about ASM on Oracle Technology Network's Database Manageability page:
ASM is supported on all database platforms, including Windows, Linux, Solaris, and HP-UX.

Remove a disk from a group by issuing an ALTER DISKGROUP DROP command. Be aware, though, that the name you use to drop a disk is an Oracle-generated ASM disk name that is not the same as the operating system name you used to add that same disk. To determine the correct name to use in dropping a disk, query V$ASM_DISK. Find the operating system disk name in the LABEL column, and use the corresponding ASM disk name from the NAME column:

ALTER DISKGROUP mydata
   DROP DISK MYDATA_0004, MYDATA_0005;

After dropping all the disks you want to drop from a disk group, issue the ALTER DISKGROUP REBALANCE command to initiate the rebalancing operation. Then wait for ASM to move any data off the disks being dropped. Monitor the V$ASM_OPERATION view to watch that process, or watch the STATUS column of the V$ASM_DISK view. When the rebalance is complete, you can remove or reuse the drives.

Recovering from a Disk Failure

Recovery from a disk failure could hardly be simpler. When a drive fails, ASM automatically removes it from the group, rebuilds any mirrored files that were lost when the drive failed, and rebalances the data. Figure 2 illustrates this process. So long as you have enough free space remaining in the disk group to remirror the data from the lost drive, your database instance will not only continue running but it will even continue running safely, because your data will all still be mirrored. Your only exposure is the time it takes for ASM to remirror the lost data. You need not find yourself under great pressure to swap in a new drive. If you do not have enough free space to cover the loss of a drive, however, ASM won't be able to rebuild any mirrored files and your database will stop, much as it stops when you run out of archive log space.

Figure 2

Figure 2: Disk 2 fails, and mirrored files are rebalanced to remaining disks.

Life Gets Easier

This article focuses on command-line procedures, because that's very important in terms of understanding ASM, but ASM is also fully supported by Oracle Enterprise Manager (OEM) and Grid Control. Not only can you use OEM to create disk groups, to add and remove disks, and to otherwise manage ASM storage but you can also configure OEM to notify you (optionally by e-mail) when a disk fails or when a disk group is running out of space.

ASM holds a great deal of promise. It has the potential to make your DBA job much easier. Combine ASM with Oracle Managed Files, and you may find your disk-management activities reduced to periodically adding new drives to your database's disk group. You don't even have to think about filenames or disk group names. OEM notifies you when your storage needs attention. You can spend less time reacting under pressure and more time working proactively on projects that will make a difference to you and your business.


Jonathan Gennick (
Jonathan@Gennick.com) is an experienced Oracle DBA and Oracle Certified Professional living on Michigan's Upper Peninsula. He runs the Oracle-article e-mail list, which you can learn about by visiting http://gennick.com. Gennick wrote the SQL Pocket Guide and collaborated on the Oracle Regular Expression Pocket Reference, both published by O'Reilly & Associates.



Please rate this document:

Excellent Good Average Below Average Poor


Send us your comments

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy