2007/11/29

Fw Oracle 10g Automatic Storage Management (ASM), Part 3: Advanced Features By Jim Czuprynski

Oracle 10g Automatic Storage Management (ASM), Part 3: Advanced Features
By Jim Czuprynski


Synopsis. Oracle 10g's Automatic Storage Management (ASM) features offer powerful tools to Oracle DBAs to create and manage a robust, flexible, scalable file storage system ready for access by any existing Oracle database instance. This article – the third and final in this series – navigates the myriad ASM file naming conventions and templates, provides examples of ASM storage management commands for adding and removing disks and disk groups, and covers how to convert an entire Oracle database to use ASM storage instead of regular file system storage.

The previous article in this series presented complete demonstrations of how to set up an ASM instance in both Linux and Windows NT, as well as how to use Oracle 10g's Enterprise Manager (EM) to monitor and manage an ASM instance. This article will focus on ASM instance administration, including how to add, alter, and remove ASM disks and disk groups, how to increase the survivability of ASM disk groups with additional striping and mirroring features, and how to migrate an entire Oracle database from regular to ASM storage.

Before I turn my attention to those topics, though, I will review how ASM's file naming conventions help to make quick work of organizing database files and components within an ASM instance.
ASM Naming Conventions

The first thing I noticed when I began my ASM explorations was the unique method of file naming that ASM employs. All ASM file names are based on the Oracle Flexible Architecture (OFA) standard. ASM also employs Oracle Managed File (OMF) structures and rules for file creation, which means that Oracle will clean up after itself when files are no longer needed. For example, if I drop a tablespace, ASM will figure out which datafile(s) are no longer required and will then automatically remove the physical files without any intervention on my part. If an RMAN backup fails, ASM (through OMF) will simply delete any partial files created as part of that failed backup.

One big advantage of this approach is that I have a lot less to worry about when it comes to physical file management. Instead of being concerned about whether I'm using "acceptable" names for physical files, I can simply let ASM worry about this instead, thus freeing me up to concentrate on which logical objects I need to create to support my database.
ASM File Templates

ASM uses file templates to figure out how to configure the myriad attributes for a new Oracle database file. A file template is simply a named collection of attributes associated with an ASM disk group; whenever a new file is created within a disk group, these attributes are applied to the file. Templates also help to simplify file creation because they can be used to map complex file attributes to a single specification. Certain attributes of an ASM file are set forever when the file is initially created, including the file's protection policy and striping policy.

Default Templates. When a disk group is created, ASM associates it with a set of initial system default templates that include default attributes for the various Oracle database file types like control files (CONTROLFILE) or data files (DATAFILE). Also, the DBA can mandate whether files created via the template should be two-way or three-way mirrored, as well as whether files created under that template are COARSE or FINE striped. Table 3.1 lists these default templates and their characteristics.
Table 3.1: ASM Default File Templates and Attributes

Database File Type
ASM Default Template
ASM File Type
ASM Tag Assigned
ASM Default Striping

Archived Redo Logs
ARCHIVELOG
archive_log
parameter
coarse

Archived Redo Log Backup Pieces
BACKUPSET
backupset
Specified by client
coarse

Control Files
CONTROLFILE
controlfile
CF or BCF
fine

Control File Autobackups
AUTOBACKUP
autobackup
Specified by client
coarse

Cross-Platform Converted Data Files
XTRANSPORT
N/A
N/A
coarse

Data Files
DATAFILE
datafile
_
coarse

Data File Backup Pieces
BACKUPSET
backupset
Specified by client
coarse

Data File Backup Image Copies
BACKUPSET
datafile
_
coarse

DataGuard Broker Configurations
DATAGUARDCONFIG
drc
drc
coarse

DataPump DUMPSet
DUMPSET
dumpset
dump
coarse

Flashback Logs
FLASHBACK
rlog
_
fine

Online Redo Logs
ONLINELOG
online_log
log_
fine

Server Initialization Parameters
PARAMETERFILE
init
spfile
coarse

TEMPFILEs
TEMPFILE
temp
_
coarse


These system default templates cannot be deleted; depending on the defined disk group redundancy characteristics, the system templates are created with the attributes exactly as shown. However, some of the attributes of the default templates can be modified (except for redundancy and striping, of course). It is also possible to add new user-defined file templates for special types of database files; this can assist in standardization of database physical and logical structures. See Listing 3.1 for examples of how to create and drop user-defined templates.

There is one unfortunate drawback of ASM file templates: If an ASM file attribute needs to be modified after the file has been created, the file must be copied via RMAN into a new file with the new settings. Changing the template that was originally used to create the ASM file does not automatically populate the change to the file itself.
ASM File Names: Some Illustrations

To demonstrate these sundry naming patterns, I will use an actual example of just one ASM file -- the datafile for the TBSASM tablespace – to show how templates and file naming conventions combine to help manage ASM file naming standards. Which pattern to use for an ASM file name depends on the context of how the filename is going to be used: (a) when an existing file is being referenced; (b) during the creation of just one file; and (c) during the creation of multiple files.

Fully-Qualified Names. When an ASM-managed file is created, ASM assigns the file a fully-qualified, unique file name. This file name - also known as a system alias - is the most detailed description of the ASM file, so it is the most direct method to access any ASM file. Since ASM constructs the system alias automatically when the file is created, fully-qualified names are not permitted to be specified when creating the file, and no user is permitted to modify this name.

Here is an actual example of a fully-qualified ASM file name; it is the name of the file that represents the datafile for the TBSASM tablespace:
ASM1DG1.ORCL.DATAFILE.TBSASM.257.1

A fully-qualified file name comprises the following five components, and always ends with a special number pair:
. The name of the ASM disk group.
. The database that owns this ASM file.
. The Oracle file type (e.g. DATAFILE, ARCHIVELOG, CONTROLFILE).
. Type-specific information about the file. In this case, it is the corresponding tablespace name for the datafile.
.. A special number pair that ASM generates to insure uniqueness.

Numeric Names. This type consists of just two components, the disk group and the unique numeric identifier that ends the file name and that is automatically assigned by ASM during file creation. Therefore, this file name type can only be used for referencing existing ASM files. To continue the previous example, here is the file name that represents the datafile from the TBSASM tablespace:
ASM1DG1.257.1

Incomplete Names. Incomplete ASM file names are used only for file creation operations. They consist of a disk group name only. ASM will then use the appropriate default template to translate the incomplete ASM file name, as defined by its file type. For example, here is the SQL command I executed originally to create the TBSASM tablespace in the ASM1DG1 disk group:
SQL> CREATE TABLESPACE tbsasm DATAFILE '+ASM1DG1' SIZE 32M;

Incomplete Names With Named Template. Incomplete ASM file names with named templates are used only for file creation operations. They consist of a disk group name plus a template name. The template name determines the file creation attributes of the file. For example:
SQL> CREATE TEMPORARY TABLESPACE temp01
SQL> TEMPFILE '+ASM1DG1(TEMPFILE)' SIZE 32M;
ASM File Name Aliases

ASM file name aliases can be used to create new or reference existing ASM files. While aliases do specify a disk group name, they include a user-friendly name string instead of a file and incarnation number. (In fact, if I attempt to construct an alias that ended with a dotted pair of numbers, Oracle will detect the problem and will signal an error.)

Aliases are implemented using a hierarchical directory structure, thus making it simple to reference ASM files via common-sense, human-recognizable names. I can create an additional alias for each file during its creation, or I can create an alias after its creation via the ALTER DISKGROUP ADD ALIAS command.

ASM file name aliases are case-insensitive, and will always contain a slash (/) that separates its components; each component is stored in UTF-8 format and may be up to 48 bytes long, but the component itself cannot contain a slash. The components of alias file names can contain spaces between sets of characters, but the space should not be the first or last character of a component. This implies a 48-character limit in a single-byte language, but in a multi-byte language, this size limit will be lower depending upon how many multi-byte characters are present in the string.

The total length of an aliased file name, including all components and all separators, is limited to 256 bytes. I can create directory structures as required to support whatever alias naming convention is desired, but it is important to remember that these directories will still be subject to the 256-byte limit.

A common use of an ASM file name alias is during the creation of the database's control files using the CONTROL_FILES parameter, or when creating online redo log files. The following example assumes that I have already created a directory named LOGFILES:
SQL ALTER DATABASE
SQL> ADD LOGFILE GROUP 4
SQL> MEMBERS
SQL> '+ASM1DG1/logfiles/log4a.rdo' SIZE 32M,
SQL> '+ASM1DG1/logfiles/log4b.rdo' SIZE 32M;

Aliased Names Plus Templates. This file name format lists the disk group name, an alias name, and a file creation template name. It is therefore used only during ASM file creation operations. For example, this statement assumes that an aliased directory, dbf, already exists, and that I am creating a server parameter file from a parameter file:
CREATE SPFILE '+ASM1DG1/dbfs/(spfile)' FROM PFILE;

Finally, it is important to note that an ASM file that was created by specifying a user alias will not be cleaned up automatically by ASM when the file is dropped later.

Listing ASM File Name Aliases. To retrieve all ASM file name aliases stored within the database, the V$ASM_ALIAS dynamic view can be traversed, starting at the ASM disk group level and then traverse the hierarchy of the alias information stored within. Note that the REFERENCE_INDEX number is required to traverse entries that are directory entries in this view; for all other alias entry types, REFERENCE_INDEX will be zeroed out.

See Listing 3.2 for examples of how to construct directories and aliases, query the ASM instance for all available aliases, and drop aliases and directories.

