Automatic Storage Management

From Oracle FAQ
⧼orafaq-jumptonavigation⧽⧼orafaq-jumptosearch⧽

Automatic Storage Management (ASM) is an Oracle database feature that provides DBAs with a simple storage management interface that is consistent across all server and storage platforms.

ASM is shipped as part of the database server software (Enterprise and Standard editions) and does not cost extra money to run.

History

ASM was first released with Oracle 10g Release 1.

Features

  • ASM takes control of disk devices (no disk partitioning needed)
  • More space can be transparently added
  • I/Os are spread over all the available disks (striping)
  • ASM can maintain redundant copies of the data (mirror)
  • Storage can be migrated between disks
  • Same disk (or set of disks) can be shared amongst many DBs

Installing ASM

It is recommended to install ASM in a separate Oracle home so that upgrades can be done independently from the databases.

Use the DBCA utility to create the ASM instance.

Starting and stopping

Start the ASM instance:

$ export ORACLE_SID=+ASM
$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Sep 3 00:28:09 2006
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup
ASM instance started
Total System Global Area   83886080 bytes
Fixed Size                  1217836 bytes
Variable Size              57502420 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted

Stop the ASM instance:

$ export ORACLE_SID=+ASM
$ sqlplus "/ as sysdba"
shutdown immediate

Adding diskgroups

SQL> create diskgroup orag2 external redundancy disk 'ORCL:VOL5';
Diskgroup created.
SQL> select group_number,disk_number,mode_status,name from v$asm_disk;
GROUP_NUMBER DISK_NUMBER MODE_STATUS    NAME
------------ ----------- -------------- -------------------------------------
           0           5 ONLINE
           1           0 ONLINE         VOL1
           1           1 ONLINE         VOL2
           1           2 ONLINE         VOL3
           1           3 ONLINE         VOL4
           2           0 ONLINE         VOL5
6 rows selected.

Recreating a diskgroup

All ASM metadata must be cleared before attempting to re-create a diskgroup. Example Command:

dd if=/dev/zero of=/dev/rdsk/c1t4d0s4 bs=8192 count=12800

When done, restart ASM and create the diskgroup from scratch.

Rebalancing

The rebalancing speed is controlled by the ASM_POWER_LIMIT initialization parameter. Setting it to 0 will disable disk rebalancing.

To force rebalancing of a diskgroup:

ALTER DISKGROUP data REBALANCE POWER 11 WAIT;

Converting to ASM

One can use Rman to convert a datafile, tablespace or entire database from/to ASM. Here are the steps required to migrate an entire database to ASM:

Convert a database to ASM

Ensure the database is using an SPFILE and not a PFILE (it's about time after all!). Set parameters on the target database. For example, if we set both DB_CREATE_FILE_DEST and DB_RECOVERY_FILE_DEST we should get mirrored controlfiles and duplexed log files by default:

SQL> alter system set DB_CREATE_FILE_DEST = '+DATA';
SQL> alter system set DB_RECOVERY_FILE_DEST_SIZE = 17G;
SQL> alter system set DB_RECOVERY_FILE_DEST = '+RECOVER';
SQL> alter system set CONTROL_FILES = '+DATA';

Start the database in NOMOUNT mode and restore the controlfile into the new location from the old location:

RMAN> connect target /
RMAN> STARTUP NOMOUNT
RMAN> RESTORE CONTROLFILE FROM 'old_control_file_name';

Mount the database and copy the database into the ASM disk group:

RMAN> ALTER DATABASE MOUNT;
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 8;
RMAN> BACKUP AS COPY DATABASE FORMAT '+DATA';

Switch all datafiles to the new ASM location and open the database:

RMAN> SWITCH DATABASE TO COPY;
RMAN> ALTER DATABASE OPEN;

Add new tempfiles and drop the old tempfiles:

SQL> alter tablespace temp add tempfile;
SQL> alter database tempfile '...' DROP;
SQL> select * from dba_temp_files; 

Optionally, move SPFILE into ASM:

SQL> CREATE SPFILE '+DATA' FROM PFILE;

Move redo log files into ASM - for each group:

SQL> ALTER DATABASE DROP LOGFILE GROUP 1;
SQL> ALTER DATABASE ADD LOGFILE GROUP 1 SIZE 100M;

If a logfile is active and cannot be dropped, issue an ALTER DATABASE SWITCH LOGFILE; command and try again.

Convert a tablespace to ASM

Ensure the database in in archive log mode, and from rman:

connect target;
sql "alter tablespace TSNAME offline";
backup as copy tablespace TSNAME format '+DATA';
switch tablespace TSNAME to copy;
sql "alter tablespace TSNAME online";
exit;

Convert a datafile to ASM

Ensure the database in in archive log mode, and from rman:

connect target;
sql "alter database datafile '...' offline";
backup as copy datafile '...' format '+DATA';
switch datafile '..' to copy;
sql "alter database datafile '...' online";
exit;

Monitoring

Some of the views that can be used to monitor ASM configuration and activity:

  • V$ASM_DISK - ASM disks
  • V$ASM_DISK_STAT - cached view of V$ASM_DISK for faster access (used by Enterprise Manager)
  • V$ASM_DISKGROUP - ASM diskgroups
  • V$ASM_DISKGROUP_STAT - cached view of V$ASM_DISKGROUP for faster access (used by Enterprise Manager)
  • V$ASM_OPERATION - status of ongoing disk operations (like rebalancing)

Also see

  • ASM FAQ - frequently asked questions about ASM
  • asmcmd - command line utility for managing ASM
  • DBMS_FILE_TRANSFER - PL/SQL package for transferring files between ASM and non-ASM storage

External links