2007/11/29

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;

No comments: