Sunteți pe pagina 1din 75

Automatic Storage Management (ASM)

Oracle Database 10g Release 1, introduced Automatic Storage Management(ASM), a new


framework for managing Oracle database files,
to bypass the OS overhead,
to simplify Oracle data management,
to enforce the SAME (Stripe And Mirror Everywhere, RAID10), and
to provide a platform for file sharing in RAC and Grid computing.
Automatic Storage Management (ASM) is a new type of file system. ASM provided a
foundation for highly efficient storage management with kernelized asynchronous I/O, direct
I/O, redundancy, striping, and an easy way to manage storage. ASM is recommended file
system for RAC and single instance ASM for storing database files. This provides direct I/O to
the file and performance is comparable with that provided by raw devices. Oracle creates a
separate instance for this purpose.
ASM includes volume management functionality similar to that of a generic logical volume
manager. Automatic Storage Management (ASM) will take physical disk partitions and
manages their contents in a way that efficiently supports the files needed to create an Oracle
database.
Automatic Storage Management (ASM) simplifies administration of Oracle related files by
allowing the administrator to reference diskgroups rather than hundreds of individual disks
and files, which are managed by ASM. The ASM functionality is an extension of the Oracle
Managed Files (OMF) functionality that also includes striping and mirroring to provide
balanced and secure storage. The ASM functionality can be used in combination with existing
raw and cooked file systems, along with OMF and manually managed files.
Before ASM, there were only two choices: file system storage and raw disk storage. File
system storage is flexible, allowing the DBA to see the individual files and to move them, copy
them, and back them up easily, but it also incurs overhead. Raw disk storage has no file
directories on it, and Oracle manages its blocks directly, which makes it more efficient. Raw
disk storage is such a manageability nightmare that few DBAs use it.
ASM is the middle ground. It's raw disk storage managed by Oracle, and it is very efficient.
Oracle uses a scaled down Oracle instance to simulate a file structure on it where none
exists, by recording all the metadata. The metadata enables the Recovery Manager (RMAN)
to backup and restore Oracle files easily within it.
Setting up storage takes a significant amount of time during most database installations.
Zeroing on a specific disk configuration from among the multiple possibilities requires careful
planning and analysis, and most important, intimate knowledge of storage technology, volume
managers, and file systems. The design tasks at this stage can be loosely described as
follows:
1 Confirm that storage is recognized at the OS level and determine the level of
redundancy protection that might already be provided (hardware RAID, called external
redundancy in ASM).
2 Assemble and build logical volume groups and determine if striping or mirroring is
also necessary.
3 Build a file system on the logical volumes created by the logical volume manager.
4 Set the ownership and privileges so that the Oracle process can open, read, and
write to the devices.
5 Create a database on that file system while taking care to create special files such as
redo logs, temporary tablespaces, and undo tablespaces in non-RAID locations, if possible.

All above tasks, striping, mirroring, logical file system building, are done to serve Oracle
database. Oracle database offers some techniques of its own to simplify or enhance the
process. Lets DBAs execute many of the above tasks completely within the Oracle
framework. Using ASM you can transform a bunch of disks to a highly scalable and
performance file system/volume manager using nothing more than what comes with Oracle
database software at no extra cost and you don't need to be an expert in disk, volume
managers, or file system management.
You can store the following file types in ASM diskgroups:
o Datafiles
o Control files
o Online redo logs
o Archive logs
o Flashback logs
o SPFILEs
o RMAN backups
o Temporary datafiles
o Datafile copies
o Disaster recovery configurations
o Change tracking bitmaps
o Datapump dumpsets
In summary, ASM provides the following functionality/features:
 Manages groups of disks, called diskgroups. Must be careful while choosing disks for
a diskgroup.
 Manages disk redundancy within a diskgroup.
 Provides near-optimal I/O balancing without any manual tuning.
 Enables management of database objects without specifying mount points and
filenames.
 Supports large files.
 Replacement for CFS (Cluster File System).
 Also useful for Non-RAC databases.
 A new instance type - ASM is introduced in 10g.
 ASM instance has no data dictionary.
 A Disk can be a partial, full or a LUN from the RG.
 I/O is spread evenly across all disks of a diskgroup.
 Disks can be dynamically added to any diskgroup.
 When combined with OMF increases manageability.
 ASM cannot maintain empty directories “delete input” has issues, create a dummy
directory.
 Use of ASM diskgroup is very simple create tablespace.
 Enterprise Manager can also be used for administering diskgroups
 Only RMAN can be used with ASM.
o Introduces three additional Oracle background processes – RBAL, ARBx and
ASMB.ASMB - This ASMB process is used to provide information to and from
cluster synchronization services used by ASM to manage the disk resources. It's
also used to update statistics and provide a heart beat mechanism.
o Re-Balance, RBAL - RBAL is the ASM related process that performs
rebalancing of disk resources controlled by ASM.
o Actual Rebalance, ARBx - ARBx is configured by ASM_POWER_LIMIT.
 ASM instance has it own set of v$views and init.ora parameters.
The advantages of ASM are
 Disk Addition - Adding a disk is very easy. No downtime is required and file extents
are redistributed automatically.
 I/O Distribution - I/O is spread over all the available disks automatically, without
manual intervention, reducing chances of a hot spot.
 Stripe Width - Striping can be fine grained as in redolog files (128K for faster transfer
rate) and coarse for datafiles (1MB for transfer of a large number of blocks at one time).
 Mirroring - Software mirroring can be set up easily, if hardware mirroring is not
available.
 Buffering - The ASM file system is not buffered, making it direct I/O capable by
design.
 Kernelized Asynchronous I/O - There is no special setup necessary to enable
kernelized asynchronous I/O, without using raw or third-party file systems such as Veritas
Quick I/O.

ASM Background Processes

ASMB
This ASMB process is used to provide information to and from cluster synchronization services
used by ASM to manage the disk resources. It's also used to update statistics and provide a heart
beat mechanism.
Re-Balance RBAL
RBAL is the ASM related process that performs rebalancing of disk resources controlled by ASM.
Actual Rebalance ARBx
ARBx is configured by ASM_POWER_LIMIT.
Performs the actual extent movement between disks in the disk groups
KATE - I/O to an ASM when disk offline
GMON – Global Monitor: It is responsible for coordinating the disk group activities whenever a
disk group becomes offline or drop.
KATE – Konductor for ASM Temporary Errand: It is responsible for making online for disk
groups.
PZ9X: It is responsible for gathering the dynamic views information globally across all the
instances of database.
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. This value is also used as the
default when the POWER clause is omitted from a rebalance operation.
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.

ASM_PREFERRED_READ_FAILURE_GROUPS - This initialization parameter value (default


is NULL) is a comma-delimited list of strings that specifies the failure groups that should be
preferentially read by the given instance. This parameter is generally used only for clustered
ASM instances and its value can be different on different nodes. This is from Oracle 11g.

ASM Instance
The ASM functionality is controlled by an ASM instance. This is a special instance, not a
database where users can create objects, just the memory structures and as such is very
small and lightweight.
With ASM, you don't have to create anything on the OS side; the feature will group a set of
physical disks to a logical entity known as a diskgroup. A diskgroup is analogous to a striped
and optionally mirrored, file system, with important differences: it's not a general-purpose file
system for storing user files and it's not buffered. Diskgroup offers the advantage of direct
access to this space as a raw device, yet provides the convenience and flexibility of a file
system. All the metadata about the disks are stored in the diskgroups themselves, making
them as self-describing as possible.
This special ASM instance is similar to other file systems in that it must be running for ASM to
work and can't be modified by the user. One ASM instance can serve number of Oracle
databases. ASM instance and database instances have to be present on same server.
Otherwise it will not work.
Logical volume managers typically use a function, such as hashing, to map the logical
address of the blocks to the physical blocks. This computation uses CPU cycles. When a new
disk is added, this typical striping function requires each bit of the entire data set to be
relocated. In contrast, ASM uses this special instance to address the mapping of the file
extents to the physical disk blocks. This design, in addition to being fast in locating the file
extents, helps while adding or removing disks because the locations of file extents need not
be coordinated.
You should start the instance up when the server is booted i.e. it should be started before the
database instances, and it should be one of the last things stopped when the server is
shutdown. From 11.2.0, we can use ASMCMD to start and stop the ASM instances.
Startup of ASM Instances
ASM instances are started and stopped in a similar way to normal database instances.
The options for the STARTUP command are:
 NOMOUNT - Starts the ASM instance without mounting any diskgroups.
 MOUNT - Starts the ASM instance and mounts the diskgroups specified by the
ASM_DISKGROUPS parameter.
 OPEN - ASM instance does not have open stage.
 FORCE - Performs a SHUTDOWN ABORT before restarting the ASM instance.
ASMCMD equivalent for this command is startup (11g R2 command).