Using ASM File Names in SQL Commands. Instead of supplying the full ASM file name, any of the other indirect naming methods mentioned above can be used when specifying an ASM file in a SQL command. This is in fact one of the biggest benefits of ASM: the need to specify long, cumbersome file names is reduced in almost every case. Oracle recommends using "shorthand" ASM file designations or ASM aliases as much as possible except for the few specific cases where ASM file names are needed as parameters (for example, when specifying the names of the database's online redo logs during an ALTER DATABASE RENAME FILE operation).

Default File Sizes. When ASM creates a data file for a permanent table space, or a temporary file for a temporary table space, the data file is set to auto-extensible with an unlimited maximum size and 100 MB default size. An AUTOEXTEND clause may override this default. ASM applies attributes to the files it creates as specified by the corresponding system default template.

Some Exclusions. Finally, it is important to remember that ASM does not manage any binary files (i.e. BFILEs), alert logs, user or background trace files, or Oracle database password files. These files must still be named, backed up, and managed via manual methods.
Managing An ASM Instance

Now that I have detailed ASM file naming techniques, I will turn my attention to the nuts and bolts of managing an ASM instance. Besides creating new files on the instance, I also need to know how to add new disks and new disk groups, modify disk group components, mount and dismount disk groups, and remove existing disks and disk groups from the ASM instance. Since ASM disk concepts are at the heart of these operations, an expanded exploration of ASM striping, mirroring techniques, and disk failure groups is in order.

Coarse vs. Fine-Grained Striping

When a new disk group is created, ASM will spread files in 1MB allocation unit (AU) chunks across all of the disks in a disk group. This default method, called coarse striping, eliminates the need for manual disk tuning. When striping is completed, all disks in the same ASM disk group should have about the same size and performance characteristics; this helps to insure that optimal I/O is attainable. For most installations, only a small number of disk groups should be sufficient (e.g., one disk group designated as a work area and one for a recovery area). Thus, even though the number of files and disks may increase, a constant number of disk groups will probably have to be managed.

Most ASM files stored in the ASM instance will perform well with normal (coarse) striping. However, Files like online redo logs, flashback logs, and control files typically require low latency. For these file types, ASM provides fine-grained (128K) striping. In this case, each AU is striped, and this tends to break up medium-sized I/O operations into many smaller I/O operations that will be executed in parallel.
Failure Groups

ASM failure groups provide mechanisms to prevent the failure of a set of disks within a single particular disk group that share a common resource whose failure must be tolerated. A typical example of this concept is a series of disks connected to a single, common disk controller. In this situation, if the controller failed, all the other disks on the controller's common bus would also be unavailable, even though all of the individual disks are still working fine. (Note that what constitutes a failure group tends to be site-specific and will depend upon the failure level(s) that a site can accept.)

By default, ASM assigns each disk to its own failure group. The DBA can, of course, select a different disk grouping when creating a disk group or adding a disk to a disk group. Once a set of failure groups are identified, ASM will tend to optimize file layout so that the possibility of data unavailability because of the failure of a shared resource is reduced.
Disk Group Mirroring

ASM provides three types of disk group mirroring possibilities. The first type, external redundancy, does not utilize failure groups at all and thus provides no mirroring. This type of redundancy is best when either the DBA has decided to rely upon external OS-level hardware mirroring, or when data loss is an acceptable risk due to media failure. Normal-redundancy disk groups are the ASM default, and they support two-way mirroring that insures two copies of a file extent will always exist on the disk group. Finally, high-redundancy disk groups support triple mirroring, which insures that there will always be three copies of each file extent on the disk group.

When ASM allocates a new primary extent for a file to one disk in a disk group, it allocates a mirror copy of that extent to another disk on one of the several available "partner" disks in the same disk group. Because ASM ensures that a primary extent and its mirror copy never reside in the same failure group, ASM can thus tolerate simultaneous failures of multiple disks in a single failure group. In addition, since ASM mirrors file extents instead of disks, ASM requires spare capacity only within that disk group, not among all disks.

When a disk fails – and all disks eventually do! - ASM reads the mirrored contents from the surviving disks and then automatically rebuilds the complete contents of the disk that has failed onto the surviving disks in the disk group. This also has the advantage of spreading out the I/O hit from the recovery from a disk failure across several disks.
Disk Group Rebalancing

ASM automatically rebalances a disk group whenever disks are added or dropped. Therefore, the rebalancing process requires no intervention. Because ASM uses special indexing techniques to distribute extents over all available disks in a disk group, re-striping of the data is not required; instead, ASM only moves enough data proportionally versus the amount of storage that's been added or removed. This evenly redistributes the files and keeps a balanced I/O load across all disks in the disk group.

Oracle recommends that, to avoid unnecessary data movement, it is generally more efficient to add or drop multiple disks simultaneously. This tends to insure that the disks will be rebalanced in a single operation.
Creating New Disk Groups

On to some practical examples! I have already set up some additional simulated disks on my Linux server, so I will next create a new ASM disk group via the CREATE DISKGROUP SQL command. See Listing 3.3 for the sample code I used.
Adding New Disks

If I want to add one or more ASM disks to an existing ASM disk group, I can use the ALTER DISKGROUP ADD DISK command. ASM performs the addition of ASM disks to an ASM disk group in a single operation. I can add specific ASM disks to a disk group by name, or I can choose to use a disk discovery string. The nice thing about the disk discovery string is that if ASM detects ASM disks that are already part of an ASM disk group in the folder specified by that string, the disks will be ignored and only those ASM disks that are not yet in use will be added.

When I add an ASM disk to a disk group, the ASM instance will determine if the disk is addressable and usable; if so, then the ASM disk is formatted and rebalanced. Rebalancing tends to be time-consuming because it moves extents from every file in the ASM disk group onto the new ASM disk. Though an ASM rebalancing operation does not block any ongoing database operations, rebalancing will definitely have at least some impact on the I/O load on the system. I can also tell the ASM instance to expend more resources on the rebalancing by increasing the value of the ASM_POWER initialization parameter.

See Listing 3.4 for an example of adding a new disk to an existing disk group while requesting a higher than normal amount of resources for rebalancing the affected ASM disk group.
Resizing Disks

I can easily resize an existing ASM disk via the ALTER DISKGROUP RESIZE ; command. ASM offers me the choice to resize all disks in the specified disk group, all disks in the specified failure group, or just the specified disk. Listing 3.5 shows examples of these three options.
Verifying ASM Disk Groups

Keeping my ASM disk groups in ship-shape condition should be one of my primary concerns. I can issue the ALTER DISKGROUP CHECK [NOREPAIR]; command to verify internal consistency of ASM disk group metadata and repair any possible errors. This command checks each file, each disk, or all components of the ASM disk group for any errors and will attempt to repair them. Specifying the NOREPAIR directive alerts me to any errors and bypasses any repairs; all errors will still be reported in the ASM instance's alert log. Listing 3.6 shows an example of ASM disk group verification via this command.
Manually Rebalancing a Disk Group

Even though ASM will automatically rebalance a disk group when any operation other than a MOUNT, DISMOUNT, or CHECK has been issued, I also have the option to initiate a disk rebalancing manually. Issuing the ALTER DISKGROUP REBALANCE [POWER n]; command requests ASM to perform rebalancing on the specified ASM disk group, provided that any rebalancing is needed.

If the optional POWER directive is specified, ASM will rebalance the disk group using the integer value to override the value that the ASM_POWER_LIMIT initialization parameter has set forth. I can thus override the speed of a potential rebalancing or change the power level of an ongoing rebalance operation by changing the POWER directive's value. In addition, if I set POWER to zero (0), any rebalancing on the disk group is halted until I directly or implicitly invoke the rebalancing operation again. See Listing 3.7 for an example of manual rebalancing a selected ASM disk group.
Mounting and Dismounting ASM Disk Groups

Dismounting a mounted ASM disk group is performed via the ALTER DISKGROUP DISMOUNT; command. Its reciprocal is the MOUNT directive. See Listing 3.8 for examples of both of these commands.
Removing Disks from a Disk Group

I can issue the ALTER DISKGROUP DROP DISK ; command to drop a single ASM disk from an existing ASM disk group. And I can also "undrop" (i.e. cancel the pending drop) of any ASM disks that were previously assigned to ASM disk group(s) with the ALTER DISKGROUP UNDROP DISKS; command. However, note that once a disk drop operation completes successfully, issuing UNDROP will not recover the disks. See Listing 3.9 for examples of these two commands.
Dropping a Disk Group

Finally, I can drop an entire existing ASM disk group – along with all of its files - via the DROP DISKGROUP command. If the disk group does still contain any files besides internal ASM metadata, then I have to specify the INCLUDING CONTENTS option as well. Also, the disk group to be dropped must be mounted. ASM will first validate that none of the disk group files are open, and then remove all of the assigned ASM disks and the disk group itself from the ASM instance. ASM will also overwrite the header of each previously used ASM disk to remove any remaining ASM formatting information. Listing 3.10 shows an example of this command.
Migrating a Database to ASM Storage

As discussed in the prior article in this series, ASM files cannot be accessed through normal operating system interfaces. Therefore, RMAN is the only means for copying files from regular storage to ASM, and is the only tool a DBA can use to migrate an entire database from regular to ASM storage. Oracle recommends the following process for a full database migration:

Step 1. Take a complete backup of the database before proceeding with any migration efforts. This will provide a relatively safe fallback position in case any of the migration steps outlined below should fail.

Step 2. Gather the file names of the current control files and online redo logs using V$CONTROLFILE and V$LOGFILE.

Step 3. Shut down the database in consistent mode using either SHUTDOWN IMMEDIATE, SHUTDOWN TRANSACTIONAL, or SHUTDOWN NORMAL. This is a crucial step.

Step 4. Change the database's server parameter file:
Set the necessary OMF destination parameters to the desired ASM disk group.
Remove the CONTROL_FILES parameter.

Step 5. Restore a control file from backup. This will migrate the control files to ASM storage automatically. Note that if an OMF control file is created but there is a server parameter file, then a CONTROL_FILES initialization parameter entry will also be created in the server parameter file.

Step 6. Issue ALTER DATABASE MOUNT; to mount the database.

Step 7. Edit and run an RMAN command file that:
Backs up the database
Switches the current data files to the backups
Renames the online redo logs. You can move only tablespaces or data files using the BACKUP AS COPY command

Step 8. Once the DBA is certain that the migration has been successful, she can delete the original database files left behind in the "regular" storage directories.

An example RMAN command script to accomplish Step 7 is shown in Listing 3.11.
Conclusion

While I have endeavored to introduce practical examples of how to employ Automatic Storage Management (ASM) within multiple Oracle 10g environments, I have truly just scratched the scratch on the surface of what ASM can accomplish. ASM places extremely powerful file management tools into the hands of every Oracle DBA, and it is definitely worth the effort to explore its features no matter the size of the database environment.

References and Additional Reading

While there is no substitute for direct experience, reading the manual is not a bad idea, either. I have drawn upon the following Oracle 10g documentation for the deeper technical details of this article:

B10739-01 Oracle Database Administrator's Guide, Chapter 12

B10743-01 Oracle Database Concepts, Chapter 14

B10755-01 Oracle Database Reference

B10759-01 Oracle Database SQL Reference

Fw Oracle 10g Automatic Storage Management (ASM), Part 3: Advanced Features By Jim Czuprynski

Oracle 10g Automatic Storage Management (ASM), Part 3: Advanced Features
By Jim Czuprynski


Synopsis. Oracle 10g's Automatic Storage Management (ASM) features offer powerful tools to Oracle DBAs to create and manage a robust, flexible, scalable file storage system ready for access by any existing Oracle database instance. This article – the third and final in this series – navigates the myriad ASM file naming conventions and templates, provides examples of ASM storage management commands for adding and removing disks and disk groups, and covers how to convert an entire Oracle database to use ASM storage instead of regular file system storage.

The previous article in this series presented complete demonstrations of how to set up an ASM instance in both Linux and Windows NT, as well as how to use Oracle 10g's Enterprise Manager (EM) to monitor and manage an ASM instance. This article will focus on ASM instance administration, including how to add, alter, and remove ASM disks and disk groups, how to increase the survivability of ASM disk groups with additional striping and mirroring features, and how to migrate an entire Oracle database from regular to ASM storage.

Before I turn my attention to those topics, though, I will review how ASM's file naming conventions help to make quick work of organizing database files and components within an ASM instance.
ASM Naming Conventions

The first thing I noticed when I began my ASM explorations was the unique method of file naming that ASM employs. All ASM file names are based on the Oracle Flexible Architecture (OFA) standard. ASM also employs Oracle Managed File (OMF) structures and rules for file creation, which means that Oracle will clean up after itself when files are no longer needed. For example, if I drop a tablespace, ASM will figure out which datafile(s) are no longer required and will then automatically remove the physical files without any intervention on my part. If an RMAN backup fails, ASM (through OMF) will simply delete any partial files created as part of that failed backup.

One big advantage of this approach is that I have a lot less to worry about when it comes to physical file management. Instead of being concerned about whether I'm using "acceptable" names for physical files, I can simply let ASM worry about this instead, thus freeing me up to concentrate on which logical objects I need to create to support my database.
ASM File Templates

ASM uses file templates to figure out how to configure the myriad attributes for a new Oracle database file. A file template is simply a named collection of attributes associated with an ASM disk group; whenever a new file is created within a disk group, these attributes are applied to the file. Templates also help to simplify file creation because they can be used to map complex file attributes to a single specification. Certain attributes of an ASM file are set forever when the file is initially created, including the file's protection policy and striping policy.

Default Templates. When a disk group is created, ASM associates it with a set of initial system default templates that include default attributes for the various Oracle database file types like control files (CONTROLFILE) or data files (DATAFILE). Also, the DBA can mandate whether files created via the template should be two-way or three-way mirrored, as well as whether files created under that template are COARSE or FINE striped. Table 3.1 lists these default templates and their characteristics.
Table 3.1: ASM Default File Templates and Attributes

Database File Type
ASM Default Template
ASM File Type
ASM Tag Assigned
ASM Default Striping

Archived Redo Logs
ARCHIVELOG
archive_log
parameter
coarse

Archived Redo Log Backup Pieces
BACKUPSET
backupset
Specified by client
coarse

Control Files
CONTROLFILE
controlfile
CF or BCF
fine

Control File Autobackups
AUTOBACKUP
autobackup
Specified by client
coarse

Cross-Platform Converted Data Files
XTRANSPORT
N/A
N/A
coarse

Data Files
DATAFILE
datafile
_
coarse

Data File Backup Pieces
BACKUPSET
backupset
Specified by client
coarse

Data File Backup Image Copies
BACKUPSET
datafile
_
coarse

DataGuard Broker Configurations
DATAGUARDCONFIG
drc
drc
coarse

DataPump DUMPSet
DUMPSET
dumpset
dump
coarse

Flashback Logs
FLASHBACK
rlog
_
fine

Online Redo Logs
ONLINELOG
online_log
log_
fine

Server Initialization Parameters
PARAMETERFILE
init
spfile
coarse

TEMPFILEs
TEMPFILE
temp
_
coarse


These system default templates cannot be deleted; depending on the defined disk group redundancy characteristics, the system templates are created with the attributes exactly as shown. However, some of the attributes of the default templates can be modified (except for redundancy and striping, of course). It is also possible to add new user-defined file templates for special types of database files; this can assist in standardization of database physical and logical structures. See Listing 3.1 for examples of how to create and drop user-defined templates.

There is one unfortunate drawback of ASM file templates: If an ASM file attribute needs to be modified after the file has been created, the file must be copied via RMAN into a new file with the new settings. Changing the template that was originally used to create the ASM file does not automatically populate the change to the file itself.
ASM File Names: Some Illustrations

To demonstrate these sundry naming patterns, I will use an actual example of just one ASM file -- the datafile for the TBSASM tablespace – to show how templates and file naming conventions combine to help manage ASM file naming standards. Which pattern to use for an ASM file name depends on the context of how the filename is going to be used: (a) when an existing file is being referenced; (b) during the creation of just one file; and (c) during the creation of multiple files.

Fully-Qualified Names. When an ASM-managed file is created, ASM assigns the file a fully-qualified, unique file name. This file name - also known as a system alias - is the most detailed description of the ASM file, so it is the most direct method to access any ASM file. Since ASM constructs the system alias automatically when the file is created, fully-qualified names are not permitted to be specified when creating the file, and no user is permitted to modify this name.

Here is an actual example of a fully-qualified ASM file name; it is the name of the file that represents the datafile for the TBSASM tablespace:
ASM1DG1.ORCL.DATAFILE.TBSASM.257.1

A fully-qualified file name comprises the following five components, and always ends with a special number pair:
. The name of the ASM disk group.
. The database that owns this ASM file.
. The Oracle file type (e.g. DATAFILE, ARCHIVELOG, CONTROLFILE).
. Type-specific information about the file. In this case, it is the corresponding tablespace name for the datafile.
.. A special number pair that ASM generates to insure uniqueness.

Numeric Names. This type consists of just two components, the disk group and the unique numeric identifier that ends the file name and that is automatically assigned by ASM during file creation. Therefore, this file name type can only be used for referencing existing ASM files. To continue the previous example, here is the file name that represents the datafile from the TBSASM tablespace:
ASM1DG1.257.1

Incomplete Names. Incomplete ASM file names are used only for file creation operations. They consist of a disk group name only. ASM will then use the appropriate default template to translate the incomplete ASM file name, as defined by its file type. For example, here is the SQL command I executed originally to create the TBSASM tablespace in the ASM1DG1 disk group:
SQL> CREATE TABLESPACE tbsasm DATAFILE '+ASM1DG1' SIZE 32M;

Incomplete Names With Named Template. Incomplete ASM file names with named templates are used only for file creation operations. They consist of a disk group name plus a template name. The template name determines the file creation attributes of the file. For example:
SQL> CREATE TEMPORARY TABLESPACE temp01
SQL> TEMPFILE '+ASM1DG1(TEMPFILE)' SIZE 32M;
ASM File Name Aliases

ASM file name aliases can be used to create new or reference existing ASM files. While aliases do specify a disk group name, they include a user-friendly name string instead of a file and incarnation number. (In fact, if I attempt to construct an alias that ended with a dotted pair of numbers, Oracle will detect the problem and will signal an error.)

Aliases are implemented using a hierarchical directory structure, thus making it simple to reference ASM files via common-sense, human-recognizable names. I can create an additional alias for each file during its creation, or I can create an alias after its creation via the ALTER DISKGROUP ADD ALIAS command.

ASM file name aliases are case-insensitive, and will always contain a slash (/) that separates its components; each component is stored in UTF-8 format and may be up to 48 bytes long, but the component itself cannot contain a slash. The components of alias file names can contain spaces between sets of characters, but the space should not be the first or last character of a component. This implies a 48-character limit in a single-byte language, but in a multi-byte language, this size limit will be lower depending upon how many multi-byte characters are present in the string.

The total length of an aliased file name, including all components and all separators, is limited to 256 bytes. I can create directory structures as required to support whatever alias naming convention is desired, but it is important to remember that these directories will still be subject to the 256-byte limit.

A common use of an ASM file name alias is during the creation of the database's control files using the CONTROL_FILES parameter, or when creating online redo log files. The following example assumes that I have already created a directory named LOGFILES:
SQL ALTER DATABASE
SQL> ADD LOGFILE GROUP 4
SQL> MEMBERS
SQL> '+ASM1DG1/logfiles/log4a.rdo' SIZE 32M,
SQL> '+ASM1DG1/logfiles/log4b.rdo' SIZE 32M;

Aliased Names Plus Templates. This file name format lists the disk group name, an alias name, and a file creation template name. It is therefore used only during ASM file creation operations. For example, this statement assumes that an aliased directory, dbf, already exists, and that I am creating a server parameter file from a parameter file:
CREATE SPFILE '+ASM1DG1/dbfs/(spfile)' FROM PFILE;

Finally, it is important to note that an ASM file that was created by specifying a user alias will not be cleaned up automatically by ASM when the file is dropped later.

Listing ASM File Name Aliases. To retrieve all ASM file name aliases stored within the database, the V$ASM_ALIAS dynamic view can be traversed, starting at the ASM disk group level and then traverse the hierarchy of the alias information stored within. Note that the REFERENCE_INDEX number is required to traverse entries that are directory entries in this view; for all other alias entry types, REFERENCE_INDEX will be zeroed out.

See Listing 3.2 for examples of how to construct directories and aliases, query the ASM instance for all available aliases, and drop aliases and directories.

Using ASM File Names in SQL Commands. Instead of supplying the full ASM file name, any of the other indirect naming methods mentioned above can be used when specifying an ASM file in a SQL command. This is in fact one of the biggest benefits of ASM: the need to specify long, cumbersome file names is reduced in almost every case. Oracle recommends using "shorthand" ASM file designations or ASM aliases as much as possible except for the few specific cases where ASM file names are needed as parameters (for example, when specifying the names of the database's online redo logs during an ALTER DATABASE RENAME FILE operation).

Default File Sizes. When ASM creates a data file for a permanent table space, or a temporary file for a temporary table space, the data file is set to auto-extensible with an unlimited maximum size and 100 MB default size. An AUTOEXTEND clause may override this default. ASM applies attributes to the files it creates as specified by the corresponding system default template.

Some Exclusions. Finally, it is important to remember that ASM does not manage any binary files (i.e. BFILEs), alert logs, user or background trace files, or Oracle database password files. These files must still be named, backed up, and managed via manual methods.
Managing An ASM Instance

Now that I have detailed ASM file naming techniques, I will turn my attention to the nuts and bolts of managing an ASM instance. Besides creating new files on the instance, I also need to know how to add new disks and new disk groups, modify disk group components, mount and dismount disk groups, and remove existing disks and disk groups from the ASM instance. Since ASM disk concepts are at the heart of these operations, an expanded exploration of ASM striping, mirroring techniques, and disk failure groups is in order.

Coarse vs. Fine-Grained Striping

When a new disk group is created, ASM will spread files in 1MB allocation unit (AU) chunks across all of the disks in a disk group. This default method, called coarse striping, eliminates the need for manual disk tuning. When striping is completed, all disks in the same ASM disk group should have about the same size and performance characteristics; this helps to insure that optimal I/O is attainable. For most installations, only a small number of disk groups should be sufficient (e.g., one disk group designated as a work area and one for a recovery area). Thus, even though the number of files and disks may increase, a constant number of disk groups will probably have to be managed.

Most ASM files stored in the ASM instance will perform well with normal (coarse) striping. However, Files like online redo logs, flashback logs, and control files typically require low latency. For these file types, ASM provides fine-grained (128K) striping. In this case, each AU is striped, and this tends to break up medium-sized I/O operations into many smaller I/O operations that will be executed in parallel.
Failure Groups

ASM failure groups provide mechanisms to prevent the failure of a set of disks within a single particular disk group that share a common resource whose failure must be tolerated. A typical example of this concept is a series of disks connected to a single, common disk controller. In this situation, if the controller failed, all the other disks on the controller's common bus would also be unavailable, even though all of the individual disks are still working fine. (Note that what constitutes a failure group tends to be site-specific and will depend upon the failure level(s) that a site can accept.)

By default, ASM assigns each disk to its own failure group. The DBA can, of course, select a different disk grouping when creating a disk group or adding a disk to a disk group. Once a set of failure groups are identified, ASM will tend to optimize file layout so that the possibility of data unavailability because of the failure of a shared resource is reduced.
Disk Group Mirroring

ASM provides three types of disk group mirroring possibilities. The first type, external redundancy, does not utilize failure groups at all and thus provides no mirroring. This type of redundancy is best when either the DBA has decided to rely upon external OS-level hardware mirroring, or when data loss is an acceptable risk due to media failure. Normal-redundancy disk groups are the ASM default, and they support two-way mirroring that insures two copies of a file extent will always exist on the disk group. Finally, high-redundancy disk groups support triple mirroring, which insures that there will always be three copies of each file extent on the disk group.

When ASM allocates a new primary extent for a file to one disk in a disk group, it allocates a mirror copy of that extent to another disk on one of the several available "partner" disks in the same disk group. Because ASM ensures that a primary extent and its mirror copy never reside in the same failure group, ASM can thus tolerate simultaneous failures of multiple disks in a single failure group. In addition, since ASM mirrors file extents instead of disks, ASM requires spare capacity only within that disk group, not among all disks.

When a disk fails – and all disks eventually do! - ASM reads the mirrored contents from the surviving disks and then automatically rebuilds the complete contents of the disk that has failed onto the surviving disks in the disk group. This also has the advantage of spreading out the I/O hit from the recovery from a disk failure across several disks.
Disk Group Rebalancing

ASM automatically rebalances a disk group whenever disks are added or dropped. Therefore, the rebalancing process requires no intervention. Because ASM uses special indexing techniques to distribute extents over all available disks in a disk group, re-striping of the data is not required; instead, ASM only moves enough data proportionally versus the amount of storage that's been added or removed. This evenly redistributes the files and keeps a balanced I/O load across all disks in the disk group.

Oracle recommends that, to avoid unnecessary data movement, it is generally more efficient to add or drop multiple disks simultaneously. This tends to insure that the disks will be rebalanced in a single operation.
Creating New Disk Groups

On to some practical examples! I have already set up some additional simulated disks on my Linux server, so I will next create a new ASM disk group via the CREATE DISKGROUP SQL command. See Listing 3.3 for the sample code I used.
Adding New Disks

If I want to add one or more ASM disks to an existing ASM disk group, I can use the ALTER DISKGROUP ADD DISK command. ASM performs the addition of ASM disks to an ASM disk group in a single operation. I can add specific ASM disks to a disk group by name, or I can choose to use a disk discovery string. The nice thing about the disk discovery string is that if ASM detects ASM disks that are already part of an ASM disk group in the folder specified by that string, the disks will be ignored and only those ASM disks that are not yet in use will be added.

When I add an ASM disk to a disk group, the ASM instance will determine if the disk is addressable and usable; if so, then the ASM disk is formatted and rebalanced. Rebalancing tends to be time-consuming because it moves extents from every file in the ASM disk group onto the new ASM disk. Though an ASM rebalancing operation does not block any ongoing database operations, rebalancing will definitely have at least some impact on the I/O load on the system. I can also tell the ASM instance to expend more resources on the rebalancing by increasing the value of the ASM_POWER initialization parameter.

See Listing 3.4 for an example of adding a new disk to an existing disk group while requesting a higher than normal amount of resources for rebalancing the affected ASM disk group.
Resizing Disks

I can easily resize an existing ASM disk via the ALTER DISKGROUP RESIZE ; command. ASM offers me the choice to resize all disks in the specified disk group, all disks in the specified failure group, or just the specified disk. Listing 3.5 shows examples of these three options.
Verifying ASM Disk Groups

Keeping my ASM disk groups in ship-shape condition should be one of my primary concerns. I can issue the ALTER DISKGROUP CHECK [NOREPAIR]; command to verify internal consistency of ASM disk group metadata and repair any possible errors. This command checks each file, each disk, or all components of the ASM disk group for any errors and will attempt to repair them. Specifying the NOREPAIR directive alerts me to any errors and bypasses any repairs; all errors will still be reported in the ASM instance's alert log. Listing 3.6 shows an example of ASM disk group verification via this command.
Manually Rebalancing a Disk Group

Even though ASM will automatically rebalance a disk group when any operation other than a MOUNT, DISMOUNT, or CHECK has been issued, I also have the option to initiate a disk rebalancing manually. Issuing the ALTER DISKGROUP REBALANCE [POWER n]; command requests ASM to perform rebalancing on the specified ASM disk group, provided that any rebalancing is needed.

If the optional POWER directive is specified, ASM will rebalance the disk group using the integer value to override the value that the ASM_POWER_LIMIT initialization parameter has set forth. I can thus override the speed of a potential rebalancing or change the power level of an ongoing rebalance operation by changing the POWER directive's value. In addition, if I set POWER to zero (0), any rebalancing on the disk group is halted until I directly or implicitly invoke the rebalancing operation again. See Listing 3.7 for an example of manual rebalancing a selected ASM disk group.
Mounting and Dismounting ASM Disk Groups

Dismounting a mounted ASM disk group is performed via the ALTER DISKGROUP DISMOUNT; command. Its reciprocal is the MOUNT directive. See Listing 3.8 for examples of both of these commands.
Removing Disks from a Disk Group

I can issue the ALTER DISKGROUP DROP DISK ; command to drop a single ASM disk from an existing ASM disk group. And I can also "undrop" (i.e. cancel the pending drop) of any ASM disks that were previously assigned to ASM disk group(s) with the ALTER DISKGROUP UNDROP DISKS; command. However, note that once a disk drop operation completes successfully, issuing UNDROP will not recover the disks. See Listing 3.9 for examples of these two commands.
Dropping a Disk Group

Finally, I can drop an entire existing ASM disk group – along with all of its files - via the DROP DISKGROUP command. If the disk group does still contain any files besides internal ASM metadata, then I have to specify the INCLUDING CONTENTS option as well. Also, the disk group to be dropped must be mounted. ASM will first validate that none of the disk group files are open, and then remove all of the assigned ASM disks and the disk group itself from the ASM instance. ASM will also overwrite the header of each previously used ASM disk to remove any remaining ASM formatting information. Listing 3.10 shows an example of this command.
Migrating a Database to ASM Storage

As discussed in the prior article in this series, ASM files cannot be accessed through normal operating system interfaces. Therefore, RMAN is the only means for copying files from regular storage to ASM, and is the only tool a DBA can use to migrate an entire database from regular to ASM storage. Oracle recommends the following process for a full database migration:

Step 1. Take a complete backup of the database before proceeding with any migration efforts. This will provide a relatively safe fallback position in case any of the migration steps outlined below should fail.

Step 2. Gather the file names of the current control files and online redo logs using V$CONTROLFILE and V$LOGFILE.

Step 3. Shut down the database in consistent mode using either SHUTDOWN IMMEDIATE, SHUTDOWN TRANSACTIONAL, or SHUTDOWN NORMAL. This is a crucial step.

Step 4. Change the database's server parameter file:
Set the necessary OMF destination parameters to the desired ASM disk group.
Remove the CONTROL_FILES parameter.

Step 5. Restore a control file from backup. This will migrate the control files to ASM storage automatically. Note that if an OMF control file is created but there is a server parameter file, then a CONTROL_FILES initialization parameter entry will also be created in the server parameter file.

Step 6. Issue ALTER DATABASE MOUNT; to mount the database.

Step 7. Edit and run an RMAN command file that:
Backs up the database
Switches the current data files to the backups
Renames the online redo logs. You can move only tablespaces or data files using the BACKUP AS COPY command

Step 8. Once the DBA is certain that the migration has been successful, she can delete the original database files left behind in the "regular" storage directories.

An example RMAN command script to accomplish Step 7 is shown in Listing 3.11.
Conclusion

While I have endeavored to introduce practical examples of how to employ Automatic Storage Management (ASM) within multiple Oracle 10g environments, I have truly just scratched the scratch on the surface of what ASM can accomplish. ASM places extremely powerful file management tools into the hands of every Oracle DBA, and it is definitely worth the effort to explore its features no matter the size of the database environment.

References and Additional Reading

While there is no substitute for direct experience, reading the manual is not a bad idea, either. I have drawn upon the following Oracle 10g documentation for the deeper technical details of this article:

B10739-01 Oracle Database Administrator's Guide, Chapter 12

B10743-01 Oracle Database Concepts, Chapter 14

B10755-01 Oracle Database Reference

B10759-01 Oracle Database SQL Reference

Fw Oracle 10g Automatic Storage Management (ASM), Part 2: Sample Implementation By Jim Czuprynski

Oracle 10g Automatic Storage Management (ASM), Part 2: Sample Implementation
By Jim Czuprynski


Synopsis. Oracle 10g's Automatic Storage Management (ASM) features offer powerful tools to Oracle DBAs to create and manage a robust, flexible, scalable file storage system ready for access by any existing Oracle database instance. This article -- the second in this series -- provides a simple yet practical demonstration of setting up an ASM instance in both the Linux and Windows NT environments for purposes of exploration and experimentation, including how to migrate existing tablespaces to the ASM storage environment.

The previous article in this series presented a high-level overview of Oracle 10g's new Automatic Storage Management (ASM) features and how ASM instances can be used in concert with other Oracle database instances to provide a scalable, reliable architecture for managing and monitoring large disk volumes via the ASM file system. Please note that this article and the corresponding examples are meant to demonstrate how ASM can be implemented on a small scale as a confidence-building exercise and to show how easy it is to set up ASM in an extremely basic single-CPU server environment. It is most definitely not intended as a starting point for a full-blown ASM implementation, which does (and should!) involve significant effort.

I will demonstrate how to set up an ASM instance in both the Linux and Windows NT operating systems, how to set up tablespaces in a database instance that uses ASM for data storage, and how to reconfigure Oracle 10g Enterprise Manager (EM) to monitor and manage the ASM instance. For my test bed servers I utilized Red Hat Enterprise Linux Advanced Server 3.0, kernel 2.4.1.2, and Windows XP 2002 Professional Service Pack 2 for these demonstrations; except where noted, all code listed as part of this article should work within either operating system.

Fortunately, the preparations required prior to creating the ASM instance and its disk groups are the most difficult part of this demonstration; once that's done, the rest is relatively simple.
Preparing Disks for ASM: Windows NT

To simulate implementation of ASM in the Windows NT environment, I first created raw disk partitions on some of my hard drives. Fortunately, I had extra space on three of the four disks in my test server, so I created several primary disk partitions sized at 100MB on each of those three drives using the Windows Disk Partitioning utility (DISKPART.EXE):
C:\> select disk 2
C:\> Disk 2 selected.
C:\> create partition primary size=100
C:\> Partition created.
C:\> create partition primary size=100
C:\> Partition created.
C:\> create partition primary size=100
C:\> Partition created.
C:\> select disk 3
C:\> Disk 3 selected.
C:\> create partition primary size=100
C:\> Partition created.
...

Figure 2.1.1 shows the results of the successful disk partitioning.

Once the partitions are completed, I used the ASMTOOLG.EXE utility to "stamp" each partition with an ASM label so that Oracle can recognize these partitions as candidate disks for the ASM instance. I executed the ASMTOOLG.EXE program from the /bin directory of the Oracle home path for my Windows NT database. Figure 2.1.2 shows the initial screen that this GUI tool presented, and Figure 2.1.3 shows the screen that confirmed the creation of the ASM labels. Once the labels were assigned, I then re-invoked ASMTOOLG to confirm them (see Figure 2.1.4). I will also use ASMTOOLG to remove the labels prior to removing these partitions once my simulation is completed.
Preparing Disks for ASM: Linux

It is much simpler to simulate deployment of ASM in the Linux environment. From the root login, I created two new folders on separate disk spindles. I then used the dd command to create several empty files ready for use as ASM disks, and then set the appropriate permissions for those disks. See Listing 2.1 for the Linux commands required to accomplish this. (If you do not have separate spindles available, don't worry; just create the two folders on the same disk.)
Creating an ASM Instance Using DBCA In Windows NT

Now that I have completed preparing all my disks, I used Oracle 10g's Database Configuration Assistant (DBCA), the simplest method to create an ASM instance, since the specification of all ASM instance parameters and creation of the instance's ASM Disk Groups is quite intuitive. I invoked DBCA from a command prompt on my Windows NT server and followed these steps:
First, I chose the Create a Database option (Figure 2.2.1) and clicked the Next button.
I selected General Purpose as the Database Type (Figure 2.2.2) and clicked the Next button.
Next, I supplied values for the Global Database Name (Figure 2.2.3) and clicked the Next button.
I then accepted all default values for the Management Options (Figure 2.2.4) and clicked the Next button.
I supplied the same password for all database management accounts (Figure 2.2.5) and clicked on Next.
At this point, I must decide to create the ASM instance. I did this by selecting the Automatic Storage Management (ASM) option (Figure 2.2.6), at which point I was presented with a screen for specification of the ASM instance's additional password (Figure 2.2.7). Note that I could also click on the ASM Parameters button to specify exactly which directories Oracle should search for candidates for ASM disks, but in this case, I decided to let Oracle find the disks on its own. I clicked on Next to let Oracle create the ASM instance.
Once the ASM instance had been created successfully, the screen in Figure 2.2.8 was presented. After I clicked on the Create New button, Oracle displayed the screen in Figure 2.2.9 to show all Windows NT partitions that were candidates for ASM disk group creation. I then selected the partitions desired, supplied a name for the ASM disk group (DGROUP1), and clicked the OK button to complete the ASM disk group creation.
Once the ASM disk groups were created, Oracle presented one last screen (Figure 2.2.10) to confirm the disk group creation. At this point, even though it seems counter-intuitive, I clicked the Cancel button to complete the creation of the ASM instance, as there are no further steps required.
Creating an ASM Instance Using DBCA in Linux

I used this same methodology to create an ASM instance in Linux using DBCA. The only significant difference was the contents of the Disk Selection window (Figure 2.2.9), which instead showed the candidate disks I had previously created on that server for the Linux environment. In either of these cases, the end result is the same: Once I clicked on the Cancel button on the last screen, Oracle dismounted the ASM disk group I had created and then shut down the ASM instance as well.
Creating an ASM Instance without Using DBCA

Of course, I don't have to use DBCA to create an ASM instance. Personally, I prefer to use command scripts to create my database because it is easier to customize the scripts to create other ASM instances in the future, and it also gives me complete control over what Oracle is doing "behind the screen." In addition, an ASM instance is extremely easy to create because no CREATE DATABASE script is required, just an initialization parameter file like the one shown in Listing 2.2. Besides the usual initialization parameters for trace file directories, there are only a few additional ones required to create an ASM instance:
ASM Initialization Parameters

Initialization Parameter
Description

INSTANCE_TYPE
Defines the instance as an ASM instance. This is the only required parameter to identify an ASM instance; the remainder can be left at their defaults

DB_UNIQUE_NAME
Defines the service provider name for which this ASM instance manages disk groups. +ASM is the default value, and should not be modified unless multiple ASM instances are on the same node

ASM_POWER_LIMIT
Controls rebalance operation speed. Values range from 1 to 11, with 11 being the fastest. If omitted, this value defaults to 1. The number of slaves is derived from the parallelization level specified in a manual rebalance command (POWER), or by the ASM_POWER_LIMIT parameter

ASM_DISKSTRING
An operating system dependent value; used by ASM to limit the set of disks considered for discovery

ASM_DISK_GROUPS
Describes the list of ASM disk group names to be mounted by an ASM instance at startup, or whenever the ALTER DISKGROUP ALL MOUNT command is used

LARGE_POOL_SIZE
The LARGE POOL size. This must be set to a minimum of 8MB, but Oracle recommends setting this to 16MB


To create the ASM instance without using DBCA, I first made sure that I had created the directories I specified for BACKGROUND_DUMP_DEST, CORE_DUMP_DEST, and USER_DUMP_DEST. I also created a password file for the instance using the ORAPWD utility. (This is important, because when you attempt to connect to the ASM instance from Enterprise Manager, it will expect the instance to have the REMOTE_LOGIN_PASSWORDFILE initialization parameter set to EXCLUSIVE so that the instance can be contacted remotely and that means a password file will be required.)
ORAPWD file=c:\oracle\app\product\10.1.0\db_1\database\PWD+ASM.ora password=oracle

After I had made sure that the Oracle Cluster Services service was started in my Windows NT environment - it is usually named OracleCSService in the list of Windows Services that I can start - I then simply pointed my MS-DOS command window at the database instance by setting the value for ORACLE_SID to +ASM, started a SQL*Plus session, created an SPFILE from the parameter file, and then started the ASM instance in NOMOUNT mode:
C:\> set ORACLE_SID=+ASM
C:\> sqlplus "sys as sysdba"
SQL> Connected to an idle instance.
SQL> create spfile from pfile=c:\init+asm.ora;
SQL> File created.
SQL> startup nomount;
SQL> ASM instance started

Creating ASM Disk Groups without Using DBCA

If I am using DBCA to create my sample ASM instance, Oracle formats the commands necessary to create the initial ASM disk group(s) for the instance during its creation. However, I can also create the ASM disk groups separately after the necessary instance creation scripts have run successfully using the code shown in Listing 2.3. I have provided two different examples, one each for the Windows NT and Linux environments.
Starting and Stopping an ASM Instance

An ASM instance is managed in much the same way as a database instance, with a few exceptions. The major difference is that an ASM instance is never opened like a regular Oracle instance is opened, only mounted; therefore, I will either issue the STARTUP NOMOUNT; command to start just the ASM instance's memory processes, and then finish mounting the database with the ALTER DATABASE MOUNT; command. I can also open the ASM instance immediately by issuing the STARTUP MOUNT; command.

Starting a Dormant ASM Instance. To start up a dormant ASM instance, I first have to remember to set the ORACLE_SID environment variable appropriately. In addition, before I can start the ASM instance in the Windows NT environment, I also need to remember to first start the Oracle Cluster Service as well as the ASM instance's service. Of course, I do not need to worry about this in the Linux environment – the Cluster Service should have already been set up as part of the standard Linux installation of Oracle 10g.

To start up the ASM instance, I then simply issue the STARTUP MOUNT command. Here is how a successful ASM instance startup appears in the Linux environment:
$> export ORACLE_SID=+ASM
$> sqlplus "sys as sysdba"
SQL*Plus: Release 10.1.0.2.0 - Production on Tue Dec 13 16:58:17 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Enter password: ********
Connected to an idle instance.
SQL> startup mount;
ASM instance started
Total System Global Area 100663296 bytes
Fixed Size 787648 bytes
Variable Size 99875648 bytes
Database Buffers 0 bytes
Redo Buffers 0 bytes
ASM diskgroups mounted

Shutting Down an Active ASM Instance. To shut down this ASM instance, I once again set the ORACLE_SID environment variable and then simply issue the SHUTDOWN IMMEDIATE; command:
$> export ORACLE_SID=+ASM
$> sqlplus "sys as sysdba"
SQL> Connected.
SQL> shutdown immediate;
ASM diskgroups dismounted
ASM instance shutdown
SQL>

Implications of Shutting Down an Active ASM Instance. Now, a warning: When an ASM instance is shut down, it is important to be aware of the implications for any regular Oracle database instance that is using ASM files stored on that ASM instance. The ASM files will not be accessible to those regular Oracle databases until the ASM instance is restarted.
Demonstrating ASM in a Sample Database

Now that I have explained how to create, start, and stop an ASM instance, I will next demonstrate how to add a tablespace to an existing Oracle database instance that uses the ASM instance's disk group instead of the database instance's disk storage to store the new tablespace's datafile.

Creating an ASM-Managed Tablespace. What I really like about ASM is its simplicity. I no longer need to be concerned if the tablespace's datafile will fit on the drive or spindle I have targeted for storage; I simply inform ASM that it is responsible for storing the datafile and how large the datafile is, and ASM handles the rest.

All I needed to do to create a new tablespace, TBS_ASM1, was to issue the following CREATE TABLESPACE command from a SQL*Plus session running against the database instance:
SQL> CREATE TABLESPACE tbs_asm1 DATAFILE '+DGROUP1' SIZE 32M;
Tablespace created.

Note that I did not have to specify the exact location of the datafile, since ASM determined from the size of the tablespace exactly how it should be striped across the disks in the ASM disk group. Moreover, since ASM uses Oracle Managed Files (OMF) for naming the datafile, ASM automatically named the datafile using the appropriate OMF standard. (I will delve into ASM file naming conventions in greater detail in the next article in this series.)

Even more interesting, I did not have to do anything special to inform the database instance that it needed to start up the appropriate Rebalancing (RBAL) and ASM Bridge (ASM) processes. As soon as this new tablespace was created, the database instance detected that ASM storage was in use, and it automatically started these two background processes, as this snippet from the database's alert log clearly shows:
...
Sun Dec 11 18:35:00 2005
CREATE TABLESPACE tbs_asm1 DATAFILE '+DGROUP1' SIZE 32M
Sun Dec 11 18:35:03 2005
Starting background process ASMB
ASMB started with pid=21, OS id=776
Starting background process RBAL
RBAL started with pid=22, OS id=3524
Sun Dec 11 18:35:09 2005
SUCCESS: diskgroup DGROUP1 was mounted
Completed: CREATE TABLESPACE tbs_asm1 DATAFILE '+DGROUP1' SIZ
...

Migrating an Existing Tablespace to ASM-Managed Storage. Another great thing about ASM: I did not have to recreate an existing tablespace when I wanted to migrate it to ASM storage. Instead, I used Recovery Manager (RMAN) to create an image copy of the tablespace's datafile, and then I simply migrated that datafile to ASM. To demonstrate, I created a new tablespace in the database instance. I then issued the appropriate RMAN commands to take the tablespace offline, create the image copy of the tablespace, transfer the tablespace to ASM, and then bring the tablespace back online. See Listing 2.4 for the SQL statements and RMAN commands that I used to complete this task.
Setting Up Enterprise Manager (EM) for ASM Instance Management

Oracle 10g Enterprise Manager (EM) does provide a simple and elegant way to manage ASM storage; however, I needed to reconfigure my database instance's EM configuration to take advantage of these tools via the Enterprise Manager Configuration Assistant (EMCA). Once I had created the ASM instance and had then created at least one ASM-managed file in my database instance, I removed the original EM configuration for the database instance and then replaced it with a new EM configuration that fully supports ASM. A sample set of EMCA commands are shown in Listing 2.5.

After I restarted the EM Database Console service for my database, I was then able to view details about the ASM instance as well by clicking on the ASM link on my database instance's home page (see Figure 2.3 for an example of that screen). I will explore the various diagnostic tools and maintenance operations available via EM in more detail in the next article in this series.
Viewing ASM Instance Information Via SQL Queries

Finally, there are several dynamic and data dictionary views available to view an ASM configuration from within the ASM instance itself:
ASM Dynamic Views: ASM Instance Information

View Name
Description

V$ASM_ALIAS
Shows every alias for every disk group mounted by the ASM instance

V$ASM_CLIENT
Shows which database instance(s) are using any ASM disk groups that are being mounted by this ASM instance

V$ASM_DISK
Lists each disk discovered by the ASM instance, including disks that are not part of any ASM disk group

V$ASM_DISKGROUP
Describes information about ASM disk groups mounted by the ASM instance

V$ASM_FILE
Lists each ASM file in every ASM disk group mounted by the ASM instance

V$ASM_OPERATION
Like its counterpart, V$SESSION_LONGOPS, it shows each long-running ASM operation in the ASM instance

V$ASM_TEMPLATE
Lists each template present in every ASM disk group mounted by the ASM instance


I was also able to query the following dynamic views against my database instance to view the related ASM storage components of that instance:
ASM Dynamic Views: Database Instance Information

View Name
Description

V$ASM_DISKGROUP
Shows one row per each ASM disk group that's mounted by the local ASM instance

V$ASM_DISK
Displays one row per each disk in each ASM disk group that are in use by the database instance

V$ASM_CLIENT
Lists one row per each ASM instance for which the database instance has any open ASM files


See Listing 2.6 for the SQL*Plus queries that I used to view information from the ASM and database instances.
Next Steps

The next article in this series will concentrate on some of the more advanced features of ASM, including how to add disks to and remove disks from an ASM disk group, how to increase the survivability of ASM disk groups with additional striping and mirroring features, and how to monitor and manage ASM storage through the Enterprise Manager (EM) interface.
References and Additional Reading

While there is no substitute for direct experience, reading the manual is not a bad idea, either. I have drawn upon the following Oracle 10g documentation for the deeper technical details of this article:

B10130-02 Oracle Database Installation Guide 10g (10.1.0.2) For Windows, Section 2.5.3

B10739-01 Oracle Database Administrator's Guide, Chapter 12

B10743-01 Oracle Database Concepts, Chapter 14

B10755-01 Oracle Database Reference

B10759-01 Oracle Database SQL Reference

Fw Oracle 10g Automatic Storage Management, Part 1: Overview By Jim Czuprynski

Oracle 10g Automatic Storage Management, Part 1: Overview
Jim Czuprynski, Jim.Czuprynski@us.fujitsu.com



Synopsis. Oracle 10g's new Automatic Storage Management (ASM) features allow an Oracle DBA to take advantage of a robust, flexible, scalable file storage system that any Oracle database instance can access. This article - the first in this series -- provides a high-level overview of the ASM architecture, and should be helpful to any DBA contemplating the adoption of ASM for storing Oracle database files as part of a high-volume storage solution.

With the possible exception of having to rebuild a database server from a "cold metal" starting point, I have to admit that the scenario that holds the most dread for me as an Oracle DBA is to run out of disk space for a production database's datafiles or tempfiles. Though, in most cases this situation can be rectified easily - as long as there is sufficient disk space available, of course! - it always seems that these challenges seem to occur either at the busiest time of my client's business day, or between 02:00 and 03:00 on an early Sunday morning when I am scheduled to be out of town enjoying a long weekend. And I have also encountered my share of unexpected (and unlikely) disk media failures. For example, I once watched five disks in a 42-disk mirrored storage array fail within a three-week period after three years of relatively solid performance. The pattern never repeated itself, but it did teach me the value of a good mirroring strategy!

While a storage area network (SAN) and other logical volume manager (LVM) storage solutions like EMC are certainly options for guaranteed storage reliability, the costs of these solutions can be prohibitive for smaller IT organizations. The good news is that Oracle 10g supplies a new set of disk media storage features called Automatic Storage Management (ASM) that are aimed directly at insuring a storage solution for smaller enterprise databases. This series of articles will delve into ASM's rich features and provide examples of how to implement some simple ASM disk configurations for evaluation purposes so that your DBA team can make some decisions about whether ASM is worth pursuing for your organization. I will concentrate this article on a general review of ASM features as well as a brief explanation of the ASM architecture.
Automatic Storage Management Features

Out-Of-The-Box Functionality. First off, ASM was designed specifically for the storage of Oracle database files. This means that it is ready "out of the box" for use against any Oracle database that it services. Though ASM appears to be the intended replacement for Oracle Cluster File System (OCFS) for the Real Applications Cluster (RAC) environment, that doesn't mean that your database needs to be deployed under RAC to take advantage of ASM's myriad features; ASM can be deployed on a single processor (SMP) server just as easily as it can be deployed on a multiple-node RAC cluster. Moreover, it is simple to configure using the graphic interface provided by the Database Configuration Assistant (DBCA), an existing Oracle tool that just about every Oracle DBA has used. Oracle 10g also provides the standard Enterprise Manager (EM) interface for managing an ASM instance once it has been created.

Flexible Storage Configuration. Since ASM is in essence its own file management system, this means that I can add more physical storage, change storage configurations, or remove extraneous storage without having to shut down my Oracle database to change out physical hardware. This is a big advantage over traditional hardware configurations, and is certainly featured in storage-area networks (SANs).

Using ASM also means that I can turn over the majority of my space management tasks to the ASM instance and let it monitor the growth of my database's tablespaces. In addition, ASM maintains pre-existing Oracle database functionality, so regular Oracle databases can continue to operate as usual. New database files can be created as ASM files managed by the ASM instance, existing database files can be migrated to ASM as time and opportunity permit, and other database files can continue to exist as "traditional" database files without ASM file management.

Fault Tolerance. I also expect any file management system to insure that once I write database information to disk, it will never be lost - unless, of course, I tell the database to delete that data. One way that DBAs usually guarantee against the inevitable failure of disk hardware is through mirroring drives via redundant arrays of inexpensive disks (aka RAID) and striping (writing portions of disk files to different disks so that if one disk is lost the information is recoverable from another disk in the set). This guards against the inevitable failure of disk hardware, since even with extremely high estimated mean time between failures (MTBF), a disk drive will almost certainly fail eventually.

Most operating systems provide controls to set up and monitor disk storage to take advantage of these redundancy features. Like any good file management system, ASM provides fault tolerance by allowing me to write duplicate or triplicate copies of any database files' contents. And if my current server and disk storage system already support fault tolerance, so much the better! ASM can also take advantage of existing vendor-supplied fault tolerance mechanisms for increased guarantees to safe data storage.

Since ASM handles the mirroring of data, there is no need to purchase a third-party Logical Volume Manager (LVM). Mirroring is applied on a file-by-file basis, rather than on a per-volume basis, so the same disk group may contain a combination of files protected by mirroring (or perhaps not even mirrored at all, if mirroring is not required for some files). ASM also supports Oracle Real Application Clusters (RAC), so there is no need for a separate Cluster LVM or a Cluster File System.

I/O Load Balancing. ASM is responsible for providing equal distribution of I/O loads across all available disk storage resources, so there is a measurable performance improvement. For example, ASM will split a datafile into its component extents and then spread those extents evenly across all defined disks that ASM is managing; those extents are then tracked via an indexing technique. ASM also automatically manages data via selection of desired reliability and performance characteristics instead of manually manipulating data file storage characteristics, and therefore it tends to reduce (or even eliminate) manual tuning and retuning of I/O.

A big advantage to this approach is that when ASM storage capacity changes, ASM doesn't need to re-stripe all data - it just moves enough data in proportion to the amount of added (or reduced!) storage, thus redistributing the datafile's extents evenly and keeping a balanced data load across all disks. Moreover, since ASM can accomplish the rebalancing act while the database is active, there is virtually no impact on database availability. I can also instruct ASM to increase the speed of a space rebalancing operation if I know that sufficient system resources are available, or I can tell ASM to reduce the speed of the rebalancing operation to limit the impact on the ASM I/O subsystem.

Productivity Increases. Here is one final, intangible benefit of ASM: an increase in my productivity as a DBA. Since I am freed up from physical and logical space management worries, I can now concentrate my limited and valuable time on more critical database tuning issues, like poorly-structured SQL statements and inefficient logical storage structures that tend to be the real culprits behind database performance issues.
The ASM Instance

The ASM instance is at the heart of Automatic Storage Management. Rather than "reengineer the wheel," Oracle decided to adopt the basic architecture of a normal Oracle database instance. An ASM instance never actually opens a database; instead, it is responsible for storing and processing the metadata that is required to make available the files stored within the ASM storage system to non-ASM Oracle databases (henceforth referred to as database instances).

In addition to the normal database background processes like CKPT, DBWR, LGWR, SMON, and PMON, an ASM instance uses at least two additional background processes to manage data storage operations. The Rebalancer process, RBAL, coordinates the rebalance activity for ASM disk groups, and the Actual ReBalance processes, ARBn, handle the actual rebalance of data extent movements. There are usually several ARB background processes (ARB0, ARB1, and so forth). I will talk more about disk rebalancing operations in the final article in this series.

Starting Up and Shutting Down an ASM Instance. The ASM instance can be can be started in NOMOUNT mode, and ASM disk groups are mounted via the MOUNT command. Similarly, disk groups can be taken offline with the SHUTDOWN command. When an ASM instance is started and appropriate ASM disk groups are mounted, all ASM files contained on those disk groups are made accessible to any Oracle database. Any database instance can use the ASM disk groups as targets for creating new ASM-managed files.

Managing an ASM Instance. Managing access to the ASM instance is relatively straightforward. The DBA can issue the ALTER SYSTEM ENABLE RESTRICTED SESSION; command to prevent database instances from accessing ASM disk groups while maintenance is being performed against the ASM instance or any ASM disk groups. Alternatively, issuing the ALTER SYSTEM DISABLE RESTRICTED SESSION; command re-enables access to the ASM instance.

The only way to connect to an ASM instance is via OS authentication (i.e. SYSDBA or SYSOPER) because an ASM instance does not have a data dictionary per se. Connecting to an ASM via a remote connection implies, of course, that a password file must be used. Normally, the SYSDBA privilege is granted through the use of an operating system group (on UNIX or Linux, typically the dba group). Since by default members of that group have SYSDBA privilege on all instances on the node, including the ASM instance, any user that connects to the ASM instance with the SYSDBA privilege has administrative access to all ASM disk groups in the system.

The SYSOPER privilege is also supported in ASM instances and limits the set of allowable SQL commands to the minimum required for basic operation of an already-configured system. A user with SYSOPER permissions can start up or shut down an ASM instance, take disk groups online or offline, issue a manual rebalance request, and verify a disk group. However, more advanced command sets like those for creating new ASM disk groups, resizing ASM disks, adding new ASM disks to existing ASM disk groups, and dropping ASM disk groups are reserved to users with the SYSDBA privilege.
The ASM Storage Hierarchy

ASM provides a flexible storage hierarchy for managing access to its disk files, starting with the smallest unit of storage, the Allocation Unit (AU). All ASM disk space is partitioned in AUs of 1 MB each, and blocks will never be split across any allocation unit.

ASM Files. Next in the hierarchy are the actual ASM files themselves. With the exception of trace files and operating system files, ASM can store every type of Oracle database file, including control files, server parameter files (SPFILEs), datafiles, tempfiles, online redo logs, archived redo logs, flashback logs, DataPump dump sets. In addition, ASM can store all types of files managed by Recovery Manager (RMAN), including backup sets, archived redo log image copies, datafile image copies, and autobackups.

ASM Disk Groups. The highest level of storage unit in an ASM instance is the ASM Disk Group. An ASM disk group can support multiple files that belong to multiple Oracle database instances. Each ASM disk group consists of one or more ASM Disks, and an ASM Disk belongs to one and only one ASM Disk Group. All ASM files in the ASM Disk Group will be spread across all the ASM disks in the ASM disk group; however, a single ASM File will never span more than one ASM disk group.

ASM disk groups are accessible by either ASM instances or database instances, and database instances can access the contents of ASM files directly, communicating with an ASM instance only to get information about the layout of these files. An ASM instance supports the addition of new ASM disks, deletion of existing ASM disks and disk groups, and modifications to existing ASM disk groups (e.g. adding new ASM disks).

ASM File Naming Conventions and File Name Aliasing. ASM uses a four-layer file name to identify an ASM file. The ASM file name consists of the ASM disk group name, the database instance name, and the file type; the final file name component consists of three tokens, a file type token (e.g. CF for control file) and two integer values. The combination of these file name components insures that an ASM file name is always unique and can be easily tied back to its owning ASM disk group and database instance. Since the ASM file naming convention can be cumbersome, ASM also supports file name aliases for easier referencing of the ASM file instead of using the fully-qualified ASM file name.
Implementing ASM Storage In Oracle Databases

Every database instance that uses ASM for file storage will also need two new processes. The Rebalancer background process (RBAL) handles global opens of all ASM disks in the ASM Disk Groups, while the ASM Bridge process (ASMB) connects as a foreground process into the ASM instance when the regular database instance starts. ASMB facilitates communication between the ASM instance and the regular database, including handling physical file changes like data file creation and deletion.

ASMB exchanges messages between both servers for statistics update and instance health validation. These two processes are automatically started by the database instance when a new Oracle file type - for example, a tablespace's datafile -- is created on an ASM disk group. When an ASM instance mounts a disk group, it registers the disk group and connect string with Group Services. The database instance knows the name of the disk group, and can therefore use it to locate connect information for the correct ASM instance.

ASM Instance Failure Scenarios. There are some implications for any database instance that is using ASM files for storage: When an ASM instance is shut down, any database instance that is using that ASM instance to store ASM files will lose contact with those ASM-managed files. Oracle 10g overcomes this potential failure scenario by allowing multiple ASM instances to share ASM disk groups, so if one ASM instance should fail, another ASM instance can continue to manage the changes to data stored on those disk groups.
Next Steps

The next article in this series will focus on a simple implementation of Automated Storage Management. It provides examples of how to create an example ASM instance in both the Red Hat Enterprise Linux (RHEL) and Windows NT environments as well as a demonstration of how to implement basic ASM storage for an existing Oracle database instance.
References and Additional Reading

While there is no substitute for direct experience, reading the manual is not a bad idea, either. I have drawn upon the following Oracle 10g documentation for the deeper technical details of this article:

B10739-01 Oracle Database Administrator's Guide, Chapter 12

B10743-01 Oracle Database Concepts, Chapter 14

B10755-01 Oracle Database Reference

B10759-01 Oracle Database SQL Reference

Oracle 11g 5 Administering ASM Files, Directories, and Templateshttp://download.oracle.com/docs/cd/B28359_01/server.111/b31107/asmfiles.htm#i1020522

Oracle® Database Storage Administrator's Guide
11g Release 1 (11.1)
Part Number B31107-03

5 Administering ASM Files, Directories, and Templates

This chapter describes how to administer files when you use the Automatic Storage Management (ASM) storage option. This appendix contains the following topics:

What Types of Files Does ASM Support?

About ASM Filenames

Creating and Referencing ASM Files in the Database

Managing Alias Names for ASM Filenames

Accessing ASM Files with the XML DB Virtual Folder

Using DBMS_FILE Transfer Utility for ASM

Managing Disk Group Directories

Managing Disk Group Templates
What Types of Files Does ASM Support?

ASM supports most file types required by the database. However, you cannot store some administrative file types on ASM disk groups. These include trace files, audit files, alert logs, export files, tar files, and core files.

Table 5-1 lists file types, indicates if they are supported, and lists the system default template that provides the attributes for file creation. Some of the file types shown in the table are related to specific products or features, and are not discussed in this book.

Table 5-1 File Types Supported by Automatic Storage ManagementFile Type Supported Default Templates

Control files
yes
CONTROLFILE

Datafiles
yes
DATAFILE

Redo log files
yes
ONLINELOG

Archive log files
yes
ARCHIVELOG

Trace files
no
n/a

Temporary files
yes
TEMPFILE

Datafile backup pieces
yes
BACKUPSET

Datafile incremental backup pieces
yes
BACKUPSET

Archive log backup piece
yes
BACKUPSET

Datafile copy
yes
DATAFILE

Persistent initialization parameter file (SPFILE)
yes
PARAMETERFILE

Disaster recovery configurations
yes
DATAGUARDCONFIG

Flashback logs
yes
FLASHBACK

Change tracking file
yes
CHANGETRACKING

Data Pump dumpset
yes
DUMPSET

Automatically generated control file backup
yes
AUTOBACKUP

Cross-platform transportable datafiles
yes
XTRANSPORT

Operating system files
no
n/a



See Also:
"Managing Disk Group Templates" for a description of the system default templates
About ASM Filenames

Every file created in ASM gets a system-generated filename, known as a fully-qualified filename. The fully-qualified filename represents a complete path name in the ASM file system. An example of a fully-qualified filename is:

+dgroup2/sample/controlfile/Current.256.541956473

You can use the fully-qualified filename to reference (read or retrieve) an ASM file. You can also use other abbreviated filename formats, such as an alias ASM filename described in "Alias ASM Filenames", to reference an ASM file.

ASM generates a fully-qualified filename upon any request to create a file. A creation request does not or cannot specify a fully-qualified filename. Instead, it uses a simpler syntax to specify a file, such as an alias or just a disk group name. ASM then creates the file, placing it in the correct ASM path according to file type, and then assigns an appropriate fully-qualified filename. If you specify an alias in the creation request, ASM also creates the alias so that it references the fully-qualified filename.

ASM file creation requests are either single file creation requests or multiple file creation request.

Note:
You can find the generated name in database views displaying Oracle file names, such as V$DATAFILE and V$LOGFILE. You can use this name, or an abbreviated form of it, if you later need to reference an ASM file in a SQL statement. Like other Oracle database filenames, ASM filenames are kept in the control file and the RMAN catalog.

Note:
Fully-qualified and numeric filenames can be used in single-file create if you specify the REUSE keyword, as described in "Using ASM Filenames in SQL Statements".

This sections contains the following topics:

Single File Creation Request

Multiple File Creation Request

Fully-qualified ASM Filename

Numeric ASM Filename

Alias ASM Filenames

Alias ASM Filename with Template

Incomplete ASM Filename

Incomplete ASM Filename with Template

Table 5-2 specifies the valid contexts for each filename form, and if the form is used for file creation, whether the created file is an Oracle Managed Files (OMF).

Table 5-2 Valid Contexts for the ASM Filename FormsFilename Form Valid Context OMF
Reference Single-File Creation Multiple File Creation Created as OMF?

Fully-qualified filename
Yes
No
No


Numeric filename
Yes
No
No


Alias filename
Yes
Yes
No
No

Alias with template filename
No
Yes
No
No

Incomplete filename
No
Yes
Yes
Yes

Incomplete filename with template
No
Yes
Yes
Yes


Single File Creation Request

A single file creation request is a request to create a single file, such as a datafile or a control file. The form of the ASM filename in this type of request is either an alias (such as +dgroup2/control/ctl.f) or a disk group name preceded by a plus sign. You use the alias or disk group name where a filename is called for in a statement, such as CREATE TABLESPACE or CREATE CONTROLFILE.

Note:
'/ ' and '\' are interchangeable in filenames. Filenames are case insensitive, but case retentive.
Multiple File Creation Request

A multiple file creation request is a request that can occur multiple times to create an ASM file. For example, if you assign a value to the initialization parameter DB_CREATE_FILE_DEST, you can issue a CREATE TABLESPACE statement (without a filename specification) multiple times. Each time, ASM creates a different unique datafile name.

One form of the ASM filename to use in this type of request is an incomplete filename, which is just a disk group name preceded by a plus sign. In this case, you set DB_CREATE_FILE_DEST to an incomplete filename (for example, +dgroup2), and whenever a command is executed that must create a database file in DB_CREATE_FILE_DEST, the file is created in the designated disk group and assigned a unique fully-qualified name. You can use an incomplete filename in other *_DEST initialization parameters.
Fully-qualified ASM Filename

This form of ASM filename can be used for referencing existing ASM files. It is the filename that ASM always automatically generates when an ASM file is created.

A fully-qualified filename has the following form:

+group/dbname/file_type/file_type_tag.file.incarnation

Where:

+group is the disk group name preceded by a plus sign.

You can think of the plus sign (+) as the root directory of the ASM file system, similar to the slash (/) on UNIX or Linux computers.

dbname is the DB_UNIQUE_NAME of the database to which the file belongs.

file_type is the Oracle file type and can be one of the file types shown in Table 5-3.

file_type_tag is type specific information about the file and can be one of the tags shown in Table 5-3.

file.incarnation is the file/incarnation pair, used to ensure uniqueness.

An example of a fully-qualified ASM filename is:

+dgroup2/sample/controlfile/Current.256.541956473

Table 5-3 Oracle File Types and Automatic Storage Management File Type TagsAutomatic Storage Management file_type Description Automatic Storage Management file_type_tag Comments

CONTROLFILE
Control files and backup control files
Current

Backup
--

DATAFILE
Datafiles and datafile copies
tsname
Tablespace into which the file is added

ONLINELOG
Online logs
group_group#
--

ARCHIVELOG
Archive logs
thread_thread#_seq_sequence#
--

TEMPFILE
Tempfiles
tsname
Tablespace into which the file is added

BACKUPSET
Datafile and archive log backup pieces; datafile incremental backup pieces
hasspfile_timestamp
hasspfile can take one of two values: s indicates that the backup set includes the spfile; n indicates that the backup set does not include the spfile.

PARAMETERFILE
Persistent parameter files
spfile


DAATAGUARDCONFIG
Data Guard configuration file
db_unique_name
Data Guard attempts to use the service provider name if it is set. Otherwise the tag defaults to DRCname.

FLASHBACK
Flashback logs
log_log#
--

CHANGETRACKING
Block change tracking data
ctf
Used during incremental backups

DUMPSET
Data Pump dumpset
user_obj#_file#
Dump set files encode the user name, the job number that created the dump set, and the file number as part of the tag.

XTRANSPORT
Datafile convert
tsname
--

AUTOBACKUP
Automatic backup files
hasspfile_timestamp
hasspfile can take one of two values: s indicates that the backup set includes the spfile; n indicates that the backup set does not include the spfile.


Numeric ASM Filename

The numeric ASM filename can be used for referencing existing files. It is derived from the fully-qualified ASM filename and takes the form:

+group.file.incarnation

Numeric ASM filenames can be used in any interface that requires an existing file name.

An example of a numeric ASM filename is:

+dgroup2.257.541956473
Alias ASM Filenames

Alias ASM filenames, otherwise known as aliases, can be used both for referencing existing ASM files and for creating new ASM files. Alias names start with the disk group name preceded by a plus sign, after which you specify a name string of your choosing. Alias filenames are implemented using a hierarchical directory structure, with the slash (/) or backslash (\) character separating name components. You can create an alias in any system-generated or user-created ASM directory. You cannot create an alias at the root level (+), however.

When you create an ASM file with an alias filename, the file is created with a fully-qualified name, and the alias filename is additionally created. You can then access the file with either name.

Alias ASM filenames are distinguished from fully-qualified filenames or numeric filenames because they do not end in a dotted pair of numbers. It is an error to attempt to create an alias that ends in a dotted pair of numbers. Examples of ASM alias filenames are:

+dgroup1/myfiles/control_file1
+dgroup2/mydir/second.dbf

Oracle Database references database files by their alias filenames, but only if you create the database files with aliases. If you create database files without aliases and then add aliases later, the database references the files by their fully-qualified filenames. The following are examples of how the database uses alias filenames:

Alias filenames appear in V$ views. For example, if you create a tablespace and use an alias filename for the datafile, the V$DATAFILE view shows the alias filename.

When a control file points to datafiles and online redo log files, it can use alias filenames.

The CONTROL_FILES initialization parameter can use the alias filenames of the control files. The Database Configuration Assistant (DBCA) creates control files with alias filenames.

Note:
Files created using an alias filename are not considered Oracle Managed Files and might require manual deletion in the future if they are no longer needed.

See Also:

"Managing Alias Names for ASM Filenames"
Creating a Tablespace in ASM: Using a Datafile with an Alias Name

The following statement creates an undo tablespace with a datafile that has an alias name, and with attributes that are set by the user-defined template my_undo_template. This example assumes that a directory has been created in disk group dgroup3 to contain the alias name and that the user-defined template exists. Because an alias is used to create the datafile, the file is not an Oracle Managed Files (OMF) file and the file is not be automatically deleted when the tablespace is dropped.
CREATE UNDO TABLESPACE myundo
DATAFILE '+dgroup3(my_undo_template)/myfiles/my_undo_ts' SIZE 200M;

The following statement drops the file manually after the tablespace has been dropped:
ALTER DISKGROUP dgroup3 DROP FILE '+dgroup3/myfiles/my_undo_ts';
Alias ASM Filename with Template

An alias ASM filename with template is used only for ASM file creation operations. It has the following format:

+dgroup(template_name)/alias

Alias filenames with template behave identically to alias filenames. The only difference is that a file created with an alias filename with template receives the mirroring and striping attributes specified by the named template. The template must belong to the disk group that the file is being created in.

The creation and maintenance of ASM templates is discussed in "Managing Disk Group Templates".

An example of an alias ASM filename with template is:

+dgroup1(my_template)/config1

Explicitly specifying a template name, as in this example, overrides the system default template for the type of file being created.

Note:
Files created using an alias filename with template are not considered Oracle Managed Files and might require manual deletion in the future if they are no longer needed.
Incomplete ASM Filename

Incomplete ASM filenames are used only for file creation operations and are used for both single and multiple file creation. They consist only of the disk group name. ASM uses a system default template to determine the ASM file mirroring and striping attributes. The system template that is used is determined by the file type that is being created. For example, if you are creating a datafile for a tablespace, the datafile template is used.

An example of using an incomplete ASM filename is setting the DB_CREATE_FILE_DEST initialization parameter to:

+dgroup1

With this setting, every time you create a tablespace, a datafile is created in the disk group dgroup1, and each datafile is assigned a different fully-qualified name. See "Creating ASM Files Using a Default Disk Group Specification" for more information.
Incomplete ASM Filename with Template

Incomplete ASM filenames with templates are used only for file creation operations and are used for both single and multiple file creation. They consist of the disk group name followed by the template name in parentheses. When you explicitly specify a template in a file name, ASM uses the specified template instead of the default template for that file type to determine mirroring and striping attributes for the file.

An example of using an incomplete ASM filename with template is setting the DB_CREATE_FILE_DEST initialization parameter to:

+dgroup1(my_template)
Creating and Referencing ASM Files in the Database

An ASM file is an Oracle Managed File unless you created the file using an alias. Any OMF is automatically deleted when it is no longer needed. An ASM file is deleted if the creation fails.

This section contains the following topics:

Creating ASM Files Using a Default Disk Group Specification

Using ASM Filenames in SQL Statements
Creating ASM Files Using a Default Disk Group Specification

Using the Oracle Managed Files feature for operating system files, you can specify a directory as the default location for the creation of datafiles, temporary files, redo log files, and control files. Using the Oracle Managed Files feature for ASM, you can specify a disk group, in the form of an incomplete ASM filename, as the default location for creation of these files, and additional types of files, including archived log files. As for operating system files, the name of the default disk group is stored in an initialization parameter and is used whenever a file specification (for example, DATAFILE clause) is not explicitly specified during file creation.

The initialization parameters in Table 5-4 accept the multiple file creation context form of ASM filenames as a destination:

Table 5-4 Multifile ASM Filename Initialization ParametersInitialization Parameter Description

DB_CREATE_FILE_DEST
Specifies the default disk group location in which to create:

Datafiles

Tempfiles

If DB_CREATE_ONLINE_LOG_DEST_n is not specified, then also specifies the default disk group for:

Redo log files

Control file

DB_CREATE_ONLINE_LOG_DEST_n
Specifies the default disk group location in which to create:

Redo log files

Control files

DB_RECOVERY_FILE_DEST
If this parameter is specified and DB_CREATE_ONLINE_LOG_DEST_n and CONTROL_FILES are not specified, then this parameter specifies a default disk group for a flash recovery area that contains a copy of:

Control file

Redo log files

If no local archive destination is specified, then this parameter implicitly sets LOG_ARCHIVE_DEST_10 to the USE_DB_RECOVERY_FILE_DEST value.

CONTROL_FILES
Specifies a disk group in which to create control files.



The initialization parameters in Table 5-5 accept the multiple file creation context form of the ASM filenames and ASM directory names as a destination:

Table 5-5 Multifile ASM Filename and Directory Name Initialization ParametersInitialization Parameter Description

LOG_ARCHIVE_DEST_n
Specifies a default disk group or ASM directory as destination for archiving redo log files

LOG_ARCHIVE_DEST
Optional parameter to use to specify a default disk group or ASM directory as destination for archiving redo log files. Use when specifying only one destination.

STANDBY_ARCHIVE_DEST
Relevant only for a standby database in managed recovery mode. It specifies a default disk group or ASM directory that is the location of archive logs arriving from a primary database. Not discussed in this book. This parameter has been deprecated. See Oracle Data Guard Concepts and Administration.



The following example illustrates how an ASM file, in this case a datafile, might be created in a default disk group.
Creating a Datafile Using a Default Disk Group: Example

Assume the following initialization parameter setting:
DB_CREATE_FILE_DEST = '+dgroup1'

The following statement creates tablespace tspace1.
CREATE TABLESPACE tspace1;

ASM automatically creates and manages the datafile for tspace1 on ASM disks in the disk group dgroup1. File extents are stored using the attributes defined by the default template for a datafile.
Using ASM Filenames in SQL Statements

You can specify ASM filenames in the file specification clause of your SQL statements. If you are creating a file for the first time, use the creation form of an ASM filename. If the ASM file already exists, you must use the reference context form of the filename, and if you are trying to re-create the file, you must add the REUSE keyword. The space will be reused for the new file. This usage might occur when, for example, trying to re-create a control file, as shown in "Creating Control Files in ASM".

If a reference context form is used with the REUSE keyword and the file does not exist, an error results.

Partially created files resulting from system errors are automatically deleted.
Using an ASM Filename in a SQL Statement: Example

The following is an example of specifying an ASM filename in a SQL statement. In this case, it is used in the file creation context:
CREATE TABLESPACE tspace2 DATAFILE '+dgroup2' SIZE 200M AUTOEXTEND ON;

The tablespace tspace2 is created and is comprised of one datafile of size 200 MB contained in the disk group dgroup2. The datafile is set to auto-extensible with an unlimited maximum size. An AUTOEXTEND clause can be used to override this default.
Managing Alias Names for ASM Filenames

Alias names, or aliases, are intended to provide a more user-friendly means of referring to ASM files, rather than using the system-generated filenames.

You can create an alias for a file when you create it in the database, or you can add an alias to an existing file using the ADD ALIAS clause of the ALTER DISKGROUP statement. You can create an alias in any system-generated or user-created ASM directory. You cannot create an alias at the root level (+), however.

For more information about creating aliases with ASMCMD, refer to "mkalias Command".

This section contains the following sections:

Adding an Alias Name for an ASM Filename

Renaming an Alias Name for an ASM Filename

Dropping an Alias Name for an ASM Filename

Dropping Files and Associated Aliases from a Disk Group
Adding an Alias Name for an ASM Filename

Use the ADD ALIAS clause of the ALTER DISKGROUP statement to create an alias name for an ASM filename. The alias name must consist of the full directory path and the alias itself.
Example 1: Adding an Alias Name for an ASM Filename

The following statement adds a new alias name for a system-generated file name:
ALTER DISKGROUP dgroup1 ADD ALIAS '+dgroup1/mydir/second.dbf'
FOR '+dgroup1/sample/datafile/mytable.342.3';
Example 2: Adding an Alias Name for an ASM Filename

This statement illustrates another means of specifying the ASM filename for which the alias is to be created. It uses the numeric form of the ASM filename, which is an abbreviated and derived form of the system-generated filename.
ALTER DISKGROUP dgroup1 ADD ALIAS '+dgroup1/mydir/second.dbf'
FOR '+dgroup1.342.3';
Renaming an Alias Name for an ASM Filename

Use the RENAME ALIAS clause of the ALTER DISKGROUP statement to rename an alias for an ASM filename. The old and the new alias names must consist of the full directory paths of the alias names.
Example: Renaming an Alias Name for an ASM Filename

The following statement renames an alias:
ALTER DISKGROUP dgroup1 RENAME ALIAS '+dgroup1/mydir/datafile.dbf'
TO '+dgroup1/payroll/compensation.dbf';
Dropping an Alias Name for an ASM Filename

Use the DROP ALIAS clause of the ALTER DISKGROUP statement to drop an alias for an ASM filename. The alias name must consist of the full directory path and the alias itself. The underlying file to which the alias refers is unchanged.
Example 1: Dropping an Alias Name for an ASM Filename

The following statement drops an alias:
ALTER DISKGROUP dgroup1 DROP ALIAS '+dgroup1/payroll/compensation.dbf';
Example 2: Dropping an Alias Name for an ASM Filename

The following statement will fail because it attempts to drop a system-generated filename. This is not allowed:
ALTER DISKGROUP dgroup1
DROP ALIAS '+dgroup1/sample/datafile/mytable.342.3';
Dropping Files and Associated Aliases from a Disk Group

You can delete ASM files and their associated aliases from a disk group using the DROP FILE clause of the ALTER DISKGROUP statement. You must use a fully-qualified filename, a numeric filename, or an alias name when specifying the file that you want to delete. The underlying file on the file system is not dropped when the alias is dropped.

Some reasons why you might need to delete files include:

A file created using aliases is not an Oracle Managed File. Consequently, it is not automatically deleted.

A point-in-time-recovery of a database might restore the database to a time before a tablespace was created. The restore does not delete the tablespace, but there is no reference to the tablespace or its datafile in the restored database. You could manually delete the datafile.
Example 1: Dropping Files and Associated Aliases from a Disk Group

In the following example, the alias name for the file is used to delete both the file and the alias from a disk group:
ALTER DISKGROUP dgroup1 DROP FILE '+dgroup1/payroll/compensation.dbf';
Example 2: Dropping Files and Associated Aliases from a Disk Group

In the following example, the system-generated filename is used to drop the file and any associated alias:
ALTER DISKGROUP dgroup1
DROP FILE '+dgroup1/sample/datafile/mytable.342.372642';
Accessing ASM Files with the XML DB Virtual Folder

ASM files and directories can be accessed through a virtual folder in the XML DB repository. The repository path to the virtual folder is /sys/asm. The folder is virtual because its contents do not actually reside in the repository; they exist as normal ASM files and directories. /sys/asm provides a means to access and manipulate the ASM files and directories with programmatic APIs such as the DBMS_XDB package and with XML DB protocols such as FTP and HTTP/WebDAV.

A typical use for this capability might be to view /sys/asm as a Web Folder in a graphical user interface (with the WebDAV protocol), and then copy a Data Pump dumpset from an ASM disk group to an operating system file system by dragging and dropping.

You must log in as a user other than SYS and you must have been granted the DBA role to access /sys/asm with XML DB protocols.

Note:
The FTP protocol is initially disabled for a new XML DB installation. To enable it, you must set the FTP port to a nonzero value. The easiest way to do this is with the catxdbdbca.sql script. This script takes two arguments. The first is the FTP port number, and the second is the HTTP/WebDAV port number. The following example configures the FTP port number to 7787, and the HTTP/WebDAV port number to 8080:

SQL> @?/rdbms/admin/catxdbdbca.sql 7787 8080

Another way to set these port numbers is with the XDB Configuration page in Enterprise Manager.

See Also:

Oracle XML DB Developer's Guide for information about Oracle XML DB, including additional ways to configure port numbers for the XML DB protocol servers

Oracle Database PL/SQL Packages and Types Reference for information about the DBMS_XDB package
Inside /sys/asm

The ASM virtual folder is created by default during XML DB installation. If the database is not configured to use ASM, the folder is empty and no operations are permitted on it.

The ASM virtual folder contains folders and subfolders that follow the hierarchy defined by the structure of an ASM fully-qualified file name. Figure 5-1 show this hierarchy, which for simplicity, excludes directories created for aliases.

The folder /sys/asm contains one subfolder for every mounted disk group, and each disk group folder contains one subfolder for each database that uses the disk group. In addition, a disk group folder might contain files and folders corresponding to aliases created by the administrator. Continuing the hierarchy, the database folders contain file type folders, which contain the ASM files.

Figure 5-1 Hierarchal Structure of ASM Folders

Description of "Figure 5-1 Hierarchal Structure of ASM Folders"

Restrictions

The following are usage restrictions on /sys/asm:

You cannot create hard links to existing ASM files or directories with APIs such as DBMS_XDB.LINK.

You cannot rename (move) an ASM file to another disk group or to a directory outside ASM.

You can use the directory /sys/asm for storing the names of disk groups. You cannot store other files in this directory. Within the disk group directories under /sys/asm, such as /sys/asm/DATA, you can only store database files in these sub-directories. ASM rejects attempts to store non-database files in these directories.
Sample FTP Session

In the following sample FTP session, the disk groups are DATA and RECOVERY, the database name is MFG, and dbs is a directory that was created for aliases. All files in /sys/asm are binary.

ftp> open myhost 7777
ftp> user system
ftp> passwd dba
ftp> cd /sys/asm
ftp> ls
DATA
RECOVERY
ftp> cd DATA
ftp> ls
dbs
MFG
ftp> cd dbs
ftp> ls
t_dbl.f
t_axl.f
ftp> binary
ftp> get t_dbl.f t_axl.f
ftp> put t_db2.f
Using DBMS_FILE Transfer Utility for ASM

The DBMS_FILE_TRANSFER package provides procedures to copy ASM files within a database or to transfer binary files between databases that use ASM. The DBMS_FILE_TRANSFER package has the following procedures:

COPY_FILE—Reads a file from a source directory and creates a copy of the file in a destination directory. The source and destination directories can both be in a local file system or in an ASM disk group. You can also use this procedure to copy between a local file system and an ASM disk group; the copy operation is valid in either direction.

GET_FILE—Contacts a remote database to read a remote file and then creates a copy of the file in the local file system or ASM disk group.

PUT_FILE—Reads a local file or ASM disk group and contacts a remote database to create a copy of the file in the remote file system.

See Also:
Oracle Database PL/SQL Packages and Types Reference for more information about the DBMS_FILE_TRANSFER package
Managing Disk Group Directories

ASM disk groups contain a system-generated hierarchical directory structure for storing ASM files. The system-generated filename that ASM assigns to each file represents a path in this directory hierarchy. The following is an example of a system-generated filename:

+dgroup2/sample/CONTROLFILE/Current.256.541956473

The plus sign represents the root of the ASM file system. The dgroup2 directory is the parent directory for all files in the dgroup2 disk group. The sample directory is the parent directory for all files in the sample database, and the CONTROLFILE directory contains all control files for the sample database.

You can create your own directories within this hierarchy to store aliases that you create. Thus, in addition to having user-friendly alias names for ASM files, you can have user-friendly paths to those names.

This section describes how to use the ALTER DISKGROUP statement to create a directory structure for aliases. It also describes how you can rename a directory or drop a directory. This section contains the following topics:

Creating a New Directory

Renaming a Directory

Dropping a Directory
Creating a New Directory

Use the ADD DIRECTORY clause of the ALTER DISKGROUP statement to create a hierarchical directory structure for alias names for ASM files. Use the slash character (/) to separate components of the directory path. The directory path must start with the disk group name, preceded by a plus sign (+), followed by any subdirectory names of your choice.

The parent directory must exist before attempting to create a subdirectory or alias in that directory.
Example 1: Creating a New Directory

The following statement creates a hierarchical directory for disk group dgroup1, which can contain, for example, the alias name +dgroup1/mydir/control_file1:
ALTER DISKGROUP dgroup1 ADD DIRECTORY '+dgroup1/mydir';
Example 2: Creating a New Directory

Assuming no subdirectory exists under the directory +dgoup1/mydir, the following statement fails:
ALTER DISKGROUP dgroup1
ADD DIRECTORY '+dgroup1/mydir/first_dir/second_dir';
Renaming a Directory

The RENAME DIRECTORY clause of the ALTER DISKGROUP statement enables you to rename a directory. System created directories (those containing system-generated names) cannot be renamed.
Example: Renaming a Directory

The following statement renames a directory:
ALTER DISKGROUP dgroup1 RENAME DIRECTORY '+dgroup1/mydir'
TO '+dgroup1/yourdir';
Dropping a Directory

You can delete a directory using the DROP DIRECTORY clause of the ALTER DISKGROUP statement. You cannot drop a system created directory. You cannot drop a directory containing alias names unless you also specify the FORCE clause.
Example: Dropping a Directory

This statement deletes a directory along with its contents:
ALTER DISKGROUP dgroup1 DROP DIRECTORY '+dgroup1/yourdir' FORCE;
Managing Disk Group Templates

This section describes how to manage disk group templates under the following topics:

Template Attributes

Adding Templates to a Disk Group

Modifying a Disk Group Template

Dropping Templates from a Disk Group

Creating Tablespaces in ASM: Specifying Redundancy and Striping with Templates

Templates are used to set redundancy (mirroring) and striping attributes of files created in an ASM disk group. When a file is created, redundancy and striping attributes are set for that file based on an explicitly named template or the system template that is the default template for the file type.

When a disk group is created, ASM creates a set of default templates for that disk group. The set consists of one template for each file type (data file, control file, redo log file, and so on) that is supported by ASM. For example, a template named ONLINELOG provides the default file redundancy and striping attributes for all redo log files written to ASM disks. Default template settings depend on the disk group type. The default template for datafiles for a normal redundancy disk group sets two-way mirroring, while the corresponding default template in a high redundancy disk group sets three-way mirroring. You can modify these default templates.

For example, default redundancy for the online redo log files (ONLINELOG template) for a normal redundancy disk group is MIRROR. In Example 4-1, this means that when one copy of a redo log file extent is written to a disk in failure group controller1, a mirrored copy of the file extent is written to a disk in failure group controller2. To support the default mirroring of a normal redundancy disk group, at least two failure groups must be defined.

Table 5-8 lists the default templates and the attributes that are associated to matching files. As the table shows, the initial redundancy value of each default template depends on the type of disk group that the template belongs to.

Note:
The striping attribute of templates applies to all disk group types. This includes normal redundancy, high redundancy, and external redundancy disk group types. However, the mirroring attribute of templates applies only to normal redundancy disk groups, and is ignored for high-redundancy disk groups in which every file is always three-way mirrored. It is also ignored for external redundancy disk groups in which no files are mirrored by ASM. Nevertheless, each type of disk group gets a full set of templates, and the redundancy value in each template is always set to the proper default for the disk group type.

Using clauses of the ALTER DISKGROUP statement, you can add new templates to a disk group, modify existing ones, or drop templates. The reason to add templates is to create the right combination of attributes to meet unique requirements. You can then reference a template name when creating a file, thereby assigning desired attributes based on an individual file rather than on the file type. The V$ASM_TEMPLATE view lists all of the templates known to the ASM instance.
Template Attributes

Table 5-6 shows the permitted striping attribute values and Table 5-7 shows the permitted redundancy values for ASM templates. These values correspond to the STRIPE and REDUND columns of V$ASM_TEMPLATE.

Table 5-6 Permitted Values for ASM Template Striping AttributeStriping Attribute Value Description

FINE
Striping in 128 KB chunks.

COARSE
Striping in 1 MB chunks.



Table 5-7 Permitted Values for ASM Template Redundancy AttributeRedundancy Attribute Value Resulting Mirroring in Normal Redundancy Disk Group Resulting Mirroring in High Redundancy Disk Group Resulting Mirroring in External Redundancy Disk Group

MIRROR
Two-way mirroring
Three-way mirroring
(Not allowed)

HIGH
Three-way mirroring
Three-way mirroring
(Not allowed)

UNPROTECTED
No mirroring
(Not allowed)
No mirroring



Table 5-8 ASM System Default Templates Attribute SettingsTemplate Name Striping Mirroring, Normal Redundancy Disk Group Mirroring, High Redundancy Disk Group Mirroring, External Redundancy Disk Group

CONTROLFILE
FINE
HIGH
HIGH
UNPROTECTED

DATAFILE
COARSE
MIRROR
HIGH
UNPROTECTED

ONLINELOG
FINE
MIRROR
HIGH
UNPROTECTED

ARCHIVELOG
COARSE
MIRROR
HIGH
UNPROTECTED

TEMPFILE
COARSE
MIRROR
HIGH
UNPROTECTED

BACKUPSET
COARSE
MIRROR
HIGH
UNPROTECTED

PARAMETERFILE
COARSE
MIRROR
HIGH
UNPROTECTED

DATAGUARDCONFIG
COARSE
MIRROR
HIGH
UNPROTECTED

FLASHBACK
FINE
MIRROR
HIGH
UNPROTECTED

CHANGETRACKING
COARSE
MIRROR
HIGH
UNPROTECTED

DUMPSET
COARSE
MIRROR
HIGH
UNPROTECTED

XTRANSPORT
COARSE
MIRROR
HIGH
UNPROTECTED

AUTOBACKUP
COARSE
MIRROR
HIGH
UNPROTECTED


Adding Templates to a Disk Group

To add a template to a disk group, use the ADD TEMPLATE clause of the ALTER DISKGROUP statement. You specify the name of the template, its redundancy attribute, and its striping attribute.

Note:
If the name of your new template is not one of the names listed in Table 5-8, then it is not used as a default template for database file types. To use the name, you must reference its name when creating a file.

The syntax of the ALTER DISKGROUP command for adding a template is as follows:
ALTER DISKGROUP disk_group_name ADD TEMPLATE template_name
ATTRIBUTES ([{MIRROR|HIGH|UNPROTECTED}] [{FINE|COARSE}]);

Both types of attribute are optional. If no redundancy attribute is specified, the value defaults to MIRROR for a normal redundancy disk group, HIGH for a high redundancy disk group, and UNPROTECTED for an external redundancy disk group. If you do not specify a striping attribute, then the value defaults to COARSE.
Example 1: Adding a Template to a Disk Group

The following statement creates a new template named reliable for the normal redundancy disk group dgroup2:
ALTER DISKGROUP dgroup2 ADD TEMPLATE reliable ATTRIBUTES (HIGH FINE);
Example 2: Adding a Template to a Disk Group

The following statement creates a new template named unreliable that specifies files are to be unprotected (no mirroring):
ALTER DISKGROUP dgroup2 ADD TEMPLATE unreliable ATTRIBUTES (UNPROTECTED);

Note:
Oracle discourages using unprotected files unless you have implemented hardware mirroring. The previous example is presented only to further illustrate how the attributes for templates are set.

See Also:
Oracle Database SQL Language Reference for more information about the ALTER DISKGROUP...ADD TEMPLATE command.
Modifying a Disk Group Template

The ALTER TEMPLATE clause of the ALTER DISKGROUP statement enables you to modify the attribute specifications of an existing system default or user-defined disk group template. Only specified template properties are changed. Unspecified properties retain their current value. When you modify an existing template, only new files created by the template reflect the attribute changes. Existing files maintain their attributes.
Example: Modifying a Disk Group Template

The following example changes the striping attribute specification of the reliable template for disk group dgroup2:
ALTER DISKGROUP dgroup2 ALTER TEMPLATE reliable
ATTRIBUTES (COARSE);
Dropping Templates from a Disk Group

Use the DROP TEMPLATE clause of the ALTER DISKGROUP statement to drop one or more templates from a disk group. You can only drop templates that are user-defined; you cannot drop system default templates.
Example: Dropping a Template from a Disk Group

The following example drops the previously created template unreliable from dgroup2:
ALTER DISKGROUP dgroup2 DROP TEMPLATE unreliable;
Creating Tablespaces in ASM: Specifying Redundancy and Striping with Templates

Use the SQL ALTER SYSTEM and CREATE TABLESPACE statements to create a tablespace that uses a user-defined template to specify the redundancy and striping attributes of the datafile.
Example: Using a User-Defined Template to Specify Redundancy and Striping

The following example assumes that the template (my_template) has been defined.
ALTER SYSTEM SET DB_CREATE_FILE_DEST = '+dgroup1(my_template)';

CREATE TABLESPACE tspace3;