Managing ASM Disk Groups
- Brian Washington

- Aug 25, 2020
- 6 min read
The OEM Database Control is the best tool for performing most ASM tasks, including creating a disk group. Using the Disk Group Administration page, you can select redundancy levels, disk-group names, and lists of disks that are members of a disk group. Once you create disk groups, the ASM instance will mount them each time you start the instance, and you won’t receive the ORA-15110 error (“No diskgroups mounted”) as you did when you first started the ASM instance.
You can also create a disk group with the CREATE DISKGROUP command. Suppose you have three disk controllers and twelve disks. The first four disks are on a separate controller from the second four disks, and so on. You could create three failure groups, each of which has four disks. To start with, you need to start the ASM instance in nomount mode. (If you want to access existing disk groups, you have to use mount mode.) You can then create the disk groups corresponding with the three groups. To do so, you would issue the CREATE DISKGROUP command, as shown in Listing 17-6.
Listing 17-6. Creating Disk Groups with the CREATE DISKGROUP Command
$ sqlplus /nolog
SQL> CONNECT / AS SYSDBA
Connected to an idle instance.
SQL> STARTUP NOMOUNT
SQL> CREATE DISKGROUP group1 HIGH REDUNDANCY 2
2 failgroup group1 disk
3 '/devices/disk1',
4 '/devices/disk2',
5 '/devices/disk3',
6 '/devices/disk4',
7 failgroup group2 disk
8 '/devices/disk5',
9 '/devices/disk6',
10 '/devices/disk7',
11 '/devices/disk8',
12 failgroup group3 disk
13 '/devices/disk9',
14 '/devices/disk10',
15 '/devices/disk11',
16 '/devices/disk12';
SQL> In order to find the disks, Oracle uses a search string in the following format:
/devices/diskname
The FAILGROUP and REDUNDANCY keywords are optional, but if you omit FAILGROUP, each disk in the group will be in its own failure group. Specifying the HIGH REDUNDANCY setting creates the following setup:
• There are three failure groups, each defined by FAILGROUP (you must have at least three failure groups to specify HIGH REDUNDANCY).
• Each failure group has four disks.
• Oracle writes data simultaneously to all three disks in the three failure groups.
Adding Disks to a Disk Group
The ALTER DISKGROUP command can be used to add a new disk, as shown here:
SQL> ALTER DISKGROUP group1 ADD DISK
'/devices/disk5' name disk5,
'/devices/disk6' name disk6;
Dropping Disks and Disk Groups
The ALTER DISKGROUP command can be used to drop a disk, as shown here:
SQL> ALTER DISKGROUP group1 DROP DISK disk5; You can use the following command to remove a disk group, after putting the database in the MOUNT state:
SQL> DROP DISKGROUP group1 INCLUDING CONTENTS; The UNDROP clause keeps a pending DROP DISK command from happening. If the disk has already dropped, there is no way for you to retrieve it, even using UNDROP.
The optional FORCE clause means you can’t use the UNDROP clause and you can never UNDROP a whole disk group. Here’s an example of the UNDROP clause:
SQL> ALTER DISKGROUP group1 UNDROP DISKS; This cancels the pending drop of all disks from the group1 disk group.
Rebalancing Disk Groups
When ASM rebalances a disk group, it does so automatically and dynamically. It does this whenever you change the status of a disk in a disk group, whether you are adding or removing a disk from the disk group—it attempts to maintain an I/O balance across all the disks in a disk group. So, when you add or remove disks, you disturb the I/O balance, but ASM sets it right automatically by moving data appropriately for the space you added or removed.
■Note Since there will be a performance hit on your system while ASM rebalances a disk group, you should consolidate the times when you add and remove disks so that you reduce the number of times that ASM has to rebalance.
You can also manually rebalance the disk groups if you wish, using the following command; you can assign a value of 1 through 11 for the POWER clause:
SQL> ALTER DISKGROUP dgroup1 REBALANCE POWER 5; The POWER clause specifies how fast ASM performs the REBALANCE command. Setting the POWER clause high increases the speed of the rebalancing. The default is 1 (the default value for the ASM_POWER_LIMIT parameter). Specifying POWER means you are overriding the value you assigned to the ASM_POWER_LIMIT initialization parameter when you started the ASM instance. Of course, it would be nice to rebalance disks quickly rather than slowly, but due to the overhead involved, there’s a trade-off between rebalancing speed and database performance.
Managing ASM Files
The datafiles you create in a regular database aren’t like the ones in an ASM setup. ASM file management takes over your normal operating system files, which become ASM files and, when you create a new datafile, control file, or redo log, you simply specify an ASM group and not an operating system filename.
So, to create a new tablespace on an ASM disk group, you would run a command like the following:
SQL> CREATE TABLESPACE tbsp1 DATAFILE '+group1';
In this example, DATAFILE takes a file type (DATAFILE), which indicates that we’re going to use the file as a datafile. Here, CREATE TABLESPACE works with a disk group and not with a disk in that group. Note that we don’t even refer to a datafile.
The ASM system does indeed create a datafile, though it doesn’t compare to regular datafiles. ASM spreads its files across every disk in the disk group, so you can’t rely on a backup of a single disk to hold the entire datafile.
It should also be noted that ASM files have a permanent redundancy level and striping policy, which is different from normal datafiles.
ASM files are OMF files, and Oracle will remove them when you don’t need them. Note that if you give an ASM file a user alias, Oracle doesn’t consider that file an OMF file, so it can’t automatically delete it.
■Note Administrative files such as trace files, audit files, alert logs, tar files, and core files can’t be on an ASM file system.
ASM filenames are stored in control files and the RMAN recovery catalog, the same way filenames of regular operating system–based files or OMF-based files are.
Types of ASM Filenames
ASM naming conventions depend on whether you’re creating a new file, or referring to an existing file. Here are the usage guidelines for the different file-naming conventions:
• Fully qualified ASM filenames are used when referencing existing ASM files (for example,
+dgroupA/db2/controlfile/CF.123.456789).
• Numeric ASM filenames are also only used when referencing existing ASM files (for example, +dgroupA.123.456789).
• Alias ASM filenames employ user-friendly names and are used when you create new files, as well as when you refer to existing files (for example, +dgroupA/myfiles/control_file1).
• Alias filenames with templates are strictly for creating new ASM files (for example, +dgroupA/config1(spfile)).
• Incomplete ASM filenames consist of a disk group name only and are used only for file creation. Incomplete ASM filenames may be used with or without a template (for example, here is an incomplete filename with a template: +dgroupA(datafile)).
Creating Diskgroup Directories for Alias Filenames
The fully qualified filenames in a disk group are held in a hierarchical directory structure. To use aliases, you have to create a directory structure to support the alias naming conventions. The following example shows how to create a hierarchical directory for a disk group named dgroup1:
SQL> ALTER DISKGROUP dgroup1 ADD DIRECTORY '+dgroup1/dir1'; After creating the +dgroup1/dir1 directory, you can create alias ASM filenames, such as +dgroup1/dir1/control_file1, for example.
Using Templates with Aliases
Templates are used to apply a set of file attributes, like those referring to file mirroring and striping, to each of the files created in a disk group. There are default templates for each file type (datafile, control file, and so on), and you can create custom file templates.
■Note Templates are discussed in detail in the “ASM File Templates” section of this chapter.
Using a template, you can create an alias ASM filename when you create a new file. Here’s the syntax of a template-based alias ASM filename: diskgroup/alias(template)
And here’s an example:
dgroup1/config1(spfile)
Adding and Dropping Aliases
If you create a file and don’t use an alias, you can later add an alias with the ADD ALIAS or RENAME ALIAS clauses of the ALTER DISKGROUP statement. The following example replaces a fully qualified ASM filename with an alias:
SQL> ALTER DISKGROUP dgroup1 ADD ALIAS '+dgroup1/dir/second.dbf'
FOR '+dgroup2/ datafile/table.763.1'; To delete an alias, use the DROP ALIAS clause.
Dropping Files from a Disk Group
ASM files are often OMF files, but you may sometimes want to use your own aliases for some ASM files. If you use your own aliases, Oracle won’t automatically delete the aliases when there is a need to do so. To accomplish this, you have to use ALTER DISKGROUP . . . DROP FILE to delete them:
SQL> ALTER DISKGROUP dgroup1 DROP FILE '+dgroup1/payroll/compensation.dbf'; Working with ASM Filenames
Here’s a brief summary of ASM filename usage:
• When referring to an existing file, use a fully qualified name, a numeric name, or an alias. This cannot be an alias with a template, or an incomplete filename with or without a template.
• When creating a single file, use any filename, but not a fully qualified filename.
• When creating multiple files, only use incomplete filenames or incomplete filenames with templates.
You must avoid using ASM filenames if you can, since one of the main goals in using ASM is to simplify file management by just referring to the disk groups instead.

Comments