Shutdown of ASM Instances


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.
ASMCMD equivalent for this command is shutdown (11g R2 command).
ASM Diskgroups
The main components of ASM are diskgroups, 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 known 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.
Diskgroup is a terminology used for logical structure which holds the database files. Each
diskgroup consists of disks/raw devices where the files are actually stored. Any ASM file (and
it's redundant copy) is completely contained within a single diskgroup. A diskgroup might
contain files belonging to several databases and a single database can use files from multiple
diskgroups.
In the initial release of Oracle 10g, ASM diskgroups were a black box. We had to manipulate
ASM diskgroups with SQL statements while logged in to the special ASM instance that
manages the diskgroups.
In Oracle 10g Release 2, Oracle introduced a new command line tool called ASMCMD that lets
you look inside ASM volumes (which are called diskgroups). Now you can do many tasks
from the command line.
While creating a diskgroup, we have to specify an ASM diskgroup type based on one of the
following three redundancy levels:
 Normal redundancy - for 2-way mirroring, requiring two failure groups, when ASM
allocates an extent for a normal redundancy file, ASM allocates a primary copy and a
secondary copy. ASM chooses the disk on which to store the secondary copy in a
different failure group other than the primary copy.
 High redundancy - for 3-way mirroring, requiring three failure groups, in this case the
extent is mirrored across 3 disks.
 External redundancy - to not use ASM mirroring. This is used if you are using
hardware mirroring or third party redundancy mechanism like RAID, Storage arrays.

ASM is supposed to stripe the data and also mirror the data (if using Normal, High
redundancy). So this can be used as an alternative for RAID (Redundant Array of Inexpensive
Disks) 0+1 solutions.
No, we cannot modify the redundancy for diskgroup once it has been created. To alter it we
will be required to create a new diskgroup and move the files to it. This can also be done by
restoring full backup on the new diskgroup.
Failure groups are defined within a diskgroup to support the required level of redundancy,
using normal/high redundancy. They contain the mirrored ASM extents and must be
containing different disks and preferably on separate disk controller.
In addition failure groups and preferred names for disks can be defined in CREATE
DISKGROUP statement. 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 diskgroup into this one.
Creating diskgroups
SQL> CREATE DISKGROUP dg_asm_data 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;
For two-way mirroring we would expect a diskgroup to contain two failure groups, so
individual files are written to two locations.

SQL> CREATE DISKGROUP dg_asm_fra HIGH 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,
FAILGROUP failure_group_3 DISK '/devices/diskc1' NAME diskc1, '/devices/diskc2' NAME
diskc2;
For three-way mirroring we would expect a diskgroup to contain three failure groups, so
individual files are written to three locations.
SQL> CREATE DISKGROUP dg_grp1 EXTERNAL REDUNDANCY
DISK '/dev/d1','/dev/d2','/dev/d3','/dev/d4' ... ...;
In the above command, database will create a diskgroup named dg_grp1 with the physical
disks named /dev/d1, /dev/d2, and so on. Instead of giving disks separately, we can also
specify disk names in wildcards in the DISK clause as DISK '/dev/d*'.
We have also specified a clause EXTERNAL REDUNDANCY, which indicates that the failure
of a disk will bring down the diskgroup. This is usually the case when the redundancy is
provided by the hardware, such as mirroring. If there is no hardware based redundancy, the
ASM can be set up to create a special set of disks called failgroup in the diskgroup to provide
that redundancy.

SQL> CREATE DISKGROUP dskgrp1 NORMAL REDUNDANCY


FAILGROUP failgrp1 DISK '/dev/d1','/dev/d2',
FAILGROUP failgrp2 DISK '/dev/d3','/dev/d4';

Although it may appear as such, d3 and d4 are not mirrors of d1 and d2. Rather, ASM uses all
the disks to create a fault-tolerant system. For example, a file on the diskgroup might be
created in d1 with a copy maintained on d4. A second file may be created on d3 with copy on
d2, and so on. That is, primary copy will be on one failure group and secondary copy will be
another (third copy will be another, for high redundancy).

Failure of a specific disk allows a copy on another disk so that the operation can continue. For
example, you could lose the controller for both disks d1 and d2 and ASM would mirror copies
of the extents across the failure group to maintain data integrity.

SQL> CREATE DISKGROUP dg1 DISK '/dev/raw/*' ATTRIBUTE 'compatible.rdbms' = '11.1',


'compatible.asm' = '11.1'; (11g R1 command)
SQL> CREATE DISKGROUP dg2 EXTERNAL REDUNDANCY DISK '/dev/sde1' ATRRIBUTE
'au_size' = '32M'; (11g R1 command)

SQL> CREATE DISKGROUP archdg NORMAL REDUNDANCY


FAILGROUP fg1 DISK '/devices/diska1','/devices/diska2','/devices/diska3','/devices/diska4'
FAILGROUP fg2 DISK '/devices/diskb1','/devices/diskb2','/devices/diskb3','/devices/diskb4'
ATTRIBUTE
'au_size'='4M','compatible.asm'='11.2','compatible.rdbms'='11.2','compatible.advm'='11.2';
(11g R2 command)

ASMCMD equivalent for this command is mkdg (11g R2 command).


Listing diskgroups
To find out all the diskgroups:
SQL> SELECT * FROM V$ASM_DISKGROUP;
ASMCMD equivalent for this command is lsdg.

Dropping diskgroups
Diskgroups can be deleted using the DROP DISKGROUP statement.
SQL> DROP DISKGROUP disk_group_1 INCLUDING CONTENTS;
SQL> DROP DISKGROUP disk_group_1 FORCE; (11g R1 command)
SQL> DROP DISKGROUP disk_group_1 FORCE INCLUDING CONTENTS; ( 11gR1
command)
ASMCMD equivalent for this command is dropdg (11g R2 command).

Altering diskgroups
Disks can be added or removed from diskgroups 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 diskgroup.

Adding disks
We may have to add additional disks into the diskgroup to accommodate growing demand.
SQL> ALTER DISKGROUP dskgrp1 ADD DISK '/dev/d5';
SQL> ALTER DISKGROUP dg1 ADD DISK '/devices/disk*3', '/devices/disk*4';
ASMCMD equivalent for this command is chdg (11g R2 command).

Listing disks
The following command shows all the disks managed by the ASM instance for all the client
databases.
SQL> SELECT * FROM V$ASM_DISK;

ASMCMD equivalent for this command is lsdsk (11g R1 command).

Listing client databases


The following command shows all the database instances connected to the ASM instance.
SQL> SELECT * FROM V$ASM_CLIENT;

ASMCMD equivalent for this command is lsct.


Dropping disks
We can remove a disk from diskgroup.
SQL> ALTER DISKGROUP dg4 DROP DISK diska4;

ASMCMD equivalent for this command is chdg (11g R2 command).


Resizing disks
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
diskgroup. If the SIZE clause is omitted the disks are resized to the size of the disk returned
by the OS.
SQL> ALTER DISKGROUP dg_data_1 RESIZE DISK diska1 SIZE 150G;
Resizing all disks in a failure group
SQL> ALTER DISKGROUP dg_data_1 RESIZE DISKS IN FAILGROUP fg_1 SIZE 50G;
Resizing all disks in a diskgroup
SQL> ALTER DISKGROUP dg_data_1 RESIZE ALL SIZE 100G;
Undropping disks
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 diskgroup.
SQL> ALTER DISKGROUP disk_group_1 UNDROP DISKS;
Online disks
SQL> ALTER DISKGROUP data ONLINE DISK 'disk_0000', 'disk_0001';
SQL> ALTER DISKGROUP data ONLINE DISKS IN FAILGROUP 'fg_99';
SQL> ALTER DISKGROUP data ONLINE ALL;

ASMCMD equivalent for this command is online (11gR2 command).

Offline disks
SQL> ALTER DISKGROUP data OFFLINE DISK 'disk_0000', 'disk_0001';
SQL> ALTER DISKGROUP data OFFLINE DISKS IN FAILGROUP 'fg_99';
SQL> ALTER DISKGROUP data OFFLINE DISK d1_0001 DROP AFTER 30m;
ASMCMD equivalent for this command is offline (11gR2 command).

Mounting diskgroups
Diskgroups 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 below.
SQL> ALTER DISKGROUP ALL MOUNT;
SQL> ALTER DISKGROUP dg_data2 MOUNT;
SQL> ALTER DISKGROUP dg_data2 MOUNT RESTRICTED; (11gR1 command)

ASMCMD equivalent for this command is mount (11gR2 command).

Dismounting diskgroups

SQL> ALTER DISKGROUP ALL DISMOUNT;

SQL> ALTER DISKGROUP dg_fra DISMOUNT;


ASMCMD equivalent for this command is umount (11gR2 command).

Changing attributes
SQL> ALTER DISKGROUP data3 SET ATTRIBUTE 'compatible.rdbms' = '11.1'; ( 11gR1
command)
SQL> ALTER DISKGROUP data3 SET ATTRIBUTE 'compatible.asm' = '11.2';
(11gR1 command)
SQL> ALTER DISKGROUP data3 SET ATTRIBUTE 'disk_repair_time' = '4.5h'; ( 11gR1
command)
ASMCMD equivalent for this command is setattr (11gR2 command).

Listing attributes
SQL> SELECT * FROM V$ASM_ATTRIBUTE;

ASMCMD equivalent for this command is lsattr (11gR2 command).


Rebalancing
Diskgroups 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.
SQL> ALTER DISKGROUP disk_group_1 REBALANCE POWER 6;

ASMCMD equivalent for this command is rebal (11gR2 command).

IO statistics of a diskgroup
SQL> SELECT * FROM V$ASM_DISK_IOSTAT;

ASMCMD equivalent for this command is iostat (11gR2 command).


Until 11.1.0, all the above commands can not be performed with ASMCMD. From 11.2.0,
we can.
Directories
As in other file systems, an ASM directory is a container for files, and an ASM directory can
be part of a tree structure of other directories. The fully qualified filename represents a
hierarchy of directories in which the plus sign (+) represent the root directory. In each
diskgroup, ASM automatically creates a directory hierarchy that corresponds to the structure
of the fully qualified filenames in the diskgroup. The directories in this hierarchy are known as
system-generated directories.
An absolute path refers to the full path of a file or directory. An absolute path begins with a
plus sign (+) followed by a diskgroup name, followed by subsequent directories in the
directory tree. The absolute path includes directories until the file or directory is reached. A
fully qualified filename is an example of an absolute path to a file. A relative path includes only
the part of the filename or directory name that is not part of the current directory. That is, the
path to the file or directory is relative to the current directory.
A directory hierarchy can be defined using the ALTER DISKGROUP statement to support
ASM file aliasing.
Creating a directory
SQL> ALTER DISKGROUP dg_1 ADD DIRECTORY '+dg_1/my_dir';
ASMCMD equivalent for this command is mkdir.
Renaming a directory
SQL> ALTER DISKGROUP dg_1 RENAME DIRECTORY '+dg_1/my_dir' TO
'+dg_1/my_dir_2';
Deleting a directory
SQL> ALTER DISKGROUP dg_1 DROP DIRECTORY '+dg_1/my_dir_2' FORCE;
ASMCMD equivalent for this command is rm.
Files
There are several ways to reference ASM files. Some forms are used during creation and
some for referencing ASM files. Every file created in ASM gets a system-generated filename,
known as fully qualified filename, this is same as complete path name in a local file system.
The forms of the ASM filenames are:
Filename Type Format
Fully Qualified ASM Filename +dgroup/dbname/file_type/ file_type_tag.file.incarnation
Numeric ASM Filename +dgroup.file.incarnation
Alias ASM Filenames +dgroup/directory/filename
Alias ASM Filename with Template +dgroup(template)/alias
Incomplete ASM Filename +dgroup
Incomplete ASM Filename with Template +dgroup(template)
ASM generates filenames according to the following scheme:
+diskGroupName/databaseName/fileType/fileTypeTag.fileNumber.incarnation
e.g: +dgroup2/crm/CONTROLFILE/Current.256.541956473
+dg_fra/hrms/DATAFILE/users.309.621906475
ASM does not place system-generated files into user-created directories; it places them only
in system-generated directories. We can add aliases or other directories to a user-created
directory.
Dropping 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.
Dropping file using an alias
SQL> ALTER DISKGROUP dg_2 DROP FILE '+dg_2/my_dir/my_file.dbf';
Dropping file using a numeric form filename
SQL> ALTER DISKGROUP dg_2 DROP FILE '+dg_2.321.123456789';
Dropping file using a fully qualified filename
SQL> ALTER DISKGROUP dg_2 DROP FILE '+dg_2/mydb/datafile/my_ts.292.265390671';
ASMCMD equivalent for this command is rm.

Aliases
Aliases allow you to reference ASM files using user-friendly names, rather than the fully
qualified ASM filenames.
Creating an alias
Creating an alias, using the fully qualified filename
SQL> ALTER DISKGROUP dg_3 ADD ALIAS '+dg_3/my_dir/users.dbf' FOR
'+dg_3/mydb/datafile/users.392.333222555';
Creating an alias, using the numeric form filename
SQL> ALTER DISKGROUP dg_3 ADD ALIAS '+dg_3/my_dir/my_file.dbf' FOR
'+dg_3.317.111222333';
ASMCMD equivalent for this command is mkalias.
Renaming an alias
SQL> ALTER DISKGROUP dg_3 RENAME ALIAS '+dg_3/my_dir/my_file.dbf' TO
'+dg_3/my_dir/my_file2.dbf';
Deleting an alias
SQL> ALTER DISKGROUP dg_3 DELETE ALIAS '+dg_3/my_dir/my_file.dbf';
ASMCMD equivalent for this command is rmalias.
Attempting to drop a system alias results in an error.
Templates
Templates are named groups of attributes that can be applied to the files within a diskgroup.
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.
Available attributes are:
 UNPROTECTED - No mirroring or striping regardless of the redundancy setting.
 MIRROR - Two-way mirroring for normal redundancy and three-way mirroring for high
redundancy.
 COARSE - Specifies lower granularity for striping.
 FINE - Specifies higher granularity for striping.
MIRROR, COARSE, FINE attributes are cannot be set for external redundancy.
Creating a template
SQL> ALTER DISKGROUP dg_4 ADD TEMPLATE mf_template ATTRIBUTES (MIRROR
FINE);

ASMCMD equivalent for this command is mktmpl (11gR2 command).


Modifying a template
SQL> ALTER DISKGROUP dg_4 ALTER TEMPLATE c_template ATTRIBUTES (COARSE);

ASMCMD equivalent for this command is chtmpl (11gR2 command).

Listing templates
SQL> SELECT * FROM V$ASM_TEMPLATE;
ASMCMD equivalent for this command is lstmpl (11gR2 command).

Dropping a template
SQL> ALTER DISKGROUP dg_4 DROP TEMPLATE u_template;

ASMCMD equivalent for this command is rmtmpl (11gR2 command).

Checking Metadata
The internal consistency of diskgroup metadata can be checked in a number of ways using
the CHECK clause of the ALTER DISKGROUP statement.
Checking metadata for a specific file
SQL> ALTER DISKGROUP dg_5 CHECK FILE '+dg_5/my_dir/my_file.dbf'

Checking metadata for a specific disk in the diskgroup


SQL> ALTER DISKGROUP dg_5 CHECK DISK diska1;

Checking metadata for a specific failure group in the diskgroup


SQL> ALTER DISKGROUP dg_5 CHECK FAILGROUP failure_group_1;
Checking metadata for all disks in the diskgroup
SQL> ALTER DISKGROUP dg_5 CHECK ALL;
SQL> ALTER DISKGROUP dg_5 CHECK;
SQL> ALTER DISKGROUP dg_5 CHECK NOREPAIR;
SQL> ALTER DISKGROUP dg_5 CHECK REPAIR;

ASMCMD equivalent for this command is chkdg (11gR2 command).


User Management
From Oracle 11g release 2, we can create ASM users and usergroups and manipulate the
permissions and ownership of files.

Creating an ASM usergroup


SQL> ALTER DISKGROUP data_dgADD USERGROUP 'grp1';
SQL> ALTER DISKGROUP data_dgADD USERGROUP 'grp2' WITH MEMBER
'oracle1','oracle2';
ASMCMD equivalent for this command is mkgrp (11gR2 command).

Listing ASM usergroups


To find out the list of ASM usergroups.
SQL> SELECT * FROM V$ASM_USERGROUP;
ASMCMD equivalent for this command is lsgrp (11gR2 command).

Dropping an ASM usergroup


SQL> ALTER DISKGROUP data_dgDROP USERGROUP 'grp1';
ASMCMD equivalent for this command is rmgrp (11gR2 command).

Modifying(adding/deleting ASM users to/from) an ASM usergroup


SQL> ALTER DISKGROUP data_dgMODIFY USERGROUP 'grp2' ADD MEMBER 'oracle3';
SQL> ALTER DISKGROUP data_dgMODIFY USERGROUP 'grp2' DROP MEMBER 'oracle3';
ASMCMD equivalent for this command is grpmod (11gR2 command).

Creating an ASM user


SQL> ALTER DISKGROUP data_dgADD USER 'oracle1';
ASMCMD equivalent for this command is mkusr (11gR2 command).

Listing ASM users


To find out the list of ASM users.
SQL> SELECT * FROM V$ASM_USER;
ASMCMD equivalent for this command is lsusr (11gR2 command).

Listing ASM usergroups to which user belongs


SQL> SELECT * FROM V$ASM_USERGROUP_MEMBER;
ASMCMD equivalent for this command is groups (11gR2 command).

Dropping an ASM user


SQL> ALTER DISKGROUP data_dgDROP USER 'oracle1';
ASMCMD equivalent for this command is rmusr (11gR2 command).

Modifying permissions for a file


SQL> ALTER DISKGROUP data_dgSET PERMISSION OWNER=read write, GROUP=read
only, OTHER=none FOR FILE '+data_dg/controlfile.f';
ASMCMD equivalent for this command is chmod (11gR2 command).

Modifying ownership of a file


SQL> ALTER DISKGROUP data_dgSET OWNERSHIP OWNER='oracle1', GROUP='grp1'
FOR FILE '+data_dg/controlfile.f';
ASMCMD equivalent for this command is chown (11gR2 command).

Volume Management
From 11g release 2, we can create Oracle ASM Dynamic Volume Manager (Oracle ADVM)
volumes in a diskgroups. The volume device associated with the dynamic volume can then be
used to host an (Oracle ACFS) file system.

Creating a volume
SQL> ALTER DISKGROUP data_dg ADD VOLUME volume1 SIZE 20G;
ASMCMD equivalent for this command is volcreate (11gR2 command).

Listing volume information


To find out the volumes information.
SQL> SELECT * FROM V$ASM_VOLUME;
ASMCMD equivalent for this command is volinfo (11gR2 command).

Listing volume statistics


To find out the volumes statistics information.
SQL> SELECT * FROM V$ASM_VOLUME_STAT;

ASMCMD equivalent for this command is volstat (11gR2 command).


Dropping a volume
SQL> ALTER DISKGROUP data_dg DROP VOLUME volume1;
ASMCMD equivalent for this command is voldelete (11gR2 command).

Resizing a volume
SQL> ALTER DISKGROUP fra_dg RESIZE VOLUME volume1 SIZE 25G;
ASMCMD equivalent for this command is volresize (11gR2 command).

Disabling a volume
SQL> ALTER DISKGROUP redo_dg DISABLE VOLUME volume1;
SQL> ALTER DISKGROUP ALL DISABLE VOLUME ALL;
ASMCMD equivalent for this command is voldisable (11gR2 command).

Enabling a volume
SQL> ALTER DISKGROUP arch_dg ENABLE VOLUME volume1;
ASMCMD equivalent for this command is volenable (11gR2 command).

Setting a volume
SQL> ALTER DISKGROUP asm_dg_data MODIFY VOLUME volume1 USAGE 'acfs';
ASMCMD equivalent for this command is volset (11gR2 command).

Misc
Listing the current operations
SQL> SELECT * FROM V$ASM_OPERATION;
ASMCMD equivalent for this command is lsop (11gR2 command).

Creating Tablespaces
Now create a tablespace in the main database using a datafile in the ASM-enabled storage.
SQL> CREATE TABLESPACE user_data DATAFILE '+dskgrp1/user_data_01' SIZE 1024M;
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 diskgroup.
SQL> CREATE TABLESPACE my_ts DATAFILE '+disk_group_1' SIZE 100M AUTOEXTEND
ON;
Note how the diskgroup is used as a virtual file system. This approach is useful not only in
datafiles, but in other types of Oracle files as well. For instance, we can create online redo log
files as...
LOGFILE GROUP 1
('+dskgrp1/redo/group_1.258.659723485','+dskgrp2/redo/group_1.258.659723485') SIZE
50M,.
Archived log destinations can also be set to a diskgroup. Everything related to Oracle
database can be created in an ASM diskgroup. Backup is another great use of ASM. You can
set up a bunch of inexpensive disks to create the recovery area of a database, which can be
used by RMAN to create backup datafiles and archived log files.
ASM supports files created by and read by the Oracle database only; it is not a replacement
for a general-purpose file system.
Until Oracle 11g release1, we cannot store binaries or flat files. We cannot use ASM for storing
the voting disk and OCR. It is due to the fact that Clusterware starts before ASM instance and
it should be able to access these files which are not possible if you are storing it on ASM. You
will have to use raw devices or OCFS or any other shared storage. But from 11g release 2, we
can store ALL files on ASM.
Can we see the files stored in the ASM instance using standard Unix commands?
No, you cannot see the files using standard Unix commands like ls. You need to use utility
called asmcmd to do this. Oracle 10g release2 introduces asmcmd which makes administration
very easy.
$ asmcmd
ASMCMD>
ASMLIB is the support library for the ASM. ASMLIB allows an Oracle database using ASM
more efficient and capable access to diskgroups. The purpose of ASMLIB, is to provide an
alternative interface to identify and access block devices. ASMLIB API enables storage and
OS vendors to supply extended storage-related features.
Migrating to ASM using RMAN
The following method shows how a database can be migrated to ASM from a disk based
backup:
1) Shutdown the database.
SQL> SHUTDOWN IMMEDIATE
2) Modify the parameter file of the database as follows:
Set DB_CREATE_FILE_DEST and DB_CREATE_ONLINE_LOG_DEST_n parameters to the
relevant ASM diskgroups.
3) Remove 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.
4) Start the database in nomount mode.
RMAN> STARTUP NOMOUNT
5) Restore the controlfile into the new location from the old location.
RMAN> RESTORE CONTROLFILE FROM 'old_control_file_name';
6) Mount the database.
RMAN> ALTER DATABASE MOUNT;
7) Copy the database into the ASM diskgroup.
RMAN> BACKUP AS COPY DATABASE FORMAT '+disk_group';
8) Switch all datafile to the new ASM location.
RMAN> SWITCH DATABASE TO COPY;
9) Open the database.
RMAN> ALTER DATABASE OPEN;
10) Create new redo logs in ASM and delete the old ones.

ASM New features in Oracle 11g release1


 Support for rolling upgrades.
 We can maintain version compatibilites at diskgroup level.
SQL> alter diskgroup dg-name set attribute 'compatible.rdbms'='11.1';
SQL> alter diskgroup dg-name set attribute 'compatible.asm'='11.1';
 ASM drops disks and if they remain offline for more than 3.6 hours. The diskgroups
