This action might not be possible to undo. Are you sure you want to continue?
Automatic Storage Management (ASM) is a new feature that has be introduced in Oracle 10g to simplify the storage of Oracle datafiles, controlfiles and logfiles. • • • • Overview of Automatic Storage Management (ASM) Initialization Parameters and ASM Instance Creation Startup and Shutdown of ASM Instances Administering ASM Disk Groups o Disks o Templates o Directories o Aliases o Files o Checking Metadata ASM Filenames ASM Views SQL and ASM Migrating to ASM Using RMAN
• • • •
Overview of Automatic Storage Management (ASM)
Automatic Storage Management (ASM) simplifies administration of Oracle related files by allowing the administrator to reference disk groups rather than individual disks and files, which are managed by ASM. The ASM functionality is an extention of the Oracle Managed Files (OMF) functionality that also includes striping and mirroring to provide balanced and secure storage. The new ASM functionality can be used in combination with existing raw and cooked file systems, along with OMF and manually managed files. The ASM functionality is controlled by an ASM instance. This is not a full database instance, just the memory structures and as such is very small and lightweight. The main components of ASM are disk groups, each of which comprise of several physical disks that are controlled as a single unit. The physical disks are known as ASM disks, while the files that reside on the disks are know as ASM files. The locations and names for the files are controlled by ASM, but user-friendly aliases and directory structures can be defined for ease of reference. The level of redundancy and the granularity of the striping can be controlled using templates. Default templates are provided for each file type stored by ASM, but additional templates can be defined as needed. Failure groups are defined within a disk group to support the required level of redundancy. For two-way mirroring you would expect a disk group to contain two failure groups so individual files are written to two locations. In summary ASM provides the following functionality: • • • Manages groups of disks, called disk groups. Manages disk redundancy within a disk group. Provides near-optimal I/O balancing without any manual tuning.
ora in the /tmp directory containing the following information.Specifies a globally unique name for the database. DB_UNIQUE_NAME .Set to ASM or RDBMS depending on the instance type.Specifies a value that can be used to limit the disks considered for discovery.The list of disk groups that should be mounted by an ASM instance during instance startup. SQL> CREATE SPFILE FROM PFILE='/tmp/init+ASM.• • Enables management of database objects without specifying mount points and filenames. SQL> shutdown ASM instance shutdown SQL> . To create an ASM instance first create a file called init+ASM. Supports large files. with 1 being the default. This value is also used as the default when the POWER clause is omitted from a rebalance operation. ASM configuration changes are automatically reflected in this parameter. The higher the limit the more resources are allocated resulting in faster rebalancing operations. • • Incorrect usage of parameters in ASM or RDBMS instances result in ORA-15021 errors. This defaults to +ASM but must be altered if you intend to run multiple ASM instances. Altering the default value may improve the speed of disk group mount time and the speed of adding a disk to a disk group. ASM_DISKGROUPS . start the instance with the NOMOUNT option. ASM_POWER_LIMIT -The maximum power for a rebalancing operation on an ASM instance. To shutdown the ASM instance issue the following command. File created. Finally. The default is RDBMS. using SQL*Plus connect to the ide instance. INSTANCE_TYPE=ASM Next. Changing the parameter to a value which prevents the discovery of already mounted disks results in an error. ASM_DISKSTRING .ora file. The default value is NULL allowing all suitable disks to be considered. The valid values range from 1 to 11. or by the ALTER DISKGROUP ALL MOUNT statement. SQL> startup nomount ASM instance started Total System Global Area 125829120 bytes Fixed Size 1301456 bytes Variable Size 124527664 bytes Database Buffers 0 bytes Redo Buffers 0 bytes SQL> The ASM instance is now ready to use for creating and mounting disk groups. Initialization Parameters and ASM Instance Creation The initialization parameters that are of specific interest for an ASM instance are: • • • INSTANCE_TYPE . export ORACLE_SID=+ASM sqlplus / as sysdba Create an spfile using the contents of the init+ASM.ora'.
The FORCE option can be used to move a disk from another disk group into this one.Performs a SHUTDOWN ABORT before restarting the ASM instance. The options for the SHUTDOWN command are: • • • • NORMAL .Two-way mirroring. requiring three failure groups.Same as IMMEDIATE. NOMOUNT . IMMEDIATE . CREATE DISKGROUP disk_group_1 NORMAL REDUNDANCY FAILGROUP failure_group_1 DISK '/devices/diska1' NAME diska1.Three-way mirroring. EXTERNAL REDUNDANCY .This is not a valid option for an ASM instance.The ASM instance waits for any SQL transactions to complete then shuts down. requiring two failure groups. It doesn't wait for sessions to exit. ABORT . The options for the STARTUP command are: • • • • FORCE . Administering ASM Disk Groups Disks Disk groups are created using the CREATE DISKGROUP statement.The ASM instance waits for all connected ASM instances and SQL sessions to exit then shuts down. '/devices/diska2' NAME diska2 . In addition failure groups and preferred names for disks can be defined. MOUNT .Once an ASM instance is present disk groups can be used for the following parameters in database instances (INSTANCE_TYPE=RDBMS) to allow ASM file creation: • • • • • • • DB_CREATE_FILE_DEST DB_CREATE_ONLINE_LOG_DEST_n DB_RECOVERY_FILE_DEST CONTROL_FILES LOG_ARCHIVE_DEST_n LOG_ARCHIVE_DEST STANDBY_ARCHIVE_DEST Startup and Shutdown of ASM Instances ASM instance are started and stopped in a similar way to normal database instances.Starts the ASM instance and mounts the disk groups specified by the ASM_DISKGROUPS parameter. OPEN . TRANSACTIONAL . If the NAME clause is omitted the disks are given a system generated name like "disk_group_1_0001".The ASM instance shuts down instantly. This statement allows you to specify the level of redundancy: • • • NORMAL REDUNDANCY .Starts the ASM instance without mounting any disk groups. HIGH REDUNDANCY .No mirroring for disks that are already protected using hardware mirroring or RAID.
Resize a specific disk. Templates Templates are named groups of attributes that can be applied to the files within a disk group. Remember that the wildcard "*" can be used to reference disks so long as the resulting string does not match a disk already used by an existing disk group. ALTER DISKGROUP ALL DISMOUNT. Disks can be resized using the RESIZE clause of the ALTER DISKGROUP statement. ALTER DISKGROUP disk_group_1 RESIZE DISKS IN FAILGROUP failure_group_1 SIZE 100G. The following example show how templates can be created. -. ALTER DISKGROUP ALL MOUNT. The statement can be used to resize individual disks. ALTER DISKGROUP disk_group_1 DISMOUNT. Rebalancing is only needed when the speed of the automatic rebalancing is not appropriate. -. Manual mounting and dismounting can be accomplished using the ALTER DISKGROUP statement as seen below. ALTER DISKGROUP disk_group_1 ADD DISK '/devices/disk*3'. .FAILGROUP failure_group_2 DISK '/devices/diskb1' NAME diskb1. ALTER DISKGROUP disk_group_1 UNDROP DISKS. ALTER DISKGROUP disk_group_1 REBALANCE POWER 5. DROP DISKGROUP disk_group_1 INCLUDING CONTENTS. -. If the POWER clause is omitted the ASM_POWER_LIMIT parameter value is used.Resize all disks in a disk group. -.Create a new template.Add disks. all disks in a failure group or all disks in the disk group. It will not revert drops that have completed. '/devices/diskb2' NAME diskb2. Disk groups can be deleted using the DROP DISKGROUP statement. Disk groups can be rebalanced manually using the REBALANCE clause of the ALTER DISKGROUP statement. ALTER DISKGROUP disk_group_1 MOUNT. -. If the SIZE clause is omitted the disks are resized to the size of the disk returned by the OS. Disks can be added or removed from disk groups using the ALTER DISKGROUP statement. -. Disk groups are mounted at ASM instance startup and unmounted at ASM instance shutdown. or disk drops associated with the dropping of a disk group.Drop a disk. '/devices/disk*4'.Resize all disks in a failure group. ALTER DISKGROUP disk_group_1 ADD TEMPLATE my_template ATTRIBUTES (MIRROR FINE). altered and dropped. ALTER DISKGROUP disk_group_1 RESIZE DISK diska1 SIZE 100G. The UNDROP DISKS clause of the ALTER DISKGROUP statement allows pending disk drops to be undone. ALTER DISKGROUP disk_group_1 DROP DISK diska2. ALTER DISKGROUP disk_group_1 RESIZE ALL SIZE 100G.
342.Two-way mirroring for normal redundancy and three-way mirroring for high redundancy. ALTER DISKGROUP disk_group_1 ADD DIRECTORY '+disk_group_1/my_dir'.dbf'.Delete a directory and all its contents. COARSE .dbf'. This attribute cannot be set for external redundancy.Drop template.Create an alias using the fully qualified filename. ALTER DISKGROUP disk_group_1 RENAME ALIAS '+disk_group_1/my_dir/my_file.-. ALTER DISKGROUP disk_group_1 RENAME DIRECTORY '+disk_group_1/my_dir' TO '+disk_group_1/my_dir_2'. ALTER DISKGROUP disk_group_1 DROP TEMPLATE my_template.dbf' FOR '+disk_group_1. modified and deleted. -. -. -. -. FINE . ALTER DISKGROUP disk_group_1 DELETE ALIAS '+disk_group_1/my_dir/my_file. -. -. -.3'.Rename an alias.Create an alias using the numeric form filename. MIRROR . ALTER DISKGROUP disk_group_1 ALTER TEMPLATE my_template ATTRIBUTES (COARSE).dbf' TO '+disk_group_1/my_dir/my_file2. This attribute cannot be set for external redundancy. . rather than the fully qualified ASM filenames. Aliases Aliases allow you to reference ASM files using user-friendly names.342.Rename a directory.Create a directory. ALTER DISKGROUP disk_group_1 DROP DIRECTORY '+disk_group_1/my_dir_2' FORCE.Delete an alias. The following examples show how ASM directories can be created. Directories A directory heirarchy can be defined using the ALTER DISKGROUP statement to support ASM file aliasing.dbf' FOR '+disk_group_1/mydb/datafile/my_ts.Modify template. This attribute cannot be set for external redundancy. ALTER DISKGROUP disk_group_1 ADD ALIAS '+disk_group_1/my_dir/my_file. -. Available attributes include: • • • • UNPROTECTED .3'. ALTER DISKGROUP disk_group_1 ADD ALIAS '+disk_group_1/my_dir/my_file.Specifies higher granularity for striping.No mirroring or striping regardless of the redundancy setting.Specifies lower granuality for striping.
-. -. Files Files are not deleted automatically if they are created using aliases.dbf' -.Check metadata for a specific disk in the disk group. ASM Views The ASM configuration can be viewed using the V$ASM_% views. -. which often contain different information depending on whether they are queried from the ASM instance. managed by the ASM instance.3'.Drop file using a fully qualified filename. or if a recovery is done to a point-in-time before the file was created.342. or a dependant database instance. as shown below. Displays a row for each disk in disk groups including disks which are not part in use by the database instance. Displays a row for each disk group V$ASM_DISK V$ASM_DISKGROUP Displays a row for each disk . -. ALTER DISKGROUP disk_group_1 DROP FILE '+disk_group_1/mydb/datafile/my_ts.Check metadata for a specific failure group in the disk group. Checking Metadata The internal consistency of disk group metadata can be checked in a number of ways using the CHECK clause of the ALTER DISKGROUP statement. View V$ASM_ALIAS ASM Instance Displays a row for each alias present in every disk group mounted by the ASM instance.Attempting to drop a system alias results in an error.Drop file using a numeric form filename. ALTER DISKGROUP disk_group_1 CHECK FILE '+disk_group_1/my_dir/my_file. -. ALTER DISKGROUP disk_group_1 CHECK FAILGROUP failure_group_1.Drop file using an alias. ALTER DISKGROUP disk_group_1 DROP FILE '+disk_group_1. ALTER DISKGROUP disk_group_1 CHECK ALL.Check metadata for all disks in the disk group.Check metadata for a specific file. Displays a row for each disk discovered by the ASM instance.dbf'. ALTER DISKGROUP disk_group_1 CHECK DISK diska1. ALTER DISKGROUP disk_group_1 DROP FILE '+disk_group_1/my_dir/my_file. For these circumstances it is necessary to manually delete the files.3'. -. of any disk group. as they are not Oracle Managed Files (OMF).342. DB Instance Returns no rows V$ASM_CLIENT Displays a row for each database Displays a row for the ASM instance if the instance using a disk group database has open ASM files.
V$ASM_TEMPLATE Displays a row for each template present in Displays a row for each template each disk group mounted by the ASM present in each disk group instance with which the database instance mounted by the ASM instance.incarnation +dgroup/directory/filename +dgroup(template)/alias +dgroup Incomplete ASM Filename with Template +dgroup(template) SQL and ASM ASM filenames can be used in place of conventional filenames for most Oracle file types.incarnation +dgroup. the following command creates a new tablespace with a datafile in the disk_group_1 disk group. For example. The forms for file creation are incomplete. logfiles etc. ASM instance. Displays no rows. including controlfiles. SQL> ALTER DATABASE DISABLE BLOCK CHANGE TRACKING. The forms of the ASM filenames are summarised below.group discovered by the ASM instance. datafiles. Filename Type Fully Qualified ASM Filename Numeric ASM Filename Alias ASM Filenames Alias ASM Filename with Template Incomplete ASM Filename Format +dgroup/dbname/file_type/file_type_tag. • Shutdown the database. V$ASM_FILE mounted by the local ASM instance. relying on ASM to create the fully qualified name.file. communicates. which can be retrieved from the supporting views. Displays a row for each file for V$ASM_OPERATION each long running operation executing in the ASM instance. SQL> SHUTDOWN IMMEDIATE . Displays a row for each file for each disk group mounted by the Displays no rows. Migrating to ASM Using RMAN The following method shows how a primary database can be migrated to ASM from a disk based backup: • Disable change tracking (only available in Enterprise Edition) if it is currently being used. Some forms are used during creation and some for referencing ASM files.file. CREATE TABLESPACE my_ts DATAFILE '+disk_group_1' SIZE 100M AUTOEXTEND ON. ASM Filenames There are several ways to reference ASM file.
If you are using a pfile the CONTROL_FILES parameter must be set to the appropriate ASM files or aliases. RMAN> BACKUP AS COPY DATABASE FORMAT '+disk_group'.• Modify the parameter file of the target database as follows: o Set the DB_CREATE_FILE_DEST and DB_CREATE_ONLINE_LOG_DEST_n parameters to the relevant ASM disk groups. . SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING. RMAN> STARTUP NOMOUNT • Restore the controlfile into the new location from the old location. RMAN> RESTORE CONTROLFILE FROM 'old_control_file_name'. • Open the database. • Copy the database into the ASM disk group. RMAN> ALTER DATABASE OPEN. • Start the database in nomount mode. • Switch all datafile to the new ASM location. RMAN> SWITCH DATABASE TO COPY. • Mount the database. • • Create new redo logs in ASM and delete the old ones. Enable change tracking if it was being used. o Remove the CONTROL_FILES parameter from the spfile so the control files will be moved to the DB_CREATE_* destination and the spfile gets updated automatically. RMAN> ALTER DATABASE MOUNT.