Anda di halaman 1dari 12

Automatic Storage Management (ASM) in Oracle Database 10g

Automatic Storage Management (ASM) is a feature that has be introduced in Oracle 10g
to simplify the storage of Oracle datafiles, controlfiles and logfiles.

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 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.

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.
Enables management of database objects without specifying mount points and filenames.
Supports large files.

Initialization Parameters and ASM Instance Creation


The initialization parameters that are of specific interest for an ASM instance are:

INSTANCE_TYPE: Set to ASM or RDBMS depending on the instance type. The


default is RDBMS.

DB_UNIQUE_NAME: Specifies a globally unique name for the database. This defaults
to +ASM but must be altered if you intend to run multiple ASM instances.

ASM_POWER_LIMIT: The maximum power for a rebalancing operation on an ASM


instance. The valid values range from 1 to 11, with 1 being the default. The higher the
limit the more resources are allocated resulting in faster rebalancing operations
ASM_DISKGROUPS: The list of disk groups that should be mounted by an ASM
instance during instance startup, or by the ALTER DISKGROUP ALL MOUNT
statement. ASM configuration changes are automatically reflected in this parameter.

ASM_DISKSTRING: Specifies a value that can be used to limit the disks considered
for discovery. Altering the default value may improve the speed of disk group mount
time and the speed of adding a disk to a disk group. Changing the parameter to a value
which prevents the discovery of already mounted disks results in an error. The default
value is NULL allowing all suitable disks to be considered.

Incorrect usage of parameters in ASM or RDBMS instances result in ORA-15021 errors.

To create an ASM instance first create a file called init+ASM.ora in the /tmp directory
containing the following information.

INSTANCE_TYPE=ASM

Next, using SQL*Plus connect to the ide instance.


export ORACLE_SID=+ASM
sqlplus / as sysdba Create an spfile using the contents of the init+ASM.ora file.

SQL> CREATE SPFILE FROM PFILE='/tmp/init+ASM.ora';


File created.
Finally, start the instance with the NOMOUNT option.

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

OR

SQL> startup nomount


ORA-29701: unable to connect to Cluster Manager
(If CRS is not started on the Database Server)

The ASM instance is now ready to use for creating and mounting disk groups. To
shutdown the ASM instance issue the following command.

SQL> shutdown
ASM instance shutdown
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.

The options for the STARTUP command are:


FORCE - Performs a SHUTDOWN ABORT before restarting the ASM instance.
MOUNT - Starts the ASM instance and mounts the disk groups specified by the
ASM_DISKGROUPS parameter.
NOMOUNT - Starts the ASM instance without mounting any disk groups.
OPEN - This is not a valid option for an ASM instance.

The options for the SHUTDOWN command are:


NORMAL - The ASM instance waits for all connected ASM instances and SQL sessions
to exit then shuts down.
IMMEDIATE - The ASM instance waits for any SQL transactions to complete then
shuts down. It doesn't wait for sessions to exit.
TRANSACTIONAL - Same as IMMEDIATE.
ABORT - The ASM instance shuts down instantly.

Administering ASM Disk Groups


Disks
Disk groups are created using the CREATE DISKGROUP statement. This statement
allows you to specify the level of redundancy:

NORMAL REDUNDANCY - Two-way mirroring, requiring two failure groups.


HIGH REDUNDANCY - Three-way mirroring, requiring three failure groups.
EXTERNAL REDUNDANCY - No mirroring for disks that are already protected using
hardware mirroring or RAID.
In addition failure groups and preferred names for disks can be defined. If the NAME
clause is omitted the disks are given a system generated name like "disk_group_1_0001".
The FORCE option can be used to move a disk from another disk group into this one.

CREATE DISKGROUP disk_group_1 NORMAL REDUNDANCY


FAILGROUP failure_group_1 DISK
'/devices/diska1' NAME diska1,
'/devices/diska2' NAME diska2,
FAILGROUP failure_group_2 DISK
'/devices/diskb1' NAME diskb1,
'/devices/diskb2' NAME diskb2;

Disk groups can be deleted using the DROP DISKGROUP statement.

DROP DISKGROUP disk_group_1 INCLUDING CONTENTS;

Disks can be added or removed from disk groups using the ALTER DISKGROUP
statement. 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.

-- Add disks.
ALTER DISKGROUP disk_group_1 ADD DISK
'/devices/disk*3',
'/devices/disk*4';

-- Drop a disk.
ALTER DISKGROUP disk_group_1 DROP DISK diska2;

Disks can be resized using the RESIZE clause of the ALTER DISKGROUP statement.
The statement can be used to resize individual disks, all disks in a failure group or all
disks in the disk group. If the SIZE clause is omitted the disks are resized to the size of
the disk returned by the OS.