default time limit is altered by changing the DISK_REPAIR_TIME parameter with a unit of
minutes(M/m) or hours(H/h).
SQL> alter diskgroup dg-name set attribute 'disk_repair_time'='4.5h';
 Automatic bad block detection and repair.
 Supports variable extent(allocation unit) sizes. The total number of extents in shared
pool will be significantly reduced and improved performance.
SQL> create diskgroup ... attribute 'au_size' = 'number-of-bytes';
 New SYSASM role (like SYSDBA, SYSOPER) & OSASM OS group (like OSDBA,
OSOPER) to manage ASM instance only. This will separate storage administration from
database administration.
$ sqlplus "/as sysasm" or $ asmcmd -a sysasm
 ASM Preferred Mirror Read or Preferred Read Failure Groups -
ASM_PREFERRED_READ_FAILURE_GROUPS parameter is set to the preferred failure
groups for each node.
 Faster Mirror Resync - Fast mirror resync after temporary connectivity lost.
 We can drop a diskgroup forcefully.
SQL> drop diskgroup dg-name force including contents;
 Can mount the disk in restricted mode, to rebalance faster.
SQL> alter diskgroup dg-name mount restricted;
o New commands in ASMCMD.cp- to copy between ASM and local or remote
destination.
o md_backup- to backup metadata.
o md_restore- to restore metadata.
o lsdsk- to list(check) disks.
o remap- to repair a range of physical blocks on disk.

ASM New features in Oracle 11g release2


 ASM Configuration Assistant (ASMCA) is a new tool to install and configure ASM.
 ASM Cluster File System (ACFS) provides support for files such as Oracle binaries,
Clusterware binaries, report files, trace files, alert logs, external files, and other
application datafiles. ACFS can be managed by ACFSUTIL, ASMCMD, OEM, ASMCA,
SQL command interface.
 ASM Dynamic Volume Manager (ADVM) provides volume management services and
a standard device driver interface to its clients (ACFS, ext3, OCFS2 and third party files
systems).
 ACFS Snapshots are read-only on-line, space efficient, point in time copy of an ACFS
file system. ACFS snapshots can be used to recover from inadvertent modification or
deletion of files from a file system.
 ASM can hold and manage OCR (Oracle Cluster Registry) file and voting file.
 ASM diskgroups can be renamed, by using renamedg command.
o ASMCMD utility can dostartup and shutdownof ASM instances.
o Managing diskgroups (create, mount, alter, drop).
o File access control (like OS, ugo and rwx ...).
o User management.
o Template management.
o Volume management.
o We can execute OS commands at asmcmd by using !, in the same we do at
SQL prompt.

ASM New features in Oracle Clusterware 12c


1. Oracle Flex ASM - This feature of Oracle Clusterware 12c claims to reduce per-node
overhead of using ASM instance. Now the instances can use remote node ASM for any
planned/unplanned downtime. ASM metadata requests can be converted by non-local
instance of ASM.

2. ASM Disk Scrubbing - From RAC 12c, ASM comes with disk scrubbing feature so that
logical corruptions can be discovered. Also Oracle 12c ASM can automatically correct this in
normal or high redundancy diskgroups.

3. Oracle ASM Disk Resync & Rebalance enhancements.

ASM New features in Oracle Clusterware 12c


1. Oracle Flex ASM - This feature of Oracle Clusterware 12c claims to reduce per-node
overhead of using ASM instance. Now the instances can use remote node ASM for any
planned/unplanned downtime. ASM metadata requests can be converted by non-local
instance of ASM.

2. ASM Disk Scrubbing - From RAC 12c, ASM comes with disk scrubbing feature so that
logical corruptions can be discovered. Also Oracle 12c ASM can automatically correct this in
normal or high redundancy diskgroups.

3. Oracle ASM Disk Resync & Rebalance enhancements.

ASM Views
The ASM configuration can be viewed using the V$ASM_% views, which contain information
depending on whether they are queried from the ASM instance, or a dependant database
instance.

View In A
V$ASM_ALIAS Displays a row for each alias present in ever
V$ASM_ATTRIBUTE (11gR2) Displays attributes of diskgroups.
V$ASM_CLIENT Displays a row for each database instance u
Displays a row for each disk discovered by
V$ASM_DISK or V$ASM_DISK_STAT
any diskgroup.
V$ASM_DISK_IOSTAT (11gR2) Displays IO statistics of disks.
V$ASM_DISKGROUP or V$ASM_DISKGROUP_STAT Displays a row for each diskgroup discovere
V$ASM_FILE Displays a row for each file for each diskgro
V$ASM_FILESYSTEM (11gR2) Displays a row for each filesystem for each d
V$ASM_OPERATION Displays a row for each file for each long run
V$ASM_TEMPLATE Displays a row for each template present in
V$ASM_USER (11gR2) Displays a row for each ASM user.
V$ASM_USERGROUP (11gR2) Displays a row for each ASM usergroup.
V$ASM_USERGROUP_MEMBER (11gR2) Displays ASM usergroups and it's members
V$ASM_VOLUME or V$ASM_VOLUME_STAT (11gR2) Displays a row for each volume.

ASM backup can be taken by spooling the output of the ASM views to text file.

SPOOL asm_views.log
SET ECHO ON
SELECT * FROM V$ASM_ALIAS;
SELECT * FROM V$ASM_ATTRIBUTE;
SELECT * FROM V$ASM_CLIENT;
SELECT * FROM V$ASM_DISK;
SELECT * FROM V$ASM_DISK_IOSTAT;SELECT * FROM V$ASM_DISK_STAT;
SELECT * FROM V$ASM_DISKGROUP;
SELECT * FROM V$ASM_DISKGROUP_STAT;
SELECT * FROM V$ASM_FILE;
SELECT * FROM V$ASM_FILESYSTEM;
SELECT * FROM V$ASM_OPERATION;
SELECT * FROM V$ASM_TEMPLATE;
SELECT * FROM V$ASM_USER;
SELECT * FROM V$ASM_USERGROUP;
SELECT * FROM V$ASM_USERGROUP_MEMBER;
SELECT * FROM V$ASM_VOLUME;
SELECT * FROM V$ASM_VOLUME_STAT;
SPOOL OFF

asmcmd utility in Oracle


Automatic Storage Management (ASM) Command line utility (ASMCMD), introduced with
Oracle Database 10g release 2.

Managing ASM through SQL interfaces, in Oracle Database 10g Release 1, posed a challenge
for administrators who were not very familiar with SQL and preferred a more conventional
command line interface. From Oracle Database 10g Release 2, we have an option to manage
the ASM files by using ASMCMD, a powerful and easy to use command line tool.
In Oracle Database 10g Release 1, ASM diskgroups are not visible outside the database for
regular file system administration tasks such as copying and creating directories. From Oracle
Database 10g Release 2, we can transfer the files from ASM to locations outside of the
diskgroups via FTP and through a web browser using HTTP.
(From 11.2.0) ASMCMD is used to
 start/stop ASM instances
 create or alter or drop diskgroups
 mount or dismount diskgroups
 list the contents, statistics and attributes of diskgroups, and files on them
 backup and restore the metadata of diskgroups
 create and remove directories, templates and aliases
 managing volumes
 make online or offline the disks/failure groups
 can rebalance the diskgroups
 repair physical blocks
 copy the files between the diskgroups and OS
 backup and restore of SP file
 add/remove/modify/list users from password file
 add/remove/modify/list templates
 manipulate diskstring
 create/modify/remove ASM users, groups
 change ASM file permissions, owners and groups
 display space utilization
 perform searches
ASMCMD has equivalent commands for all the SQL commands that can be performed
through SQL*Plus.
ASMCMD is included in the installation of the Oracle Database software (from 10g Release
2), no separate setup is required.
We can’t see the files stored in the ASM instance using standard UNIX commands like ls. We
need to use asmcmd. The asmcmd command line interface is very similar to standard
UNIX/Linux commands, but it only manages files at the OS level. The asmcmd utility supports
all common Linux commands. The idea of this tool is to make administering the ASM files
similar to administering standard OS files.
Invoking asmcmd
To start using ASMCMD, you must log in as a user that has SYSASM or SYSDBA privileges
through OS authentication. The environmental variables ORACLE_HOME and ORACLE_SID
must be set to the ASM instance. Ensure that $ORACLE_HOME/bin is in PATH environment
variable. You must have ASM configured on the machine and started, and the ASM
diskgroups are mounted.
The default value of the ASM SID for a single instance database is +ASM. In Real Application
Clusters (RAC) environments, the default value of the ASM SID on any node is +ASMnode#
(+ASM1, +ASM2, ...).
$ export ORACLE_SID=+ASM
To enter in interactive mode, type asmcmd, which brings up the ASM command prompt.
$ asmcmd
ASMCMD>
To run a specific ASMCMD command, non interactively, we can type
$ asmcmd command arguments
We can specify -p option with the asmcmd command to include current directory path in the
ASMCMD prompt.
$ asmcmd -p
ASMCMD [+] > cd dgroup1/hrms
ASMCMD [+dgroup1/hrms] >
We can specify -a option to choose the type of connection, either SYSASM or SYSDBA. From
11g, the SYSASM privilege is preferred & default.
$ asmcmd -a sysasm or asmcmd -a sysdba
We can specify -V option when starting asmcmd to displays the asmcmd version number.
This is from 11g.
$ asmcmd -V
asmcmd version 11.1.0.6.0
We can specify -v option when starting asmcmd to displays the additional information. This is
from 11g.
$ asmcmd -v
ASM Filenames & Directories
Pathnames within ASMCMD, can use either the forward slash (/) as in UNIX or the backward
slash (\) as in Windows, they're interchangeable. Also, we can use either the UNIX wildcard
"*" to match any string in a pathname, or its SQL equivalent, "%".
Filenames are not case sensitive, but are case retentive, that is, ASMCMD retains the case of
the directory that you entered.
The fully qualified filename represents a hierarchy of directories in which the plus sign (+)
represent the root directory. We can also create our own directories as subdirectories of the
system-generated directories using the ALTER DISKGROUP command or with the ASMCMD
mkdir command. Those directories can have subdirectories, and we can navigate the
hierarchy of both system-generated directories and user-created directories with the cd
command.
When we run an ASMCMD command that accepts a filename or directory name as an
argument, we can use the name as either an absolute path or a relative path.
An absolute path refers to the full path of a file or directory. An absolute path begins with a
plus sign (+) followed by a diskgroup name, followed by subsequent directories in the
directory tree. The absolute path includes directories until the file or directory is reached. A
fully qualified filename is an example of an absolute path to a file.
Using an absolute path enables the command to access the file or directory regardless of
where the current directory is set. The following rm command uses an absolute path for the
filename:
ASMCMD [+] > rm +dgroup1/hrms/datafile/users.280.555341999
A relative path includes only the part of the filename or directory name that is not part of the
current directory. That is, the path to the file or directory is relative to the current directory.
ASMCMD [+dgroup1/hrms/DATAFILE] > ls -l undotbs1.267.557429239
Paths to directories can also be relative and we can use the pseudo-directories "." and ".." in
place of a directory name. The wildcard characters * and % match zero or more characters
anywhere within an absolute or relative path, which saves typing of the full directory or file
name. These two wildcard characters behave identically.
Alias
As in UNIX, we can create alias names for files listed in the diskgroup. Aliases are user-
friendly filenames that are references or pointers to system-generated filenames. Aliases are
similar to symbolic links in UNIX flavors. ASM's auto generated names can be a bit strange,
so creating aliases makes working with ASM files with ASMCMD easier. Aliases simplify ASM
filename administration. We can create aliases with an ALTER DISKGROUP command or
with the mkalias ASMCMD command.
An alias has at a minimum the diskgroup name as part of its complete path. We can create
aliases at the diskgroup level or in any system-generated or user-created subdirectory. The
following are examples of aliases:
+dgroup1/ctl1.f
+dgroup1/crm/ctl1.f
+dgroup1/mydir/ctl1.f

If you run the ASMCMD ls (list directory) with the -l flag, each alias is listed with the system-
generated file to which the alias refers.
ctl1.f => +dgroup2/hrms/CONTROLFILE/Current.256.541956473
We can run the ASMCMD utility in either interactive or non interactive mode.
ASMCMD in Interactive Mode
The interactive mode of the ASMCMD utility provides an environment like shell or SQL*Plus,
where we are prompted to enter ASMCMD commands.
To run ASMCMD in interactive mode:
1. Enter the following at the OS command prompt:
$ asmcmd
Oracle displays an ASMCMD command prompt as follows:
ASMCMD>
2. Enter an ASMCMD command and press Enter. The command runs and displays its output,
and then ASMCMD prompts for the next command.
3. Continue entering ASMCMD commands. Enter the command exit to exit ASMCMD.

ASMCMD in Non Interactive Mode


In non interactive mode, you run a single ASMCMD command by including the command and
command arguments on the command line that invokes ASMCMD. ASMCMD runs the
command, generates output, and then exits. The non interactive mode is especially useful for
running scripts.
To run ASMCMD in non interactive mode, where command is any valid ASMCMD command
and arguments is a list of command flags and arguments, at the command prompt enter the
following:
$ asmcmd command arguments
$ asmcmd ls -l
State Type Rebal Unbal Name
MOUNTED NORMAL N N DG_GROUP1/
MOUNTED NORMAL N N DG_GROUP2/
$ asmcmd lsdg ASM_DG_FRA
$ asmcmd mkdir +data/hrms/archives
$ asmcmd md_restore -b /u01/app/oracle/BACKUP/asm_md_backup -t nodg
Oracle 10g (Release 2)commands

cd command
Changes to a specified directory. We can go up or down the hierarchy of the current directory
tree by providing a directory argument to the cd command.
cd dir_name
dir_name may be specified as either an absolute path or a relative path, including the . and ..
pseudo-directories and wildcards.
ASMCMD [+dgroup2/crm] > cd +dgroup1/hrms
ASMCMD [+dgroup1/hrms] > cd DATAFILE
ASMCMD [+dgroup1/hrms/DATAFILE] > cd ..
ASMCMD [+]> cd +dgroup1/sample/C*
If a wildcard pattern matches only one directory when using wildcard characters with cd, then
cd changes the directory to that destination. If the wildcard pattern matches multiple
directories, then ASMCMD does not change the directory but instead returns an error.
pwd command
Displays the absolute path of the current directory.
pwd
ASMCMD> pwd

help command
Displays the syntax of a command and description of the command parameters.
help [command] or ? [command]

If you do not specify a value for command, then the help command lists all of the ASMCMD
commands and general information about using the ASMCMD utility.
ASMCMD> help
ASMCMD> help lsct
ASMCMD> ?
ASMCMD> ? mkgrp
du command
Displays the total space used for files in the specified directory and in the entire directory tree
under the directory.
du [-H] [dir_name]

The -H flag suppresses column headings from the output.


This command is similar to the du -s command on UNIX flavors. If you do not specify
dir_name, then information about the current directory is displayed. dir_name can contain
wildcard characters.
ASMCMD [+dgroup1/prod] > du
Used_MB Mirror_used_MB
1251 2507
Used_MB - The total space used in the directory, this value does not include mirroring.
Mirror_used_MB - This value includes mirroring.
For example, if a normal redundancy diskgroup contains 100 MB of data, then assuming that
each file in the diskgroup is 2way mirrored, Used_MB is 100 MB and Mirror_used_MB is 200
MB.
ASMCMD> du TEMPFILE
Used_MB Mirror_used_MB
24582 24582
In this case, Used_MB & Mirror_used_MB are the same, because the diskgroups are not
mirrored.
ASMCMD [+ASM_DG_DATA/CRM] > du -H DATAFILE/
98203 98203
find command
Displays the absolute paths of all occurrences of the specified name pattern (can have
wildcards) in a specified directory and its subdirectories.
find [-t type] dir_name name_pattern
find [--type type] dir_name name_pattern (Oracle 11g R2 syntax)
type can be (these are the type values from the type column of the V$ASM_FILE)
CONTROLFILE,DATAFILE,ONLINELOG,ARCHIVELOG,TEMPFILE,BACKUPSET,PARAMET
ERFILE,DATAGUARDCONFIG,FLASHBACK,CHANGETRACKING,DUMPSET,AUTOBACK
UP,XTRANSPORT
This command searches the specified directory and all subdirectories under it in the directory
tree for the supplied name_pattern. The value that you use for name_pattern can be a
directory name or a filename.
ASMCMD> find +dgroup1 undo*
+dgroup1/crm/DATAFILE/UNDOTBS1.258.555341963
+dgroup1/crm/DATAFILE/UNDOTBS1.272.557429239
ASMCMD> find -t CONTROLFILE +dg_data/hrms *
+dg_data/hrms/CONTROLFILE/Current.260.555342185
+dg_data/hrms/CONTROLFILE/Current.261.555342183
ASMCMD [+] > find --type CONTROLFILE +data/devdb *
+data/devdb/CONTROLFILE/Current.260.691577263

ls command
Lists the contents of an ASM directory, the attributes of the specified file, or the names and
attributes of all diskgroups from the V$ASM_DISKGROUP_STAT (default) or
V$ASM_DISKGROUP.
ls [-lsdrtLacgH] [name]
ls [-lsdtLacgH] [--reverse] [--permission] [pattern] (11g R2syntax)
name can be a filename or directory name, can include wildcards.
If name is a directory name, then ASMCMD lists the contents of the directory and depending
on flag settings, ASMCMD also lists information about each directory member. Directories are
listed with a trailing forward slash (/) to distinguish them from files.
If name is a filename, then ASMCMD lists the file and depending on the flag settings,
ASMCMD also lists information about the file.
Flag Description
(none) Displays only filenames and directory names.
Displays extended file information, including striping and redundancy information and whether t
file was system-generated (indicated by Y under the SYS column) or user-created (as in the ca
-l
of an alias, indicated by N under the SYS column). Note that not all possible file attributes
diskgroup attributes are included.
-s Displays file space information.
If the value for the name argument is a directory, then ASMCMD displays information about th
-d
directory, rather than the directory contents. Typically used with another flag, such as the -l flag.
-r or
Reverses the sort order of the listing.
--reverse
-t Sorts the listing by timestamp.
If the value for the name argument is an alias, then ASMCMD displays information about the f
-L
that it references. Typically used with another flag, such as the -l flag.
-a For each listed file, displays the absolute path of the alias that references it.
-c Selects from V$ASM_DISKGROUP or GV$ASM_DISKGROUP if the -g flag is also specified.
Selects from GV$ASM_DISKGROUP_STAT or GV$ASM_DISKGROUP if the -c flag is al
-g
specified. GV$ASM_DISKGOUP.INST_ID is included in the output.
-H Suppresses column headings.
Shows the permissions of a file (V$ASM_FILE.permission, V$ASM_FILE.own
--permission
V$ASM_FILE.usergroup, V$ASM_ALIAS.name).
pattern Name of a file, directory, or pattern.

If you specify all of the flags, then the command shows a union of their attributes, with
duplicates removed. To see the complete set of column values for a file or a diskgroup, query
the V$ASM_FILE and V$ASM_DISKGROUP.
ASMCMD [+dgroup1/sample/DATAFILE] > ls
EXAMPLE.269.555342243
SYSAUX.257.555341961
SYSTEM.256.555341961
UNDOTBS1.258.555341963
UNDOTBS1.272.557429239
USERS.259.555341963

ASMCMD [+dgroup1/sample/DATAFILE] > ls -l


Type Redund Striped Time Sys Name
DATAFILE MIRROR COARSE APR 18 19:16:07 Y EXAMPLE.269.555342243
DATAFILE MIRROR COARSE MAY 09 22:01:28 Y SYSAUX.257.555341961
DATAFILE MIRROR COARSE APR 19 19:16:24 Y SYSTEM.256.555341961
DATAFILE MIRROR COARSE MAY 05 12:28:42 Y UNDOTBS1.258.555341963
DATAFILE MIRROR COARSE MAY 04 17:27:34 Y UNDOTBS1.272.557429239
DATAFILE MIRROR COARSE APR 18 19:16:07 Y USERS.259.555341963

ASMCMD [+dgroup1/sample/DATAFILE] > ls -lt


Type Redund Striped Time Sys Name
DATAFILE MIRROR COARSE MAY 09 22:01:28 Y SYSAUX.257.555341961
DATAFILE MIRROR COARSE MAY 05 12:28:42 Y UNDOTBS1.258.555341963
DATAFILE MIRROR COARSE MAY 04 17:27:34 Y UNDOTBS1.272.557429239
DATAFILE MIRROR COARSE APR 19 19:16:24 Y SYSTEM.256.555341961
DATAFILE MIRROR COARSE APR 18 19:16:07 Y USERS.259.555341963
DATAFILE MIRROR COARSE APR 18 19:16:07 Y EXAMPLE.269.555342243

ASMCMD [+] > ls --permission +data/prod/datafile


User Group Permission Name
rw-rw-rw- EXAMPLE.265.691577295
rw-rw-rw- SYSAUX.257.691577149
rw-rw-rw- SYSTEM.256.691577149
rw-rw-rw- UNDOTBS1.258.691577151
rw-rw-rw- USERS.259.691577151

ASMCMD [+dgroup1/sample/DATAFILE] > ls -l undo*


Type Redund Striped Time Sys Name
DATAFILE MIRROR COARSE MAY 05 12:28:42 Y UNDOTBS1.258.555341963
DATAFILE MIRROR COARSE MAY 04 17:27:34 Y UNDOTBS1.272.557429239
ASMCMD [+dgroup1/sample/DATAFILE] > ls -s
Block_Size Blocks Bytes Space Name
8192 12801 104865792 214958080 EXAMPLE.269.555342243
8192 48641 398467072 802160640 SYSAUX.257.555341961
8192 61441 503324672 101187584 SYSTEM.256.555341961
8192 6401 52436992 110100480 UNDOTBS1.258.555341963
8192 12801 104865792 214958080 UNDOTBS1.272.557429239
8192 641 5251072 12582912 USERS.259.555341963
ASMCMD [+dgroup1] > ls +dgroup1/sample
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfilesample.ora
ASMCMD [+dgroup1] > ls -l +dgroup1/sample
Type Redund Striped Time Sys Name
Y CONTROLFILE/
Y DATAFILE/
Y ONLINELOG/
Y PARAMETERFILE/
Y TEMPFILE/
N
spfilesample.ora=>+dgroup1/sample/PARAMETERFILE/spfile.270.555342443
ASMCMD [+dgroup1] > ls -r +dgroup1/sample
spfilesample.ora
TEMPFILE/
PARAMETERFILE/
ONLINELOG/
DATAFILE/
CONTROLFILE/
ASMCMD [+dgroup1] > ls -lL example_df2.f
Type Redund Striped Time Sys Name
DATAFILE MIRROR COARSE APR 27 11:04 N example_df2.f =>
+dgroup1/sample/DATAFILE/EXAMPLE.271.556715087

ASMCMD [+dgroup1] > ls -a +dgroup1/sample/DATAFILE/EXAMPLE.271.556715087


+dgroup1/example_df2.f => EXAMPLE.271.556715087
ASMCMD [+dgroup1] > ls -lH +dgroup1/sample/PARAMETERFILE
PARAMETERFILE MIRROR COARSE MAY 04 21:48 Y spfile.270.555342443
If you enter ls +, then the command returns information about all diskgroups, including
information about whether the diskgroups are mounted.
ASMCMD [+dgroup1] > ls -l +
State Type Rebal Unbal Name
MOUNTED NORMAL N N DGROUP1/
MOUNTED HIGH N N DGROUP2/
MOUNTED EXTERN N N DGROUP3/

ASMCMD [+USERDG2/prod] > ls -l


Type Redund Striped Time Sys Name
- - - - Y CONTROLFILE/
- - - - Y DATAFILE/
- - - - Y ONLINELOG/
- - - - Y TEMPFILE/
- - - - N control01.ctl => +USERDG2/prod/CONTROLFILE/Current.260.573852215
- - - - N control02.ctl => +USERDG2/prod/CONTROLFILE/Current.261.573852215
- - - - N control03.ctl => +USERDG2/prod/CONTROLFILE/Current.262.573852215
- - - - N example01.dbf => +USERDG2/prod/DATAFILE/UNKNOWN.267.573852295
- - - - N redo01.log => +USERDG2/prod/ONLINELOG/group_1.263.573852243
- - - - N redo02.log => +USERDG2/prod/ONLINELOG/group_2.264.573852249
- - - - N redo03.log => +USERDG2/prod/ONLINELOG/group_3.265.573852255
- - - - N sysaux01.dbf => +USERDG2/prod/DATAFILE/SYSAUX.257.573852115
- - - - N system01.dbf => +USERDG2/prod/DATAFILE/SYSTEM.256.573852113
- - - - N temp01.dbf => +USERDG2/prod/TEMPFILE/TEMP.266.573852277
- - - - N undotbs01.dbf => +USERDG2/prod/DATAFILE/UNDOTBS1.258.573852115
- - - - N users01.dbf => +USERDG2
The Sys column, immediately to the left of the Name column, shows if the file or directory was
created by the ASM system. Because the CONTROLFILE directory is not a real file but an
alias, the attributes of the alias, such as size, free space, and redundancy, shown in the first
few columns of the output are null.

The following examples illustrate the use of wildcards.


ASMCMD> ls +dgroup1/mydir1/d*
data1.f
dummy.f