-- Resize a specific disk.


ALTER DISKGROUP disk_group_1
RESIZE DISK diska1 SIZE 100G;

-- Resize all disks in a failure group.


ALTER DISKGROUP disk_group_1
RESIZE DISKS IN FAILGROUP failure_group_1 SIZE 100G;

-- Resize all disks in a disk group.


ALTER DISKGROUP disk_group_1
RESIZE ALL SIZE 100G;
The UNDROP DISKS clause of the ALTER DISKGROUP statement allows pending
disk drops to be undone. It will not revert drops that have completed, or disk drops
associated with the dropping of a disk group.

ALTER DISKGROUP disk_group_1 UNDROP DISKS;

Disk groups can be rebalanced manually using the REBALANCE clause of the ALTER
DISKGROUP statement. If the POWER clause is omitted the ASM_POWER_LIMIT
parameter value is used. Rebalancing is only needed when the speed of the automatic
rebalancing is not appropriate.

ALTER DISKGROUP disk_group_1 REBALANCE POWER 5;

Disk groups are mounted at ASM instance startup and unmounted at ASM instance
shutdown. Manual mounting and dismounting can be accomplished using the ALTER
DISKGROUP statement as seen below.

ALTER DISKGROUP ALL DISMOUNT;


ALTER DISKGROUP ALL MOUNT;
ALTER DISKGROUP disk_group_1 DISMOUNT;
ALTER DISKGROUP disk_group_1 MOUNT;

Directories – not used much


A directory hierarchy can be defined using the ALTER DISKGROUP statement to
support ASM file aliasing. The following examples show how ASM directories can be
created, modified and deleted.

-- Create a directory.
ALTER DISKGROUP disk_group_1 ADD DIRECTORY '+disk_group_1/my_dir';

-- Rename a directory.
ALTER DISKGROUP disk_group_1 RENAME DIRECTORY '+disk_group_1/my_dir'
TO '+disk_group_1/my_dir_2';

-- Delete a directory and all its contents.


ALTER DISKGROUP disk_group_1 DROP DIRECTORY '+disk_group_1/my_dir_2'
FORCE;

Aliases – not used much


Aliases allow you to reference ASM files using user-friendly names, rather than the fully
qualified ASM filenames.
-- Create an alias using the fully qualified filename.
ALTER DISKGROUP disk_group_1 ADD ALIAS '+disk_group_1/my_dir/my_file.dbf'
FOR '+disk_group_1/mydb/datafile/my_ts.342.3';
-- Create an alias using the numeric form filename.
ALTER DISKGROUP disk_group_1 ADD ALIAS '+disk_group_1/my_dir/my_file.dbf'
FOR '+disk_group_1.342.3';

-- Rename an alias.
ALTER DISKGROUP disk_group_1 RENAME ALIAS
'+disk_group_1/my_dir/my_file.dbf'
TO '+disk_group_1/my_dir/my_file2.dbf';

-- Delete an alias.
ALTER DISKGROUP disk_group_1 DELETE ALIAS
'+disk_group_1/my_dir/my_file.dbf';
Attempting to drop a system alias results in an error.

Files
Files are not deleted automatically if they are created using aliases, as they are not Oracle
Managed Files (OMF), or if a recovery is done to a point-in-time before the file was
created. For these circumstances it is necessary to manually delete the files, as shown
below.

-- Drop file using an alias.


ALTER DISKGROUP disk_group_1 DROP FILE '+disk_group_1/my_dir/my_file.dbf';

-- Drop file using a numeric form filename.


ALTER DISKGROUP disk_group_1 DROP FILE '+disk_group_1.342.3';

-- Drop file using a fully qualified filename.


ALTER DISKGROUP disk_group_1 DROP FILE
'+disk_group_1/mydb/datafile/my_ts.342.3';

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.

-- Check metadata for a specific file.


ALTER DISKGROUP disk_group_1 CHECK FILE
'+disk_group_1/my_dir/my_file.dbf'

-- Check metadata for a specific failure group in the disk group.


ALTER DISKGROUP disk_group_1 CHECK FAILGROUP failure_group_1;

-- Check metadata for a specific disk in the disk group.


ALTER DISKGROUP disk_group_1 CHECK DISK diska1;
-- Check metadata for all disks in the disk group. ALTER DISKGROUP disk_group_1
CHECK ALL;

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, or a
dependant database instance.

View ASM Instance DB Instance