ASMCMD> ls +group1/sample/*
+dgroup1/sample/CONTROLFILE/:
Current.260.555342185
Current.261.555342183

+dgroup1/sample/DATAFILE/:
EXAMPLE.269.555342243
SYSAUX.257.555341961
SYSTEM.256.555341961
UNDOTBS1.272.557429239
USERS.259.555341963

+dgroup1/sample/ONLINELOG/:
group_1.262.555342191
group_1.263.555342195
group_2.264.555342197
group_2.265.555342201

+dgroup1/sample/PARAMETERFILE/:
spfile.270.555342443

+dgroup1/sample/TEMPFILE/:
TEMP.268.555342229

lsct command
Lists information about current ASM clients (from V$ASM_CLIENT). A client, is a database or
Oracle ASM Dynamic Volume Manager (Oracle ADVM), uses diskgroups that are managed
by the ASM instance to which ASMCMD is currently connected.
lsct [-gH] [disk_group]

Flag Description
(none) Displays information about current ASM clients from V$ASM_CLIENT.
-g Selects from GV$ASM_CLIENT. GV$ASM_CLIENT.INST_ID is included in the output.
-H Suppresses column headings.

An ASM instance serves as a storage container; it's not a database by itself. Other databases
use the space in the ASM instance for datafiles, control files, and so on.

How do you know how many databases are using an ASM instance?
ASMCMD [+DG1_FRA] > lsct
DB_Name Status Software_Version Compatible_version Instance_Name

PROD CONNECTED 10.2.0.1.0 10.2.0.1.0 PROD


REP CONNECTED 10.2.0.1.0 10.2.0.1.0 REP

ASMCMD [+] > lsct flash (in 11g)


DB_Name Status Software_Version Compatible_version Instance_Name Group_Name
TESTDB CONNECTED 11.2.0.1.0 11.2.0.1.0 TESTDB FLASH

SQL equivalent for lsct command is:


SQL> SELECT * FROM V$ASM_CLIENT;
lsdg command
Lists all diskgroups and their attributes from V$ASM_DISKGROUP_STAT (default) or
V$ASM_DISKGROUP. The output also includes notification of any current rebalance
operation for a diskgroup. If a diskgroup is specified, then lsdg returns only information about
that diskgroup.
lsdg [-gcH] [disk_group]
lsdg [-gH] [--discovery] [pattern] (11.2.0 syntax)

If group is specified, then information about only that diskgroup is listed.

Flag Description
(none) Displays all the diskgroup attributes.
Selects from V$ASM_DISKGROUP or GV$ASM_DISKGROUP if the -g flag is also specifi
-c or --discovery
option is ignored if the ASM instance is version 10.1 or earlier.
Selects from GV$ASM_DISKGROUP_STAT or GV$ASM_DISKGROUP if the -c or --discov
-g is also specified. GV$ASM_DISKGOUP.INST_ID is included in the output. The REBAL co
the GV$ASM_OPERATION is also included in the output.
-H Suppresses column headings.
Returns only information about the specified diskgroup or diskgroups that match the s
pattern
pattern.

To see the complete set of attributes for a diskgroup, use the V$ASM_DISKGROUP_STAT or
V$ASM_DISKGROUP.

Attribute Name Description


State of the diskgroup (BROKEN, CONNECTED, DISMOUNTED, MOUNTED, QUIES
State
UNKNOWN).
Type Diskgroup redundancy (NORMAL, HIGH, EXTERN).
Rebal Y if a rebalance operation is in progress.
Sector Sector size in bytes.
Block Block size in bytes.
AU Allocation unit size in bytes.
Total_MB Size of the diskgroup in MB.
Free_MB Free space in the diskgroup in MB, without redundancy, from V$ASM_DISKGROUP.
Req_mir_free_MB Amount of space that must be available in the diskgroup to restore full redundancy afte
severe failure that can be tolerated by the diskgroup. This is the REQUIRED_MIRROR_
column from V$ASM_DISKGROUP.
Amount of free space, adjusted for mirroring, that is available for new
Usable_file_MB
V$ASM_DISKGROUP.
Offline_disks Number of offline disks in the diskgroup. Offline disks are eventually dropped.
Name Diskgroup name.
Voting_files Specifies whether the diskgroup contains voting files (Y or N).

ASMCMD [+] > lsdg dgroup2


State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB
Offline_disks Name
MOUNTED NORMAL N 512 4096 1048576 206 78 0 39 0 dgroup2

The following example lists the attributes of the dg_data diskgroup (in 11.2.0).
ASMCMD [+] > lsdg dg_data
State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB
Offline_disks Voting_files Name
MOUNTED NORMAL N 512 4096 4194304 12288 8835 1117 3859 0 N DG_DATA

SQL equivalent for lsdg command is:


SQL> SELECT * FROM V$ASM_DISKGROUP;
SQL> SELECT * FROM V$ASM_DISKGROUP_STAT;

mkalias command
Creates an alias for specified system-generated filename.
mkalias file alias

alias must be in the same diskgroup as the system-generated file. Only one alias is permitted
for each ASM file.

ASMCMD [+dgroup1/sample/DATAFILE] > mkalias SYSAUX.257.555341961 sysaux.f

SQL equivalent for mkalias command is:


SQL> ALTER DISKGROUP dg_name ADD ALIAS user_alias FOR file;

mkdir command
Creates ASM directories under the current directory.
mkdir dir_name [dir_name...]

The current directory can be created by the system or by the user. You cannot create a
directory at the root (+) level, which is a diskgroup.

ASMCMD [+dgroup1] > mkdir subdir1 subdir2

SQL equivalent for mkdir command is:


SQL> ALTER DISKGROUP dg_name ADD DIRECTORY dir_name[, dir_name ...];

rm command
Deletes specified ASM files and directories.
rm [-rf] name [name]...

Flag Description
-f Force, remove it without user interaction.
-r Recursive, remove sub-directories also.

If name is a file or alias (can contain wildcard characters), then the rm command can delete
the file or alias, only if it is not currently in use by a client database.

If name is a directory, then the rm command can delete it only if it is empty (unless the -r flag
is used) and it is not a system-generated directory.

If name is an alias, then the rm command deletes both the alias and the file to which the alias
refers.
For example, if we have an alias,
+dg1/dir1/file.alias => +dg/orcl/DATAFILE/System.256.146589651
then running the
rm -r +dg1/dir1
command removes the +dg1/dir1/file.alias as well as
+dg/orcl/DATAFILE/System.256.146589651.
To delete only an alias and retain the file that the alias references, use the rmalias command.

If you use a wildcard, the rm command deletes all of the matches except nonempty
directories, unless you use the -r flag. To recursively delete, use the -r flag. This enables you
to delete a nonempty directory, including all files and directories in it and in the entire directory
tree underneath it. If you use the -r flag or a wildcard character, then the rm command
prompts you to confirm the deletion before proceeding, unless you specify the -f flag. When
using the -r flag, either the system-generated file or the alias must be present in the directory
in which you run the rm command.

ASMCMD [+dgroup1/sample/DATAFILE] > rm alias293.f


ASMCMD> rm -rf +dg/orcl/DATAFILE
ASMCMD> rm -rf fradg/*

SQL equivalents for rm command are:


SQL> ALTER DISKGROUP dg_name DROP FILE ...;
SQL> ALTER DISKGROUP dg_name DROP DIRECTORY ...;

rmalias command
Deletes the specified aliases, retaining the files that the aliases reference.
rmalias [-r] alias [alias]...

To recursively delete, use the -r flag. This enables you to delete all of the aliases in the
current directory and in the entire directory tree beneath the current directory. If any user-
created directories become empty as a result of deleting aliases, they are also deleted. Files
and directories created by the system are not deleted.

ASMCMD [+dgroup1/orcl/DATAFILE] > rmalias sysaux.f


ASMCMD > rmalias –r +dgroup1/orcl/ARCHIVES

SQL equivalent for rmalias command is:


SQL> ALTER DISKGROUP dg_name DELETE ALIAS user_alias;

exit command
Exits ASMCMD and returns control to the OS command prompt.
exit
ASMCMD> exit

Oracle 11g Release1 commands

cp command
Used to copy files between ASM diskgroups on local instances to and from remote instances.
The local ASM instance must be either the source or the target. The file copy cannot be
between remote instances. We can also use this command to copy files from ASM diskgroups
to the OS.
cp [-ifr] [\@connect_identifier:]src_fname [\@connect_identifier:]tgt_fname
cp [-ifr] [\@connect_identifier:]src_fnameN[, src_fnameN+1…]
[\@connect_identifier:]tgt_directory

Flag Description
-i Interactive, prompt before copy file or overwrite.
-f Force, if an existing destination file, remove it and try again without user interaction.
-r Recursive, copy forwarding sub-directories recursively.

The connect_identifier parameter is not required for a local instance copy, which is default. In
case of a remote instance copy, we need to specify the connect_identifier and ASM prompts
for a password in a non-echoing prompt. The connect_identifier is in the form of:
user_name@host_name[.port_number].SID
The user_name, host_name, and SID are required. The default port number is 1521.

src_fname(s) - Source file name to copy from. Enter either the fully qualified file name, or the
ASM alias.
tgt_fname - A user alias for the created target file name or alias directory name.
tgt_directory - A target alias directory within an ASM diskgroup. The target directory must
exist, otherwise the file copy returns an error.

The format of copied files is portable between Little-Endian and Big-Endian systems, if the
files exist in an ASM diskgroup. ASM automatically converts the format when it writes the files.
For copying non-ASM files from or to an ASM diskgroup, you can copy the files to a different
endian platform and then use one of the commonly used utilities to convert the file.
ASMCMD [+] > cp +DG1/vdb.ctf1 /backups/vdb.ctf1
copying file(s)...
source +DG1/vdb.ctf1
target /backups/vdb.ctf1
file, /backups/vdb.ctf1, copy committed.

ASMCMD [+DG3/prod/DATAFILE] > cp warehouse.dbf /tmp


copying file(s)...
source +DG3/prod/DATAFILE/warehouse.dbf
target /tmp/warehouse.dbf
file, /tmp/warehouse.dbf, copy committed.

ASMCMD [+] > cp +DATA/db11g/datafile/users.273.661514191 /tmp/users.dbf


ASMCMD [+] > cp +DATA1/db11g/datafile/users.273.661514191
+DATA2/db11g/datafile/users.f

md_backup command
Creates a backup file containing metadata for one or more diskgroups. By default, all the
mounted diskgroups are included in the backup file which is saved in the current working
directory. If the name of the backup file is not specified, ASM names the file
AMBR_BACKUP_INTERMEDIATE_FILE. Here AMBR stands for ASM Managed Backup
Recovery.
md_backup [-b location_of_backup] [-g dgname [-g dgname...]]
md_backup [-b location_of_backup] [-g dgname[, dgname...]]

Flag Description
-b Specifies the location in which you want to store the intermediate backup file.
-g Specifies the diskgroup name that needs to be backed up.

This example backs up all of the mounted diskgroups and creates the backup in the current
working directory.
ASMCMD > md_backup

The following example creates a backup of diskgroup asmdsk1 and asmdsk2. The backup will
be saved in the /tmp/dgbackup100221 file.
ASMCMD > md_backup –b /tmp/dgbackup100221 –g admdsk1 –g asmdsk2
ASMCMD > md_backup -b /u01/backup/backup.txt -g dg_fra,dg_data

md_restore command
This command restores a diskgroup metadata backup.
md_restore -b backup_file [-li] [-t (full)|nodg|newdg] [-f sql_script_file] [-g
'dg_name,dg_name,...'] [-o 'old_dg_name:new_dg_name,...']

md_restore backup_file [--silent]


[--full|--nodg|--newdg -o 'old_diskgroup:new_diskgroup [,...]']
[-S sql_script_file] [-G 'diskgroup [,diskgroup...]'] (11g R2syntax)

Flag Description
-b Reads the metadata information from backup_file.
-l Prints the messages to a file.
-i or --silent If md_restore encounters an error, it will stop. Specifying this flag ignores any errors.
Specifies the type of diskgroup to be created:
full - Create diskgroup and restore metadata.
-t
nodg - Restore metadata only.
newdg - Create diskgroup with a different name and restore metadata, -o is required to rename.
-f or -S Write SQL commands to sql_script_file instead of executing them.
Select the diskgroups to be restored. If no diskgroups are defined, then all diskgroups wil
-g or -G
restored.
-o Rename diskgroup old_dg_name to new_dg_name.

ASMCMD> md_restore -b /tmp/backup.txt -t full -g data

ASMCMD> md_restore –t newdg –of override.txt –i backup_file

Example restores the diskgroup asmdsk1 from the backup script and creates a copy.
ASMCMD> md_restore –t full –g asmdsk1 –i backup_file

Example takes an existing diskgroup asmdsk6 and restores its metadata.


ASMCMD> md_restore –t nodg –g asmdsk6 –i backup_file
Example restores diskgroup asmdsk1 completely but the new diskgroup that is created is
called asmdsk2.
ASMCMD> md_restore –t newdg -o 'asmdsk1:asmdsk2' –i backup_file

Example restores from the backup file after applying the overrides defined in the file
override.txt.
ASMCMD> md_restore –t newdg –of override.txt –i backup_file

Example restores the diskgroup data from the backup script and creates a copy.
ASMCMD [+] > md_restore –-full –G data –-silent /tmp/dgbackup20090714

Example takes an existing diskgroup data and restores its metadata.


ASMCMD [+] > md_restore –-nodg –G data –-silent /tmp/dgbackup20090714

Example restores diskgroup data completely but the new diskgroup that is created is called
data2.
ASMCMD [+] > md_restore –-newdg -o 'data:data2' --silent /tmp/dgbackup20090714

Example restores from the backup file after applying the overrides defined in the override.sql
script file.
ASMCMD [+] > md_restore -S override.sql --silent /tmp/dgbackup20090714

ASMCMD> md_restore -b dg7.backup -t full -f cr8_dg7.sql

lsdsk command
List the disks that are visible to ASM, using V$ASM_DISK_STAT (default) or V$ASM_DISK.
lsdsk [-ksptcgHI] [-d diskgroup_name] [pattern]

lsdsk [-kptgMHI] [-G diskgroup] [--member|--candidate]


[--discovery] [--statistics] [pattern] (11g R2syntax)

Flag Description
(none) Displays PATH column of V$ASM_DISK.
Displays TOTAL_MB, FREE_MB, OS_MB, NAME, FAILGROUP, LIBRARY, LABE
-k
PRODUCT, REDUNDANCY, and PATH columns of V$ASM_DISK.
-s or --statistics Displays READS, WRITES, READ_ERRS, WRITE_ERRS, READ_TIME, WRI
BYTES_READ, BYTES_WRITTEN, and PATH columns of V$ASM_DISK.
Displays GROUP_NUMBER, DISK_NUMBER, INCARNATION, MOUNT
-p
HEADER_STATUS, MODE_STATUS, STATE, and PATH columns of V$ASM_DISK.
-t Displays CREATE_DATE, MOUNT_DATE, REPAIR_TIMER, and PATH columns of V$AS
Selects from GV$ASM_DISK_STAT or GV$ASM_DISK if the -c flag is also
-g
GV$ASM_DISK.INST_ID is included in the output.
Selects from V$ASM_DISK or GV$ASM_DISK, if the -g flag is also specified. This option
-c
if the ASM instance is version 10.1 or earlier.
-H Suppresses column headings.
Scans disk headers for information rather than extracting the information from an ASM
-I
This option forces the non-connected mode.
-d or -G Restricts results to only those disks that belong to the group specified by diskgroup_name
Selects from V$ASM_DISK, or from GV$ASM_DISK if the -g flag is also specified. This
--discovery always enabled if the Oracle ASM instance is version 10.1 or earlier. This flag is disr
lsdsk is running in non-connected mode.
Displays the disks that are visible to some but not all active instances. These are dis
-M included in a diskgroup, cause the mount of that diskgroup to fail on the instances where
are not visible.
--candidate Restricts results to only disks having membership status equal to CANDIDATE.
--member Restricts results to only disks having membership status equal to MEMBER.
pattern Returns only information about the specified disks that match the supplied pattern.

The k, s, p, and t flags modify how much information is displayed for each disk. If any
combinations of the flags are specified, then the output shows the union of the attributes
associated with each flag.

pattern restricts the output to only disks that matches the pattern specified.
ASMCMD> lsdsk -d DG_DATA -k
ASMCMD> lsdsk -g -t -d DATA1 *_001

This command can run in connected or non-connected mode. The connected mode is always
attempted first. The -I option forces the non-connected mode.
In connected mode, ASMCMD uses dynamic views to retrieve disk information.
In non-connected mode, ASMCMD scans disk headers to retrieve disk information, using an
ASM disk string to restrict the discovery set. This is not supported on Windows.

ASMCMD> lsdsk -k -d ASM_DG_DATA *_001


ASMCMD> lsdsk -sp -d ASM_DG_FRA *_001
ASMCMD> lsdsk -Ik
ASMCMD> lsdsk -t -d ASM_DG_IDX *_001
ASMCMD> lsdsk -Ct -d ASM_DG_DATA *_001

The first and second examples list information about disks in the data diskgroup.
ASMCMD [+] > lsdsk -t -G data
Create_Date Mount_Date Repair_Timer Path
13-JUL-09 13-JUL-09 0 /devices/diska1
13-JUL-09 13-JUL-09 0 /devices/diska2
13-JUL-09 13-JUL-09 0 /devices/diskb1
13-JUL-09 13-JUL-09 0 /devices/diskb2

ASMCMD [+] > lsdsk -p -G data /devices/diska*


Group_Num Disk_Num Incarn Mount_Stat Header_Stat Mode_Stat State Path
1 0 2105454210 CACHED MEMBER ONLINE NORMAL /devices/diska1
1 1 2105454199 CACHED MEMBER ONLINE NORMAL /devices/diska2
1 2 2105454205 CACHED MEMBER ONLINE NORMAL /devices/diska3

The third example lists information about candidate disks.


ASMCMD [+] > lsdsk --candidate -p
Group_Num Disk_Num Incarn Mount_Stat Header_Stat Mode_Stat State Path
0 5 2105454171 CLOSED CANDIDATE ONLINE NORMAL /devices/diske1
0 25 2105454191 CLOSED CANDIDATE ONLINE NORMAL /devices/diske2
0 18 2105454184 CLOSED CANDIDATE ONLINE NORMAL /devices/diske3

SQL equivalent for lsdsk command is:


SQL> SELECT * FROM V$ASM_DISK;
SQL> SELECT * FROM V$ASM_DISK_STAT;

remap command
Repairs range of physical blocks on a disk. The remap command only repairs blocks that
have read disk I/O errors. It does not repair blocks that contain corrupted contents, whether
those blocks can be read or not. The command assumes a physical block size of 512 bytes
and supports all allocation unit sizes (1MB to 64MB).
It reads the blocks from a good copy of an ASM mirror and rewrites them to an alternate
location on disk if the blocks on the original location cannot be read properly.
remap diskgroup_name disk_name block_range

Flag Description
diskgroup_name Name of the diskgroup in which a disk must be repaired.
disk_name Name of the disk that must be repaired.
block_range Range of physical blocks to repair, in the format: starting_number-ending_number

The following example repairs blocks 4500 through 5599 for disk DATA_001 in diskgroup
DISK_GRP_DATA.
ASMCMD> remap DISK_GRP_DATA DATA_001 4500-5599

The following example repairs blocks 7200 through 8899 for disk largedisk_2 in diskgroup
DISK_GRP_GRA.
ASMCMD> remap DISK_GRP_FRA largedisk_2 7200-8899

Oracle 11g Release2 commands

From 11g release 2, ASMCMD utility can also do


 startup and shutdown of ASM instances.
 Managing diskgroups (create, mount, alter, drop).
 File access control (like OS, ugo and rwx ...).
 User management.
 Template management.
 Volume management.

ASMCMD Instance Management Commands

startup command
Starts up an Oracle ASM instance.
startup [--nomount] [--restrict] [--pfile pfile_name]

Flag Description
(default) Will mount diskgroups and enables Oracle ADVM volumes.
--nomount Specifies no mount operation.
--restrict Specifies restricted mode.
--pfile Oracle ASM initialization parameter file.

The following is an example of the startup command that starts the Oracle ASM instance
without mounting diskgroups and uses the asm_init.ora initialization parameter file.
ASMCMD> startup --nomount --pfile asm_init.ora

SQL equivalent for startup command is:


SQL> STARTUP ... ;

shutdown command
Shuts down an Oracle ASM instance.
shutdown [--abort|--immediate]

Flag Description
(default) normal shutdown.
--abort Shut down aborting all existing operations.
--immediate Shut down immediately.

Oracle strongly recommends that you shut down all database instances that use the Oracle
ASM instance and dismount all file systems mounted on Oracle ASM Dynamic Volume
Manager (Oracle ADVM) volumes before attempting to shut down the Oracle ASM instance
with the abort (--abort) option.

The first example performs a shutdown of the Oracle ASM instance with normal action.
ASMCMD [+] > shutdown

The second example performs a shut down with immediate action


ASMCMD [+] > shutdown –-immediate

The third example performs a shut down that aborts all existing operations.
ASMCMD [+] > shutdown --abort

SQL equivalent for shutdown command is:


SQL> SHUTDOWN ... ;

dsset command
Sets the discovery diskstring value that is used by the Oracle ASM instance and its clients.
The specified diskstring must be valid for existing mounted diskgroups. The updated value
takes effect immediately.
dsset [--normal] [--parameter] [--profile [--force]] diskstring

Flag Description
Sets the discovery string in the Grid Plug and Play (GPnP) profile and in the Oracle AS
The update occurs after the Oracle ASM instance has successfully validated that t
--normal discovery string has discovered all the necessary diskgroups and voting files. This com
the instance is not using a server parameter file (SPFILE).
This is the default setting.
Specifies the discovery diskstring that is pushed to the GPnP profile without any valid
Oracle ASM instance, ensuring that the instance can discover all the required disk
update is guaranteed to be propagated to all the nodes that are part of the cluster.
--profile [--force] If --force is specified, the specified diskstring is pushed to the local GPnP profile
synchronization with other nodes in the cluster. This command option updates only the
file. This option should only be used for recovery. The command fails if the Oracle
stack is running.
Specifies that the diskstring is updated in memory after validating that the discove
--parameter discovers all the current mounted diskgroups and voting files. The diskstring is not
recorded in either the SPFILE or the GPnP profile.
diskstring Specifies the value for the discovery diskstring.

The following example uses dsset to set the current value of the discovery diskstring in the
GPnP profile.
ASMCMD [+] > dsset /devices/disk*

dsget command
Retrieves the discovery diskstring value that is used by the Oracle ASM instance and its
clients.
dsget [[--normal] [--profile [--force]] [--parameter]]

Flag Description
Retrieves the discovery string from the Grid Plug and Play (GPnP) profile and the one
--normal the Oracle ASM instance. It returns one row each for the profile and parameter settin
default setting.
Retrieves the discovery string from the GPnP profile. If --force is specified, retrieves t
--profile [--force]
string from the local GPnP profile.
--parameter Retrieves the ASM_DISKSTRING parameter setting of the Oracle ASM instance.

The following example uses dsget to retrieve the current discovery diskstring value from the
GPnP profile and the ASM_DISKSTRING parameter.
ASMCMD [+] > dsget
profile: /devices/disk*
parameter: /devices/disk*

lspwusr command

List the current users from the local Oracle ASM password file.
lspwusr [-H]

-H Suppresses column headers from the output.

ASMCMD [+] > lspwusr


Username sysdba sysoper sysasm
SYS TRUE TRUE TRUE
ASMSNMP TRUE FALSE FALSE

ASMCMD [+] > lspwusr -H


SYS TRUE TRUE TRUE
Satya TRUE TRUE FALSE

orapwusr command
Add, drop, or modify an Oracle ASM password file user. The command requires the SYSASM
privilege to run. A user logged in as SYSDBA cannot change its password using this
command.
orapwusr {{ {--add | --modify [--password]}
[--privilege {sysasm|sysdba|sysoper}] } | --delete} user

Flag Description
--add Adds a user to the password file. Also prompts for a password.
--delete Drops a user from the password file.
--modify Changes a user in the password file.
--privilege Sets the role for the user. The options are sysasm, sysdba, and sysoper.
--password Prompts for and then changes the password of a user.
user Name of the user to add, drop, or modify.

orapwusr attempts to update passwords on all nodes in a cluster.

This example adds the Satya to the Oracle ASM password file with the role of the user set to
SYSASM.
ASMCMD [+] > orapwusr --add --privilege sysasm Satya
ASMCMD [+] > lspwusr
Username sysdba sysoper sysasm
SYS TRUE TRUE TRUE
Satya TRUE TRUE TRUE

spset command
Sets the location of the Oracle ASM SPFILE in the Grid Plug and Play (GPnP) profile.
spset location

The following is an example of the spset command that sets the location of the Oracle ASM
SPFILE command in the dg_data diskgroup.
ASMCMD> spset +DG_DATA/asm/asmparameterfile/asmspfile.ora

spget command
Retrieves the location of the Oracle ASM SPFILE from the Grid Plug and Play (GPnP) profile.
spget

The location retrieved by spget is the location in the GPnP profile, but not always the location
of the SPFILE currently used. For example, the location could have been recently updated by
spset or spcopy with the -u option on an Oracle ASM instance that has not been restarted.
After the next restart of the Oracle ASM, this location point to the ASM SPFILE currently is
being used.

The following is an example of the spget command that retrieves and displays the location of
the SPFILE from the GPnP profile.
ASMCMD [+] > spget
+DATA/asm/asmparameterfile/registry.253.691575633
spbackup command
Backs up an Oracle ASM SPFILE. spbackup does not affect the GPnP profile.
spbackup source destination

The backup file that is created is not a special file type and is not identified as a SPFILE. This
file cannot be copied with spcopy. To copy this backup file, use the ASMCMD cp command.

The first example backs up the Oracle ASM SPFILE from one operating system location to
another.
ASMCMD> spbackup /u01/oracle/dbs/spfile+ASM.ora /u01/oracle/dbs/bakspfileASM.ora

The second example backs up the SPFILE from an operating system location to the
data/bakspfileASM.ora diskgroup.
ASMCMD> spbackup /u01/oracle/dbs/spfile+ASM.ora +DG_DATA/bakspfileASM.ora

spcopy command
Copies an Oracle ASM SPFILE from source to destination. To use spcopy to copy an Oracle
ASM SPFILE into a diskgroup, the diskgroup attribute COMPATIBLE.ASM must be set to 11.2
or greater.
spcopy [-u] source destination

-u updates the Grid Plug and Play (GPnP) profile. We can also use spset to update the GPnP
profile.

Note the following about the use of spcopy:


 spcopy can copy an Oracle ASM SPFILE from a diskgroup to a different diskgroup or
to an operating system file.
 spcopy can copy an Oracle ASM SPFILE from an operating system file to a diskgroup
or to an operating system file.
 spcopy can copy an Oracle ASM SPFILE when the SPFILE is being used by an open
Oracle ASM instance.

After copying the SPFILE, you must restart the instance with the SPFILE in the new location
to use that SPFILE. When the Oracle ASM instance is running with the SPFILE in the new
location, you can remove the source SPFILE.

The first example copies the Oracle ASM SPFILE from one operating system location to
another.
ASMCMD> spcopy /u01/oracle/dbs/spfile+ASM.ora /u01/oracle/dbs/testspfileASM.ora

The second example copies the SPFILE from an operating system location to the data
diskgroup and updates the GPnP profile.
ASMCMD> spcopy -u /u01/oracle/dbs/spfile+ASM.ora +DATA/testspfileASM.ora

spmove command
Moves an Oracle ASM SPFILE from source to destination and automatically updates the
GPnP profile. To use spmove to move an Oracle ASM SPFILE into a diskgroup, the diskgroup
attribute COMPATIBLE.ASM must be set to 11.2 or greater.
spmove source destination

Note the following about the use of spmove:


 spmove can move an Oracle ASM SPFILE when the open instance is using a PFILE
or a different SPFILE. After moving the SPFILE, you must restart the instance with the
SPFILE in the new location to use that SPFILE.
 spmove cannot move an Oracle ASM SPFILE when the SPFILE is being used by an
open Oracle ASM instance.

The first example moves the Oracle ASM SPFILE from one operating system location to
another.
ASMCMD> spmove /u01/oracle/dbs/spfile+ASM.ora /u01/oracle/dbs/testspfileASM.ora

The second example moves the SPFILE from an operating system location to the data
diskgroup.
ASMCMD> spmove /u01/oracle/dbs/spfile+ASM.ora +DATA/testspfileASM.ora

lsop command
Lists the current operations on diskgroups or Oracle ASM instance, from
V$ASM_OPERATION.
lsop

ASMCMD [+] > lsop


Group_Name Dsk_Num State Power
DG_DATA REBAL WAIT 2

ASMCMD [+] > lsop


Group_Name Dsk_Num State Power
DG_FRA REBAL REAP 3

SQL equivalent for lsop command is:


SQL> SELECT * FROM V$ASM_OPERATION

ASMCMD File Access Control Commands


mkusr command
Adds a valid operating system user to a diskgroup. Only users authenticated as SYSASM can
run this command.
mkusr diskgroup user

The following example adds the asmdba2 user to the dg_fra diskgroup.
ASMCMD [+] > mkusr dg_fra asmdba2

SQL equivalent for mkusr command is:


SQL> ALTER DISKGROUP disk_group ADD USER 'user_name';

lsusr command
Lists Oracle ASM users in a diskgroup.
lsusr [-Ha] [-G diskgroup] [pattern]

Flag Description
-H Suppresses column headings.
-a List all users and the diskgroups to which the users belong.
-G Limits the results to the specified diskgroup name.
pattern Displays the users that match the pattern expression.

The example lists users in the asm_dg_data diskgroup and also shows the OS user Id
assigned to the user.
ASMCMD [+] > lsusr -G asm_dg_data
User_Num OS_ID OS_Name
3 1001 oradba
1 1021 asmdba1
2 1022 asmdba2
ASMCMD [+] > lsusr -G asm_dg_fra asm*
User_Num OS_ID OS_Name
1 1021 asmdba1
2 1022 asmdba2

SQL equivalent for lsusr command is:


SQL> SELECT * FROM V$ASM_USER;

passwd command
Changes the password of a user. The command requires the SYSASM privilege to run.
passwd user

The user is first prompted for the current password, then the new password. An error will be
raised if the user does not exist in the Oracle ASM password file.

ASMCMD [+] > passwd asmdba2


Enter old password (optional):
Enter new password: ******

rmusr command
Deletes an OS user from a diskgroup. Only a user authenticated as SYSASM can run this
command.
rmusr [-r] diskgroup user

-r removes all files in the diskgroup that the user owns at the same time that the user is
removed.

The following is an example to remove the asmdba2 user from the dg_data2 diskgroup.
ASMCMD [+] > rmusr dg_data2 asmdba2

SQL equivalent for rmusr command is:


SQL> ALTER DISKGROUP disk_group DROP USER 'user_name';

mkgrp command
Creates a new Oracle ASM user group. We can optionally specify a list of users to be
included as members of the new user group. User group name can have maximum 30
characters.
mkgrp diskgroup usergroup [user] [user...]

This example creates the asm_data user group in the dg_data diskgroup and adds the
asmdba1 and asmdba2 users to the user group.
ASMCMD [+] > mkgrp dg_data asm_data asmdba1 asmdba2

ASMCMD [+] > mkgrp dg_fra asm_fra

SQL equivalent for mkgrp command is:


SQL> ALTER DISKGROUP disk_group ADD USERGROUP 'usergroup_name';
SQL> ALTER DISKGROUP disk_group ADD USERGROUP 'usergroup_name' WITH
MEMBER 'user_names';

lsgrp command
Lists all Oracle ASM user groups.
lsgrp [-Ha] [-G diskgroup] [pattern]

Flag Description
-H Suppresses column headings.
-a Lists all columns.
-G Limits the results to the specified diskgroup name.
pattern Displays the user groups that match the pattern expression.

The following example displays a subset of information about the user groups whose name
matches the asm% pattern.
ASMCMD [+] > lsgrp asm%
DG_Name Grp_Name Owner
DG_FRA asm_fra grid
DG_DATA asm_data grid

The second example displays all information about all the user groups.
ASMCMD [+] > lsgrp –a –G DG_DATA
DG_Name Grp_Name Owner Members
DG_DATA asm_data grid asmdba1 asmdba2
SQL equivalent for lsgrp command is:
SQL> SELECT * FROM V$ASM_USERGROUP;

rmgrp command
Removes a user group from a diskgroup. The command must be run by the owner of the
group and also requires the SYSASM privilege to run.
rmgrp diskgroup usergroup

Removing a group might leave some files without a valid group. To ensure that those files
have a valid group, explicitly update those files to a valid group.

The following is an example of the rmgrp command that removes the asm_data user group
from the dg_data diskgroup.
ASMCMD [+] > rmgrp dg_data asm_data

SQL equivalent for rmgrp command is:


SQL> ALTER DISKGROUP disk_group DROP USERGROUP 'usergroup_name';

grpmod command
Adds or removes OS users to and from an existing Oracle ASM user group. Only the owner of
the user group can use this command. The command requires the SYSASM privilege to run.
This command accepts an OS user name or multiple user names separated by spaces. The
OS users are typically owners of a database instance home.
grpmod {--add | --delete} diskgroup usergroup user [user...]

Flag Description
--add Specifies to add users to the user group.
--delete Specifies to delete users from the user group.
usergroup Name of the user group.
user Name of the user to add or remove from the user group.

The following example adds the asmdba1 and asmdba2 users to the asm_fra user group of
the dg_fra diskgroup.
ASMCMD [+] > grpmod –-add dg_fra asm_fra asmdba1 asmdba2
The second example removes the asmdba2 user from the asm_data user group of the
dg_data diskgroup.
ASMCMD [+] > grpmod –-delete dg_data asm_data asmdba2

SQL equivalent for grpmod command is:


SQL> ALTER DISKGROUP disk_group MODIFY USERGROUP 'usergroup_name' ADD
MEMBER 'user_name';
SQL> ALTER DISKGROUP disk_group MODIFY USERGROUP 'usergroup_name' DROP
MEMBER 'user_name';

groups command
Lists all the user groups to which the specified user belongs.
groups diskgroup user

ASMCMD [+] > groups dg9 asmdba1


asm_data

SQL equivalent for groups command is:


SQL> SELECT * FROM V$ASM_USERGROUP_MEMBER;

chmod command
Changes permissions of a file or list of files. This command accepts a file name or multiple file
names separated by spaces. The specified files must be closed.
chmod mode file [file ...]

mode can be one of the following forms:


 {ugo|ug|uo|go|u|g|o|a} {+|-} {r|w|rw}
a specifies permissions for all users, u specifies permissions for the owner/user of the file,
g specifies the group permissions, and o specifies permissions for other users.
 {0|4|6} {0|4|6} {0|4|6}
The first digit specifies owner permissions, the second digit specifies group permissions,
and the third digit specifies other permissions.
Flag Description
6 Read write permissions
4 Read only permissions
0 No permissions
u Owner permissions, used with r or w
g Group permissions, used with r or w
o Other user permissions, used with r or w
a All user permissions, used with r or w
+ Add a permission, used with r or w
- Removes a permission, used with r or w
r Read permission
w Write permission
file Name of a file

We can only set file permissions to read-write, read-only, and no permissions. We cannot set
file permissions to write-only.
ASMCMD [+fra/orcl/archivelog/flashback] > chmod ug+rw log_7.264.684968167
log_8.265.684972027

ASMCMD [+fra/orcl/archivelog/flashback] > chmod 640 log_7.264.684968167


log_8.265.684972027

To view the permissions on a file, use the ASMCMD ls command with the --permission option.
ASMCMD [+] > ls --permission +fra/orcl/archivelog/flashback
User Group Permission Name
grid asm_fra rw-r----- log_7.264.684968167
grid asm_fra rw-r----- log_8.265.684972027

ASMCMD> chmod ug+rw +data/hrms/Controlfile/Current.175.654892547

SQL equivalent for chmod command is:


SQL> ALTER DISKGROUP disk_group SET PERMISSION OWNER=read write,
GROUP=read only, OTHER=none FOR FILE '..path..';

chown command
Changes the owner of a file or list of files. This command accepts a file name or multiple file
names separated by spaces. The specified files must be closed. Only the Oracle ASM
administrator can use this command.
chown user[:usergroup ] file [file ...]

user typically refers to the user that owns the database instance home. Oracle ASM File
Access Control uses the OS name to identify a database.
ASMCMD [+fra/orcl/archivelog/flashback] > chown asmdba1 log_7.264.684968167
log_8.265.684972027

ASMCMD [+fra/orcl/archivelog/flashback] > chown asmdba1:asm_fra log_9.264.687650269

ASMCMD> chown oracle1:asm_users +data/hrms/Controlfile/Current.175.654892547

SQL equivalent for chown command is:


SQL> ALTER DISKGROUP disk_group SET OWNERSHIP OWNER='user_name',
GROUP='usergroup_name' FOR FILE '..path..';

chgrp command
Changes the Oracle ASM user group of a file or list of files. This command accepts a file
name or multiple file names separated by spaces. Only the file owner or the Oracle ASM
administrator can use this command. If the user is the file owner, then he must also be either
the owner or a member of the group for this command to succeed.
chgrp usergroup file [file ...]

ASMCMD [+] > chgrp asm_data +data/orcl/controlfile/Current.260.684924747

ASMCMD [+fra/orcl/archivelog/flashback] > chgrp asm_fra log_7.264.684968167


log_8.265.684972027

ASMCMD Diskgroup Management Commands

mkdg command
Creates a diskgroup based on an XML configuration file which specifies the name of the
diskgroup, redundancy, attributes, and paths of the disks that form the diskgroup.
mkdg {config_file.xml | 'contents_of_xml_file'}

Flag Description
Name of the XML file that contains the configuration for the new diskgroup. m
config_file
XML file in the directory where ASMCMD was started unless a path is specifie
contents_of_xml_file The XML script enclosed in single quotations.

Redundancy is an optional parameter; the default is normal redundancy. For some types of
redundancy, disks are required to be gathered into failure groups. In the case that failure
groups are not specified for a diskgroup, each disk in the diskgroup belongs to its own failure
group.
It is possible to set some diskgroup attribute values during diskgroup creation. Some
attributes, such as AU_SIZE and SECTOR_SIZE, can be set only during diskgroup creation.

The default diskgroup compatibility settings are 10.1 for Oracle ASM compatibility, 10.1 for
database compatibility, and no value for Oracle ADVM compatibility.

Tags for mkdg XML Configuration File


<dg> diskgroup
name diskgroup name
redundancy normal, external, high

<fg> failure group


name failure group name
</fg>

<dsk> disk
name disk name
path disk path
size size of the disk to add
</dsk>

<a> attribute
name attribute name
value attribute value
</a>
</dg>

The following is an example of an XML configuration file for mkdg. The configuration file
creates a diskgroup named dg_data with normal redundancy. Two failure groups, fg1 and fg2,
are created, each with two disks identified by associated disk strings. The diskgroup
compatibility attributes are all set to 11.2.
<dg name="dg_data" redundancy="normal">
<fg name="fg1">
<dsk string="/dev/disk1"/>
<dsk string="/dev/disk2"/>
</fg>
<fg name="fg2">
<dsk string="/dev/disk3"/>
<dsk string="/dev/disk4"/>
</fg>
<a name="compatible.asm" value="11.2"/>
<a name="compatible.rdbms" value="11.2"/>
<a name="compatible.advm" value="11.2"/>
</dg>

The first example executes mkdg with an XML configuration file in the directory where
ASMCMD was started.
ASMCMD [+] > mkdg data_config.xml

The second example executes mkdg using information on the command line.
ASMCMD [+] > mkdg '<dg name="data"><dsk path="/dev/disk*"/></dg>'

SQL equivalent for mkdg command is:


SQL> CREATE DISKGROUP diskgroup_name ... ;

chdg command
Changes a diskgroup (adds disks, drops disks, or rebalances) based on an XML configuration
file.
chdg {config_file.xml | 'contents_of_xml_file'}

Flag Description
Name of the XML file that contains the changes for the diskgroup. chdg searc
config_file
the directory where ASMCMD was started unless a path is specified.
contents_of_xml_file The XML script enclosed in single quotations.

The modification includes adding or deleting disks from an existing diskgroup, and the setting
rebalance power level. The power level can set from 0 to the maximum of 11, the same
values as the ASM_POWER_LIMIT initialization parameter.

When adding disks to a diskgroup, the diskstring must be specified in a format similar to the
ASM_DISKSTRING initialization parameter.

The failure groups are optional parameters. The default causes every disk to belong to a its
own failure group.

Dropping disks from a diskgroup can be performed through this operation. An individual disk
can be referenced by its Oracle ASM disk name. A set of disks that belong to a failure group
can be specified by the failure group name.

We can resize a disk inside a diskgroup with chdg. The resize operation fails if there is not
enough space for storing data after the resize.

Tags for the chdg XML Configuration Template


<chdg> update disk clause (add/delete disks/failure groups)
name diskgroup to change
power power to perform rebalance

<add> items to add are placed here</add>

<drop> items to drop are placed here</drop>

<fg> failure group


name failure group name
</fg>

<dsk> disk
name disk name
path disk path
size size of the disk to add
</dsk>
</chdg>

The following is an example of an XML configuration file for chdg. This XML file alters the
diskgroup named data. The failure group fg1 is dropped and the disk data_0001 is also
dropped. The /dev/disk8 disk is added to failure group fg2. The rebalance power level is set to
4.
<chdg name="data" power="4">
<drop>
<fg name="fg1"></fg>
<dsk name="data_0001"/>
</drop>
<add>
<fg name="fg2">
<dsk string="/dev/disk8"/>
</fg>
</add>
</chdg>

The following are examples of the chdg command with the configuration file or configuration
information on the command line.
ASMCMD [+] > chdg data_config.xml

ASMCMD [+] > chdg '<chdg name="data" power="3">


<drop><fg name="fg1"></fg><dsk name="data_0001"/></drop>
<add><fg name="fg2"><dsk string="/dev/disk5"/></fg></add></chdg>'

SQL equivalent for chdg command is:


SQL> ALTER DISKGROUP diskgroup_name ... ;
dropdg command
Drops an existing diskgroup. The diskgroup cannot be mounted on multiple nodes.
dropdg [-r] [-f] diskgroup

Flag Description
-f Force the operation. Only applicable if the diskgroup cannot be mounted.
-r Recursive, include contents.
diskgroup Name of diskgroup to drop.

The first example forces the drop of the diskgroup dg_data, including any data in the
diskgroup.
ASMCMD [+] > dropdg -r -f dg_data

The second example drops the diskgroup dg_fra, including any data in the diskgroup.
ASMCMD [+] > dropdg -r dg_fra

SQL equivalent for dropdg command is:


SQL> DROP DISKGROUP diskgroup_name ... ;

chkdg command
Checks or repairs the metadata of a diskgroup. chkdg checks the metadata of a diskgroup for
errors and optionally repairs the errors.
chkdg [--repair] diskgroup

The following is an example of the chkdg command used to check and repair the dg_data
diskgroup.
ASMCMD [+] > chkdg --repair dg_data

SQL equivalent for chkdg command is:


SQL> ALTER DISKGROUP diskgroup_name CHECK ... ;

mount command
Will mount the specified diskgroups. This operation mounts one or more diskgroups. A
diskgroup can be mounted with or without force or restricted options.
mount [--restrict] {[-a] | [-f] diskgroup[,diskgroup,...]}

Flag Description
--restrict Mounts in restricted mode.
-a Mounts all diskgroups.
-f Forces the mount operation.
diskgroup Name of the diskgroup.

The following are examples of the mount command showing the use of the force, restrict, and
all options.
ASMCMD [+] > mount -f data

ASMCMD [+] > mount --restrict data

ASMCMD [+] > mount -a

SQL equivalentfor mount command is:


SQL> ALTER DISKGROUP diskgroup_name MOUNT;

umount command
Will dismount the specified diskgroup.
umount {-a | [-f] diskgroup}

Flag Description
Dismounts all mounted diskgroups. These disk groups are listed in the output
-a
V$ASM_DISKGROUP view.
-f Forces the dismount operation.
diskgroup Name of the diskgroup.

The first example dismounts all diskgroups mounted on the Oracle ASM instance.
ASMCMD [+] > umount -a

The second example forces the dismount of the data disk group.
ASMCMD [+] > umount -f data

SQL equivalent for umount command is:


SQL> ALTER DISKGROUP diskgroup_name DISMOUNT;

offline command
Offline disks or failure groups that belong to a diskgroup.
offline -G diskgroup {-F failgroup|-D disk} [-t {minutes|hours}]

Flag Description
-G Diskgroup name.
-F Failure group name.
-D Specifies a single disk name.
Specifies the time before the specified disk is dropped as nm or nh, where m specifies minutes and
-t
h specifies hours. The default unit is hours.

When a failure group is specified, this implies all the disks that belong to it should be offlined.

The first example offlines the failgroup1 failure group of the dg_data diskgroup.
ASMCMD [+] > offline -G dg_data -F failgroup1

The second example offlines the data_0001 disk of the dg_data diskgroup with a time of 1.5
hours before the disk is dropped.
ASMCMD [+] > offline -G dg_data -D data_0001 -t 1.5h

SQL equivalent offline command is:


SQL> ALTER DISKGROUP diskgroup_name OFFLINE ...;

online command
Online all disks, a single disk, or a failure group that belongs to a diskgroup.
online {[-a] -G diskgroup|-F failgroup|-D disk} [-w]

Flag Description
-a Online all offline disks in the diskgroup.
-G Diskgroup name.
-F Failure group name.
-D Disk name.
Wait option. Causes ASMCMD to wait for the diskgroup to be rebalanced before returning control to
-w
the user. The default is not waiting.

When a failure group is specified, this implies all the disks that belong to it should be onlined.

The first example onlines all disks in the failgroup1 failure group of the dg_data diskgroup with
the wait option enabled.
ASMCMD [+] > online -G dg_data -F failgroup1 -w

The second example onlines the data_0001 disk in the dg_data diskgroup.
ASMCMD [+] > online -G dg_data -D data_0001

SQL equivalent online command is:


SQL> ALTER DISKGROUP diskgroup_name ONLINE ...;

rebal command
Rebalances a diskgroup. The power level can be set from 0 to 11. A value of 0 disables
rebalancing. If the rebalance power is not specified, the value defaults to the setting of the
ASM_POWER_LIMIT initialization parameter.
rebal [--power power_value] [-w] diskgroup

Flag Description
--power Power setting (0 to 11).
Wait option. Causes ASMCMD to wait for the diskgroup to be rebalanced before returning c
-w
the user. The default is not waiting.
diskgroup Diskgroup name.

The following example rebalances the dg_fra diskgroup with a power level set to 6.
ASMCMD [+] > rebal --power 6 dg_fra

We can determine if a rebalance operation is occurring with the ASMCMD lsop command.
ASMCMD [+] > lsop
Group_Name Dsk_Num State Power
FRA REBAL RUN 6

SQL equivalent rebal command is:


SQL> ALTER DISKGROUP diskgroup_name REBALANCE POWER n;

iostat command
Will display I/O statistics of disks in mounted ASM diskgroups, by using
V$ASM_DISK_IOSTAT.
iostat [-etH] [--io] [--region] [-G diskgroup] [interval]

Flag Description
-e Displays error statistics (Read_Err, Write_Err).
-t Displays time statistics (Read_Time, Write_Time).
-H Suppresses column headings.
--io Displays information in number of I/Os, instead of bytes.
Displays information for cold and hot disk regions (Cold_Reads, Cold_Writes, Hot_R
--region
Hot_Writes).
-G Displays statistics for the diskgroup name.
Refreshes the statistics display based on the interval value (seconds). Use Ctrl-C to sto
interval
interval display.

To see the complete set of statistics for a diskgroup, use the V$ASM_DISK_IOSTAT view.
Attribute Name Description
Group_Name Name of the diskgroup.
Dsk_Name Name of the disk.
Number of bytes read from the disk. If the --io option is entered, then the valu
Reads
number of I/Os.
Number of bytes written from the disk. If the --io option is entered, then the valu
Writes
number of I/Os.
Number of bytes read from the cold disk region. If the --io option is entered,
Cold_Reads
displayed as number of I/Os.
Number of bytes written from the cold disk region. If the --io option is entered,
Cold_Writes
displayed as number of I/Os.
Number of bytes read from the hot disk region. If the --io option is entered,
Hot_Reads
displayed as number of I/Os.
Number of bytes written from the hot disk region. If the --io option is entered,
Hot_Writes
displayed as number of I/Os.
Read_Err Number of failed I/O read requests for the disk.
Write_Err Number of failed I/O write requests for the disk.
I/O time (in hundredths of a second) for read requests for th
Read_Time
TIMED_STATISTICSinitialization parameter is set to TRUE (0 if set to FALSE).
I/O time (in hundredths of a second) for write requests for th
Write_Time
TIMED_STATISTICSinitialization parameter is set to TRUE (0 if set to FALSE).

If a refresh interval is not specified, the number displayed represents the total number of
bytes or I/Os. If a refresh interval is specified, then the value displayed (bytes or I/Os) is the
difference between the previous and current values, not the total value.

The first example displays disk I/O statistics for the data diskgroup in total number of bytes.

ASMCMD> iostat -G DG_DATA


Group_Name Disk_Name Reads Writes
DG_DATA DATA_0010 58486 29183
DG_DATA DATA_0011 4860 18398

The second example displays disk I/O statistics for the data diskgroup in total number of I/O
operations.
ASMCMD [+] > iostat --io -G data
Group_Name Dsk_Name Reads Writes
DATA DATA_0000 2801 34918
DATA DATA_0001 58301 35700
DATA DATA_0002 3320 36345

ASMCMD> iostat -t
Group_Name Disk_Name Reads Writes Read_Time Write_Time
FRA DATA_0099 54601 38411 441.234546 672.694266

SQL equivalent for iostat command is:


SQL> SELECT * FROM V$ASM_DISK_IOSTAT;

setattr command
setattr command will change an attribute of a diskgroup.
setattr -G disk_group attribute_name attribute_value

ASMCMD> setattr -G DG_ASM_FRA compatible.asm 11.2.0.0.0


ASMCMD> setattr -G DG_ASM_DATA compatible.rdbms 11.1.0.0.0
ASMCMD> setattr -G DG_ASM_DATA au_size 2M

SQL equivalent for setattr command is:


SQL> ALTER DISKGROUP disk_group SET ATTRIBUTE attribute_name=attribute_value;

lsattr command
List attributes of a diskgroup, from V$ASM_ATTRIBUTE.
lsattr [-G diskgroup] [-Hlm] [pattern]

Flag Description
-G Diskgroup name.
-H Suppresses column headings.
-l Display names with values.
-m Displays additional information, such as the RO and Sys columns.
pattern Display the attributes that contain pattern expression.
The RO (read-only) column identifies those attributes that can only be set when a diskgroup is
created. The Sys column identifies those attributes that are system-created.

ASMCMD> lsattr -l -G DG_ASM_FRA


Name Value
access_control.enabled FALSE
access_control.umask 066
au_size 1048576
cell.smart_scan_capable FALSE
compatible.asm 11.2.0.0.0
compatible.rdbms 10.1.0.0.0
disk_repair_time 3.6h
sector_size 512

ASMCMD> setattr -G DG_ASM_FRA compatible.rdbms 11.2.0.0.0


ASMCMD> lsattr -l -G DG_ASM_FRA
Name Value
access_control.enabled FALSE
access_control.umask 066
au_size 1048576
cell.smart_scan_capable FALSE
compatible.asm 11.2.0.0.0
compatible.rdbms 11.2.0.0.0
disk_repair_time 3.6h
sector_size 512

ASMCMD [+] > lsattr -l -G fra %compat*


Name Value
compatible.asm 11.2.0.0.0
compatible.rdbms 10.1.0.0.0

SQL equivalent for lsattr command is:


SQL> SELECT * FROM V$ASM_ATTRIBUTE;

lsod command
Lists the open ASM disks.
lsod [-H] [-G diskgroup] [--process process_name] [pattern]

Flag Description
-H Suppresses column header information from the output.
-G Specifies the diskgroup that contains the open disks.
--process Specifies a pattern to filter the list of processes.
pattern Specifies a pattern to filter the list of disks.

The rebalance operation (RBAL) opens a disk both globally and locally so the same disk may
be listed twice in the output for the RBAL process.

The first example lists the open devices associated with the data diskgroup and the LGWR
process.
ASMCMD [+] > lsod -G data --process LGWR
Instance Process OSPID Path
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diska1
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diska2
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diska3
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diskb1
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diskb2
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diskb3
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diskd1

The second example lists the open devices associated with the LGWR process for disks that
match the diska pattern.
ASMCMD [+] > lsod --process LGWR diska
Instance Process OSPID Path
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diska1
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diska2
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diska3

ASMCMD Template Management Commands


mktmpl command
Adds a template to a diskgroup.
mktmpl -G diskgroup [--striping {coarse|fine}]
[--redundancy {high|mirror|unprotected}] [--primary {hot|cold}]
[--secondary {hot|cold}] template

Flag Description
-G Name of the diskgroup.
--striping Striping specification, either coarse or fine.
--redundancy Redundancy specification, either high, mirror, or unprotected.
--primary Intelligent Data Placement specification for primary extents, either hot or cold region.
--secondary Intelligent Data Placement specification for secondary extents, either hot or cold regi
template Name of the template to create.

The following example adds temp_mc template to the dg_data diskgroup. The new template
has the redundancy set to mirror and the striping set to coarse.
ASMCMD [+] > mktmpl -G dg_data --redundancy mirror --striping coarse temp_mc

SQL equivalent for mktmpl command is:


SQL> ALTER DISKGROUP disk_group ADD TEMPLATE template_name ...;

lstmpl command
Lists all templates or the templates for a specified diskgroup.
lstmpl [-Hl] [-G diskgroup] [pattern]

Flag Description
-H Suppresses column headings.
-l Displays all details.
-G Specifies diskgroup name.
pattern Displays the templates that match pattern expression.

The example lists all details of the templates in the dg_data diskgroup.
ASMCMD [+] > lstmpl -l -G dg_data
Group_Name Group_Num Name Stripe Sys Redund PriReg MirrReg
DG_DATA 1 ARCHIVELOG COARSE Y MIRROR COLD COLD
DG_DATA 1 ASMPARAMETERFILE COARSE Y MIRROR COLD COLD
DG_DATA 1 AUTOBACKUP COARSE Y MIRROR COLD COLD
DG_DATA 1 BACKUPSET COARSE Y MIRROR COLD COLD
DG_DATA 1 CHANGETRACKING COARSE Y MIRROR COLD COLD
DG_DATA 1 CONTROLFILE FINE Y HIGH COLD COLD
DG_DATA 1 DATAFILE COARSE Y MIRROR COLD COLD
DG_DATA 1 DATAGUARDCONFIG COARSE Y MIRROR COLD COLD
DG_DATA 1 DUMPSET COARSE Y MIRROR COLD COLD
DG_DATA 1 FLASHBACK COARSE Y MIRROR COLD COLD
DG_DATA 1 MYTEMPLATE FINE N HIGH COLD COLD
DG_DATA 1 OCRFILE COARSE Y MIRROR COLD COLD
DG_DATA 1 ONLINELOG COARSE Y MIRROR COLD COLD
DG_DATA 1 PARAMETERFILE COARSE Y MIRROR COLD COLD
DG_DATA 1 TEMPFILE COARSE Y MIRROR COLD COLD
DG_DATA 1 XTRANSPORT COARSE Y MIRROR COLD COLD

SQL equivalent for lstmpl command is:


SQL> SELECT * FROM V$ASM_TEMPLATE;

chtmpl command
Changes the attributes of a template.
chtmpl -G diskgroup { [--striping {coarse|fine}]
[--redundancy {high|mirror|unprotected}] [--primary {hot|cold}]
[--secondary {hot|cold}]} template

Flag Description
-G Name of the diskgroup.
--striping Striping specification, either coarse or fine.
--redundancy Redundancy specification, either high, mirror, or unprotected.
--primary Intelligent Data Placement specification for primary extents, either hot or cold region
--secondary Intelligent Data Placement specification for secondary extents, either hot or cold reg
template Name of the template to change.

At least one of these options is required: --striping, --redundancy, --primary, or --secondary.

The following example updates temp_hf template of the dg_fra diskgroup. The redundancy
attribute is set to high and the striping attribute is set to fine.
ASMCMD [+] > chtmpl -G dg_fra --redundancy high --striping fine temp_hf

SQL equivalent for chtmpl command is:


SQL> ALTER DISKGROUP disk_group ALTER TEMPLATE template_name ...;

rmtmpl command
Removes a template from a diskgroup.
rmtmpl -G diskgroup template

The following example removes temp_uf template from the dg_data diskgroup.
ASMCMD [+] > rmtmpl -G dg_data temp_uf

SQL equivalentfor rmtmpl command is:


SQL> ALTER DISKGROUP disk_group DROP TEMPLATE template_name ...;

ASMCMD Volume Management Commands


volcreate command
Creates an Oracle ADVM volume in the specified diskgroup.
volcreate -G diskgroup -s size [--column number] [--width stripe_width] [--redundancy {high|
mirror|unprotected}]
[--primary {hot|cold}] [--secondary {hot|cold}] volume
Flag Description
-G Name of the diskgroup containing the volume.
Size of the volume to be created in units of K, M, G, T, P, or E. The unit desig
-s size
appended to the number specified. No space is allowed. For example: 20G
--column Number of columns in a stripe set. Values range from 1 to 8. The default value is 4.
Stripe width of a volume. The value can range from 4 KB to 1 MB, at power-of-two
--width
default of 128 KB.
Redundancy of the Oracle ADVM volume which can be specified for norm
diskgroups. The range of values are as follows: unprotected for non-mirrored redun
--redundancy
double-mirrored redundancy, or high for triple-mirrored redundancy. If redundancy
the setting defaults to the redundancy level of the diskgroup.
--primary Intelligent Data Placement specification for primary extents, either hot or cold region
--secondary Intelligent Data Placement specification for secondary extents, either hot or cold reg
Name of the volume to be created. Can be a maximum of 11 alphanumeric charac
volume
not allowed. The first character must be alphabetic.

When creating an Oracle ADVM volume, a volume device name is created with a unique
Oracle ADVM persistent diskgroup number that is concatenated to the end of the volume
name. The unique number can be one to three digits.

On Linux, the volume device name is in the format volume_name-nnn, such as volume1-123.
On Windows the volume device name is in the format asm-volume_name-nnn, such as asm-
volume1-123.

A successful volume creation automatically enables the volume device.

The volume device file functions as any other disk or logical volume to mount file systems or
for applications to use directly.

The following example creates volume1 in the dg_data diskgroup with the size set to 10
gigabytes.
ASMCMD [+] > volcreate -G dg_data -s 10G --width 64K --column 8 volume1

You can determine the volume device name with the volinfo command.
ASMCMD [+] > volinfo -G dg_data volume1
Diskgroup Name: DATA
Volume Name: VOLUME1
Volume Device: /dev/asm/volume1-123
State: ENABLED
Size (MB): 10240
Resize Unit (MB): 512
Redundancy: MIRROR
Stripe Columns: 8
Stripe Width (K): 64
Usage:
Mountpath:

ASMCMD [+] > volcreate -G dg_fra -s 100M vol2

SQL equivalent for volcreate command is:


SQL> ALTER DISKGROUP disk_group ADD VOLUME volume_name SIZE n;

volinfo command
Displays information about Oracle ADVM volumes.
volinfo {-a | -G diskgroup -a | -G diskgroup volume}
volinfo [--show_diskgroup|--show_volume] volumedevice}

Flag Description
When used without a diskgroup name, specifies all volumes within all diskg
-a
a diskgroup name (-G diskgroup -a), specifies all volumes within that diskgro
-G Name of the diskgroup containing the volume.
volume Name of the volume.
--show_diskgroup Returns only the diskgroup name. A volume device name is required.
--show_volume Returns only the volume name. A volume device name is required.
volumedevice Name of the volume device.

The first example displays information about the volume1 volume in the dg_data diskgroup
and was produced in a Linux environment. The mount path field displays the last mount path
for the volume.
ASMCMD [+] > volinfo -G dg_data volume1
Diskgroup Name: DG_DATA
Volume Name: VOLUME1
Volume Device: /dev/asm/volume1-123
State: ENABLED
Size (MB): 10240
Resize Unit (MB): 512
Redundancy: MIRROR
Stripe Columns: 8
Stripe Width (K): 64
Usage: ACFS
Mountpath: /u01/app/acfsmounts/acfs1

The second example displays information about the asm-volume1 volume in the dg_data
diskgroup and was produced in a Windows environment.
ASMCMD [+] > volinfo -G dg_data -a
Diskgroup Name: DG_DATA
Volume Name: VOLUME1
Volume Device: \\.\asm-volume1-311
State: ENABLED
Size (MB): 1024
Resize Unit (MB): 256
Redundancy: MIRROR
Stripe Columns: 4
Stripe Width (K): 128
Usage: ACFS
Mountpath: C:\oracle\acfsmounts\acfs1

ASMCMD [+] > volinfo -a

SQL equivalent for volinfo command is:


SQL> SELECT * FROM V$ASM_VOLUME;
SQL> SELECT * FROM V$ASM_VOLUME_STAT;

voldelete command
Deletes an Oracle ADVM volume.
voldelete -G diskgroup volume

To successfully execute this command, the local Oracle ASM instance must be running and
the diskgroup required by this command must be mounted in the Oracle ASM instance.
Before deleting a volume, you must ensure that there are no active file systems associated
with the volume.

The following example deletes volume1 from the dg_data diskgroup.


ASMCMD [+] > voldelete -G dg_data volume1

SQL equivalent for voldelete command is:


SQL> ALTER DISKGROUP disk_group DROP VOLUME volume_name;

voldisable command
Disables Oracle ADVM volumes in mounted diskgroups and removes the volume device on
the local node.
voldisable {-a | -G diskgroup -a | -G diskgroup volume}
Flag Description
When used without a diskgroup name, specifies all volumes within all diskgroups.
-a
When used with a diskgroup name (-G diskgroup -a), specifies all volumes within that diskgr
-G Name of the diskgroup containing the volume.
Name of the volume to be operated on. Can be maximum of 30 alphanumeric characters. T
volume
character must be alphabetic.

You can disable volumes before shutting down an Oracle ASM instance or dismounting a
diskgroup to verify that the operations can be accomplished normally without including a force
option due to open volume files. Disabling a volume also prevents any subsequent opens on
the volume or device file because it no longer exists.

Before disabling a volume, you must ensure that there are no active file systems associated
with the volume. You must first dismount the Oracle ACFS file system before disabling the
volume. You can delete a volume without first disabling the volume.

The following example disables volume1 in the dg_data diskgroup.


ASMCMD [+] > voldisable -G dg_data volume1

SQL equivalent for voldisable command is:


SQL> ALTER DISKGROUP disk_group DISABLE VOLUME volume_name;

volenable command
Enables Oracle ADVM volumes in mounted diskgroups. A volume is enabled when it is
created.
volenable {-a | -G diskgroup -a | -G diskgroup volume}

Description
Flag
When used without a diskgroup name, specifies all volumes within all diskgroups.
-a
When used with a diskgroup name (-G diskgroup -a), specifies all volumes within that diskg
-G Name of the diskgroup containing the volume.
volume Name of the volume to be operated on.

The following example enables volume1 in the dg_data diskgroup.


ASMCMD [+] > volenable -G dg_data volume1

SQL equivalent for volenable command is:


SQL> ALTER DISKGROUP disk_group ENABLE VOLUME volume_name;

volresize command
Resizes an Oracle ADVM volume.
volresize -G diskgroup -s size [-f] volume

Flag Description
-G Name of the diskgroup containing the volume.
Force the shrinking of a volume that is not an Oracle ACFS volume to suppress the
-f
message.
volume Name of the volume to be operated on.
-s New size of the volume in units of K, M, G, or T.

If the volume is mounted on a non-Oracle ACFS file system, then dismount the file system
first before resizing. If the new size is smaller than current, you are warned of possible data
corruption. Unless the -f (force) option is specified, you are prompted whether to continue with
the operation.

If there is an Oracle ACFS file system on the volume, then you cannot resize the volume with
the volresize command. You must use the acfsutil size command, which also resizes the
volume and file system.

The following is an example of the volresize command that resizes volume1 in the dg_data
diskgroup to 20 gigabytes.
ASMCMD [+] > volresize -G dg_data -s 20G volume1

SQL equivalent for volresize command is:


SQL> ALTER DISKGROUP disk_group RESIZE VOLUME volume_name SIZE n;

volset commnad
Sets attributes of an Oracle ADVM volume in mounted diskgroups.
volset -G diskgroup [--usagestring string] [--mountpath mount_path] [--primary {hot|cold}] [--
secondary {hot|cold}] volume

Flag Description
-G Name of the diskgroup containing the volume.
Optional usage string to tag a volume which can be up to 30 characters. This str
--usagestring
when the volume is attached to an Oracle ACFS file system and should not be ch
--mountpath Optional string to tag a volume with its mount path string which can be up to 102
string is set when the file system is mounted and should not be changed.
--primary Intelligent Data Placement specification for primary extents, either hot or cold reg
--secondary Intelligent Data Placement specification for secondary extents, either hot or cold r
volume Name of the volume to be operated on.

When running the mkfs command to create a file system, the usage field is set to ACFS and
mountpath field is reset to an empty string if it has been set. The usage field should remain at
ACFS.

When running the mount command to mount a file system, the mountpath field is set to the
mount path value to identify the mount point for the file system. After the value is set by the
mount command, the mountpath field should not be updated.

The following is an example of a volset command that sets the usage string for a volume that
is not associated with a file system.
ASMCMD [+] > volset -G dg_arch --usagestring 'no file system created' volume1
ASMCMD [+] > volset -G dg_data --usagestring 'acfs' volume1

SQL equivalent for volset command is:


SQL> ALTER DISKGROUP disk_group MODIFY VOLUME volume_name USAGE
'usage_string;

volstat command
Reports I/O statistics for Oracle ADVM volumes.
volstat [-G diskgroup] [volume]

The following apply when using the volstat command.


 If the diskgroup is not specified and the volume name is specified, all mounted
diskgroups are searched for the specified volume name.
 If the diskgroup name is specified and the volume name is omitted, all volumes are
displayed for the named diskgroup.
 If both the diskgroup name and the volume name are omitted, all volumes on all
diskgroups are displayed.

The following is an example of the volstat command that displays information about volumes
in the dg_data diskgroup.
ASMCMD [+] > volstat -G dg_data
DISKGROUP NUMBER / NAME: 1 / DG_DATA
---------------------------------------
VOLUME_NAME
READS BYTES_READ READ_TIME READ_ERRS
WRITES BYTES_WRITTEN WRITE_TIME WRITE_ERRS
-------------------------------------------------------------
VOLUME1
10085 2290573312 22923 0
1382 5309440 1482 0

SQL equivalent for volstat command is:


SQL> SELECT * FROM V$ASM_VOLUME_STAT;

ASMCMD File Management Commands

lsof command
Lists the open files of the local clients.
lsof [-H] {-G diskgroup|--dbname db|-C instance}

Flag Description
-H Suppresses column headings.
-G List files only from this specified disk group.
--dbname List files only from this specified database.
-C List files only from this specified instance.

ASMCMD [+] > lsof -G dg_data


DB_Name Instance_Name Path
orcl orcl +dg_data/orcl/controlfile/current.260.691577263
orcl orcl +dg_data/orcl/datafile/example.265.691577295
orcl orcl +dg_data/orcl/datafile/sysaux.257.691577149
orcl orcl +dg_data/orcl/datafile/system.256.691577149
orcl orcl +dg_data/orcl/datafile/undotbs1.258.691577151
orcl orcl +dg_data/orcl/datafile/users.259.691577151
orcl orcl +dg_data/orcl/onlinelog/group_1.261.691577267
orcl orcl +dg_data/orcl/onlinelog/group_2.262.691577271
orcl orcl +dg_data/orcl/onlinelog/group_3.263.691577275
orcl orcl +dg_data/orcl/tempfile/temp.264.691577287

ASMCMD [+] > lsof -C +ASM


DB_Name Instance_Name Path
asmvol +ASM +data/VOLUME1.271.679226013
asmvol +ASM +data/VOLUME2.272.679227351

Other file management commands are


cd, cp, du, find, ls, mkalias, pwd, rm, rmalias
asmcmd command line history
The asmcmd utility does not provide command history with the up-arrow key. With rlwrap
utility installed, that can be done by adding the following entry to the oracle user’s profile file:
alias asmcmd='rlwrap asmcmd'

Oracle ASM Interview Questions/FAQs

Oracle ASM Interview Questions/FAQs

1. What is the use of ASM(or) Why ASM preferred over filesystem?


ASM provides striping and mirroring.

2. What are the init parameters related to ASM?


INSTANCE_TYPE = ASM
ASM_POWER_LIMIT = 11
ASM_DISKSTRING = '/dev/rdsk/*s2', '/dev/rdsk/c1*'
ASM_DISKGROUPS = DG_DATA, DG_FRA

3. What is rebalancing (or) what is the use of ASM_POWER_LIMIT?


ASM_POWER_LIMIT is dynamic parameter, which will be useful for rebalancing the data
across disks.
Value can be 1(lowest) to 11 (highest).

4. What are different types of redundancies in ASM& explain?


External redundancy,
Normal redundancy,
High redundancy.

5. How to copy file to/from ASM from/to filesystem?


By using ASMCMDcp command

6. How to find out the databases, which are using the ASM instance?
ASMCMD> lsct
SQL> select DB_NAME from V$ASM_CLIENT;

7. What are different types of stripings in ASM & their differences?


Fine-grained striping
Coarse-grained striping
lsdg
select NAME,ALLOCATION_UNIT_SIZE from v$asm_diskgroup;
8. What is allocation unit and what is default value of au_size and how to change?
Every ASM disk is divided into allocation units (AU). An AU is the fundamental unit of
allocation within a disk group. A file extent consists of one or more AU. An ASM file consists of
one or more file extents.
CREATE DISKGROUP disk_group_2 EXTERNAL REDUNDANCY DISK '/dev/sde1'
ATRRIBUTE 'au_size' = '32M';

9. What are the background processes in ASM?

10. What process does the rebalancing?


RBAL, ARBn

11. How to add/remove disk to/from diskgroup?

S-ar putea să vă placă și