V$ASM_ALIAS Displays a row for each alias present in every disk group mounted by
the ASM instance. Returns no rows
V$ASM_CLIENT Displays a row for each database instance using a disk group managed
by the ASM instance. Displays a row for the ASM instance if the database has open
ASM files.
V$ASM_DISK Displays a row for each disk discovered by the ASM instance, including
disks which are not part of any disk group. Displays a row for each disk in disk groups
in use by the database instance.
V$ASM_DISKGROUP Displays a row for each disk group discovered by the ASM
instance. Displays a row for each disk group mounted by the local ASM instance.
V$ASM_FILE Displays a row for each file for each disk group mounted by the ASM
instance. Displays no rows.
V$ASM_OPERATION Displays a row for each file for each long running operation
executing in the ASM instance. Displays no rows.

SQL and ASM


ASM filenames can be used in place of conventional filenames for most Oracle file types,
including controlfiles, datafiles, logfiles etc. For example, the following command creates
a new tablespace with a datafile in the disk_group_1 disk group.

CREATE TABLESPACE my_ts DATAFILE '+disk_group_1' SIZE 100M


AUTOEXTEND ON;

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.

SQL> ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;


Shutdown the database.

SQL> SHUTDOWN IMMEDIATE


Modify the parameter file of the target database as follows:
Set the DB_CREATE_FILE_DEST and DB_CREATE_ONLINE_LOG_DEST_n
parameters to the relevant ASM disk groups.
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. If
you are using a pfile the CONTROL_FILES parameter must be set to the appropriate
ASM files or aliases.

Start the database in nomount mode.

RMAN> STARTUP NOMOUNT


Restore the controlfile into the new location from the old location.

RMAN> RESTORE CONTROLFILE FROM 'old_control_file_name';


Mount the database.

RMAN> ALTER DATABASE MOUNT;


Copy the database into the ASM disk group.

RMAN> BACKUP AS COPY DATABASE FORMAT '+disk_group';


Switch all datafile to the new ASM location.

RMAN> SWITCH DATABASE TO COPY;


Open the database.

RMAN> ALTER DATABASE OPEN;


Create new redo logs in ASM and delete the old ones.

Enable change tracking if it was being used.

SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;

Form more information see:

Using Automatic Storage Management (http://download-


west.oracle.com/docs/cd/B14117_01/server.101/b10739/storeman.htm)
Migrating a Database into ASM
(http://download-
west.oracle.com/docs/cd/B14117_01/server.101/b10734/rcmasm.htm#1018745)

http://www.filibeto.org/sun/lib/nonsun/oracle/10.2.0.1.0/B19306_01/server.102/b14196/a
sm.htm#sthref769

http://download-
west.oracle.com/docs/cd/B19306_01/server.102/b14215/asm_util.htm#CBAGHJHI
CREATE TABLESPACE "POOL_DATA" DATAFILE
'+DGROUP1/oradata/snsst4/pool_data_1.dbf' SIZE 6291456000,
'+DGROUP1/oradata/snsst4/pool_data_2.dbf' SIZE 6291456000,
'+DGROUP1/oradata/snsst4/pool_data_3.dbf' SIZE 6291456000,
'+DGROUP1/oradata/snsst4/pool_data_4.dbf' SIZE 6291456000,
'+DGROUP1/oradata/snsst4/pool_data_5.dbf' SIZE 6291456000,
'+DGROUP1/oradata/snsst4/pool_data_6.dbf' SIZE 10485760000,
'+DGROUP1/oradata/snsst4/pool_data_7.dbf' SIZE 10485760000,
'+DGROUP1/oradata/snsst4/pool_data_8.dbf' SIZE 5242880000,
'+DGROUP1/oradata/snsst4/pool_data_9.dbf' SIZE 10485760000,
'+DGROUP1/oradata/snsst4/pool_data_10.dbf' SIZE 5242880000,
'+DGROUP1/oradata/snsst4/pool_data_11.dbf' SIZE 5242880000,
'+DGROUP1/oradata/snsst4/pool_data_12.dbf' SIZE 1572864000,
'+DGROUP1/oradata/snsst4/pool_data_13.dbf' SIZE 8589934592,
'+DGROUP1/oradata/snsst4/pool_data_14.dbf' SIZE 8589934592,
'+DGROUP1/oradata/snsst4/pool_data_15.dbf' SIZE 8589934592,
'+DGROUP1/oradata/snsst4/pool_data_16.dbf' SIZE 8589934592,
'+DGROUP1/oradata/snsst4/pool_data_17.dbf' SIZE 8589934592
LOGGING ONLINE PERMANENT BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 40960 SEGMENT SPACE
MANAGEMENT AUTO
ALTER DATABASE DATAFILE
'+DGROUP1/oradata/snsst4/pool_data_1.dbf' RESIZE 9437184000
ALTER DATABASE DATAFILE
'+DGROUP1/oradata/snsst4/pool_data_2.dbf' RESIZE 8388608000
ALTER DATABASE DATAFILE
'+DGROUP1/oradata/snsst4/pool_data_3.dbf' RESIZE 8388608000
ALTER DATABASE DATAFILE
'+DGROUP1/oradata/snsst4/pool_data_4.dbf' RESIZE 8388608000
ALTER DATABASE DATAFILE
'+DGROUP1/oradata/snsst4/pool_data_5.dbf' RESIZE 10485760000
ALTER DATABASE DATAFILE
'+DGROUP1/oradata/snsst4/pool_data_8.dbf' RESIZE 8388608000
ALTER DATABASE DATAFILE
'+DGROUP1/oradata/snsst4/pool_data_10.dbf' RESIZE 8388608000
ALTER DATABASE DATAFILE
'+DGROUP1/oradata/snsst4/pool_data_11.dbf' RESIZE 8388608000
ALTER DATABASE DATAFILE
'+DGROUP1/oradata/snsst4/pool_data_12.dbf' RESIZE 7864320000
hpx613!adba:~/showcommands_IDC [187]> showasmdisk SNSST4
hpx613!adba:~/showcommands_IDC [188]> showasmclients SNSST4

adba@linhb307:~> ps -ef | grep ASML307


oracle 27750 1 0 Feb07 ? 00:00:04 asm_pmon_+ASML307
oracle 27763 1 0 Feb07 ? 00:00:35 asm_diag_+ASML307
oracle 27765 1 0 Feb07 ? 00:00:00 asm_psp0_+ASML307
oracle 27767 1 0 Feb07 ? 00:01:15 asm_lmon_+ASML307
oracle 27769 1 0 Feb07 ? 00:01:28 asm_lmd0_+ASML307
oracle 27771 1 0 Feb07 ? 00:00:00 asm_lms0_+ASML307
oracle 27775 1 0 Feb07 ? 00:00:00 asm_mman_+ASML307
oracle 27777 1 0 Feb07 ? 00:00:00 asm_dbw0_+ASML307
oracle 27779 1 0 Feb07 ? 00:00:00 asm_lgwr_+ASML307
oracle 27781 1 0 Feb07 ? 00:00:00 asm_ckpt_+ASML307
oracle 27784 1 0 Feb07 ? 00:00:00 asm_smon_+ASML307
oracle 27786 1 0 Feb07 ? 00:00:00 asm_rbal_+ASML307
oracle 27788 1 0 Feb07 ? 00:00:00 asm_gmon_+ASML307
oracle 27796 1 0 Feb07 ? 00:00:09 asm_lck0_+ASML307
oracle 27836 1 0 Feb07 ? 00:00:07 /oravl01/oracle/10.2.0.3_RAC/bin/racgimon
daemon ora.linhb307.ASML307.asm
oracle 28111 1 0 Feb07 ? 00:00:00 oracle+ASML307
(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 28865 1 0 Feb07 ? 00:00:00 oracle+ASML307
(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
ASMCMD command utility:
ASMCMD is a command-line utility that you can use to easily view and
manipulate files and directories within Automatic Storage Management
(ASM) disk groups. It can list the contents of disk groups, perform
searches, create and remove directories and aliases, display space
utilization, and more.

ASMCMD Command Reference


This section describes each individual ASMCMD command in detail.
Table 20-1 provides a summary of all ASMCMD commands.

Table 20-1 Summary of ASM Commands

Comman
d Description
cd Changes the current directory to the specified directory.
du Displays the total disk space occupied by ASM files in the
specified ASM directory and all its subdirectories,
recursively.
exit Exits ASMCMD.
find Lists the paths of all occurrences of the specified name (with
wildcards) under the specified directory.
help Displays the syntax and description of ASMCMD commands.
ls Lists the contents of an ASM directory, the attributes of the
specified file, or the names and attributes of all disk groups.
lsct Lists information about current ASM clients.
lsdg Lists all disk groups and their attributes.
mkalias Creates an alias for a system-generated filename.
mkdir Creates ASM directories.
pwd Displays the path of the current ASM directory.
rm Deletes the specified ASM files or directories.
rmalias Deletes the specified alias, retaining the file that the alias
points to.

find [-t type] dir name


You use the -t flag to find all the files of a particular type (specified as
type). For example, you can search for control files by specifying type
as CONTROLFILE. Valid values for type are the following:

CONTROLFILE
DATAFILE
ONLINELOG
ARCHIVELOG
TEMPFILE
BACKUPSET
DATAFILE
PARAMETERFILE
DATAGUARDCONFIG
FLASHBACK
CHANGETRACKING
DUMPSET
AUTOBACKUP
XTRANSPORT

Anda mungkin juga menyukai