Performing ASM Operations


This section discusses the important ASM commands that will help you deploy databases using ASM files.

The CREATE DISK GROUP Command

The CREATE DISK GROUP command is used to create a disk group. The ASM instance will verify that the disk in a disk group is addressable and usable before it does any operations on it. It reads the first block of the disk to determine whether it belongs to a group and writes a header to disks not in any group.

When you issue the CREATE DISKGROUP command, ASM mounts the disk group for the first time and adds the disk-group name to the ASM_DISKGROUPS initialization parameter in SPFILE. If you are using the initSID.ora file and need the disk group to be automatically mounted at startup, you have to manually add the disk-group name to the ASM_DISKGROUPS entry in the init file.

Let's use the previous Q0OR10G database as an example throughout this section. ASM_DISKSTRING is set to /dev/*. The following disks are in /dev: /dsk_qa_a01, /dsk_qa_a02, /dsk_qa_b01, /dsk_qa_b02. /dsk_qa_a01 and /dsk_qa_a02 are on separate SCSI controllers from other disks on the server: The following code will create the disk group dskgrp10g01 using two failgroups:

 CREATE DISKGROUP dskgrp10g01 NORMAL REDUNDANCY FAILGROUP fgctl_qa01 DISK '/dev/dsk_qa_a01', '/dev/dsk_qa_a02', FAILGROUP fgctl_qa02 DISK '/dev/dsk_qa_b01', '/dev/dsk_qa_b02' ; 

dskgrp10g01 has four disks belonging to the failure group, fgctl_qa01 or fgctl_qa02. With the NORMAL REDUNDANCY option, ASM provides redundancy for all files in dskgrp10g01 and dskgrp10g02 subject to the attributes given in the disk-group templates, as explained later in this chapter in the section "Using Disk-Group Templates."

Because no names were given to the disks using the NAME clause, the disks will be named dskgrp10g01_0001, dskgrp10g01_0002, dskgrp10g01_0003, and dskgrp10g01_0004 by default.

Other Operations on a Disk Group

Use the ALTER DISKGROUP command to add, drop, or resize any disk(s). This command can be used simultaneously on multiple disks in a single statement. After issuing an ALTER DISKGROUP statement, ASM rebalances the file extents automatically to suit the new disk-group configuration. The rebalancing operation continues even after the ALTER DISKGROUP command completes successfully. The status of this rebalancing task can be viewed from V$ASM_OPERATION.

ADD DISK

If you want to add a diskfor example, /dsk_qa_a03to the dskgrp10g01 disk group, use the ADD DISK clause as follows:

 ALTER DISKGROUP dskgrp10g01 ADD DISK '/dev/dsk_qa_a03'; 

This will add the disk and assign dsk_qa_a03 to its own failgroup, as no other failgroup was specifically mentioned in the command.

If you want to add a few disks (for example, /dsk_qa_c01, /dsk_qa_c02, and /dsk_qa_c03) under another failure group (fgctl_qa03), issue the following command:

 ALTER DISKGROUP dskgrp10g01 NORMAL REDUNDANCY FAILGROUP fgctl_qa03 DISK '/dev/dsk_qa_c*' ; 

DROP DISK

If you want to drop a disk from a disk group, use the DROP DISK command. To drop all disks in a failure group, use the DROP DISKS IN FAILUREGROUP clause of the ALTER DISKGROUP command. When you drop a disk, the files in the dropped disk are moved to other disks in the disk group, and the header entry on the dropped disk is cleared. The disk can be dropped without waiting for the ASM to read or write to the disk through the use of the FORCE clause of the DROP commands (for disk groups made under NORMAL or HIGH REDUNDANCY options).

To drop the disk /dsk_qa_a03 from the dskgrp10g01 disk group, issue this command:

 ALTER DISKGROUP dskgrp10g01 DROP DISK '/dev/dsk_qa_a03' ; 

You can do simultaneous ADD and DROP operations on disk groups. In the next example, we will drop a disk from and add another one to dskgrp10g01 in a single command:

 ALTER DISKGROUP dskgrp10g01 DROP DISK '/dev/dsk_qa_a03' ADD FAILGROUP fgctl_qa04 DISK '/dev/dskd01', '/dev/dskd02'; 

If you change your mind and wish to cancel a DROP operation of all disks in a disk group, use the UNDROP DISKS clause of the ALTER DISKGROUP command. This will cancel all pending DROP DISK operations within a disk group unless the DROP statement has completely finished. UNDROP DISKS will also restore the disks that were being dropped as part of the DROP DISKGROUP or FORCE commands:

 ALTER DISKGROUP dskgrp10g01 UNDROP DISKS; 

RESIZE and REBALANCE Operations

You use the RESIZE clause of ALTER DISKGROUP command to resize a disk or all disks in a disk group or a failure group. The RESIZE option needs a SIZE parameter to complete its operation, or it will resize to the size of the disk as returned by the operating system. The new size from the RESIZE operation is written to the ASM disk header record.

When you resize the disk to a higher size, it is immediately available for utilization. Resizing the disk to a lower size will require the completion of the REBALANCE operation. This operation attempts to reallocate the files among other disks. The RESIZE command will fail if the data extents cannot be successfully transferred and rebalanced. Similarly, the RESIZE command will fail when you try to resize a disk to values higher than the disk capacity.

Suppose that the disks in previous examples were sized at 128GB. To reduce the size of dsk_qa_a01 to 96GB, you would issue the following command:

 ALTER DISKGROUP dskgrp10g01 RESIZE DISK '/dev/dsk_qa_a01' SIZE 96G; 

This command can be modified to reduce the size of all disks under a failgroupsay, fgctl_qa01:

 ALTER DISKGROUP dskgrp10g01 RESIZE DISKS IN FAILGROUP fgctl_qa01 SIZE 96G; 

Manual rebalancing of disks can be done with the REBALANCE clause of the ALTER DISKGROUP command. A manual rebalance is seldom needed unless the DBA feels that the REBALANCE operation is not fast enough.

REBALANCE is an expensive operation and could sometimes crash the ASM instance.


We discussed the ASM_POWER_LIMIT initialization parameter earlier in this chapter. ASM_POWER_LIMIT controls the degree of parallelism for REBALANCE operations. This parameter has a significant impact on the REBALANCE operation of disks.

The POWER clause used along with the REBALANCE operation specifies the parallelism and speed of the REBALANCE operation. To alter the speed of an ongoing REBALANCE operation, change the POWER to a new level. With a POWER value of 0, the REBALANCE operation is stopped until the value is changed.

With a POWER value of 10 and ASM_POWER_LIMIT of 1, the degree of parallelism will not exceed the value of ASM_POWER_LIMIT (1). So the REBALANCE operation is limited by the ASM_POWER_LIMIT initialization parameter. ASM_POWER_LIMIT can be found in the V$ASM_OPERATION view.

An example of a REBALANCE operation with ASM_POWER_LIMIT of 10 and POWER of 5 is given here:

 ALTER DISKGROUP dskgrp10g01 REBALANCE POWER 5; 

In Oracle Database 10g Release 2, the ALTER DISKGROUP REBALANCE operation has an option to use WAIT in the command to halt the REBALANCE operation until a later time. The WAIT option allows a user script to be run to add or remove disks.

Mounting Disk Groups

The disk groups in the ASM_DISKGROUPS initialization parameter are automatically mounted at the ASM instance startup and unmounted when the ASM instance is shut down. ASM will mount the disk group when you create it, and unmount it when you drop it.

The ALTER DISKGROUP...MOUNT (UNMOUNT) command is used for manual operations on disk groups by name or using ALL. For dismounting a disk group with open files, use the FORCE clause of the DISMOUNT operation. See the following examples to dismount a disk group and mount it back:

 ALTER DISKGROUP dskgrp10g01 dismount; ALTER DISKGROUP dskgrp10g01 mount; 

To dismount all the disk groups in our examples (dskgrp10g01 and dskgrp10g02), use the ALL clause as follows:

 ALTER DISKGROUP ALL DISMOUNT; 

Using Disk-Group Templates

A disk-group template is a collection of attributes that are applied to all files created within the disk group. Oracle provides a set of initial default templates for use by ASM, which is listed in v$asm_template view. You can add new templates to a disk group, modify existing ones, or drop existing ones using the ALTER DISKGROUP statement.

The default templates are ARCHIVELOG, AUTOBACKUP, BACKUPSET, CONTROL, DATAFILE, DATAGUARDCONFIG, DUMPSET, FLASHBACK, ONLINELOG, PARAMETERFILE, and TEMPFILE. Refer to Oracle Database Administrators Guide 10g for a detailed explanation of templates and file types.

If you want to add a new template (say, OLTP_DBF_T1) for a disk group, use the ADD TEMPLATE clause of the ALTER DISKGROUP command along with its attributes:

 ALTER DISKGROUP dskgrp10g01 ADD TEMPLATE OLTP_DBF_T1 ATTRIBUTES (MIRROR FINE); 

The ALTER TEMPLATE clause will help to modify existing templates on specified attributes. Unspecified attributes are not modified. When an existing template is modified, new files created using that template will get new attribute values, while existing files continue to retain their old attributes.

For example, if you wish to change the striping for the template OLTP_DBF_T1 from FINE to COARSE, issue the following command:

 ALTER DISKGROUP dskgrp10g01 ALTER TEMPLATE OLTP_DBF_T1 ATTRIBUTES (COARSE); 

Use the DROP TEMPLATE clause to drop an existing template or templates from a disk group. Only user-defined templates can be dropped.

 ALTER DISKGROUP dskgrp10g01 DROP TEMPLATE OLTP_DBF_T1; 

Directory Structure

A disk group uses a hierarchical directory structure with fully qualified filenames (system aliases) along with alias filenames. When you create a new file, the system alias is automatically created by ASM. For more user-friendly aliases, you have to create a directory structure that supports the new naming conventions. The directory path should always begin with a plus (+) sign, followed by subdirectory names separated by forward slash (/) characters.

Use the ADD DIRECTORY clause to create a new directory as follows:

 ALTER DISKGROUP dskgrp10g01 ADD DIRECTORY '+dskgrp10g01/q0testdb'; 

If you want to add a new directory called qateam under q0testdb, use the following command with accurate relative paths:

 ALTER DISKGROUP dskgrp10g01 ADD DIRECTORY '+dskgrp10g01/q0testdb/qateam'; 

To rename this directory, use the RENAME DIRECTORY clause of ALTER DISKGROUP command:

[View full width]

ALTER DISKGROUP dskgrp10g01 RENAME DIRECTORY '+dskgrp10g01/q0testdb/qateam' to '+dskgrp10g01/q0testdb/qausers';

To drop any directory (other than system-created directories), use the DROP DIRECTORY clause. The FORCE clause will drop a directory along with its subdirectories and contents (as in q0testdb):

 ALTER DISKGROUP dskgrp10g01 DROP DIRECTORY '+dskgrp10g01/q0testdb' FORCE; 

With Oracle Database 10g Release 2, when using the ASMCMD utility, files can be accessed directly using a command-line interface.

Alias Names for ASM files

You can add alias names to provide more meaningful names to ASM files in the directories. Use the ADD ALIAS, RENAME ALIAS, or DELETE ALIAS clauses to add, rename, or delete alias names, except for the system alias. Every alias known to the ASM instance is listed in the v$asm_alias view. The system-generated aliases will be specified under the SYSTEM_CREATED column.

To add an alias name for an ASM filename, use the ADD ALIAS clause with full directory path and the new alias:

[View full width]

ALTER DISKGROUP dskgrp10g01 ADD ALIAS '+dskgrp10g01/q0testdb/RTLSALES_TBL01.dbf' FOR ''+dgroup1/qadata/testdb1/retail.472.1';

Use the RENAME ALIAS clause to give the alias another name:

[View full width]

ALTER DISKGROUP dskgrp10g01 RENAME ALIAS '+dskgrp10g01/RTLSALESDB/rtlsldata_1.dbf' FOR ''+dgroup1/qadata/testdb2/retail.472.1' ;

The DELETE ALIAS clause drops the alias name. Dropping an alias does not remove the underlying file on the file system. The following command will drop the alias, but will preserve the file on the system:

 ALTER DISKGROUP dskgrp10g01 DELETE ALIAS '+dskgrp10g01/RTLSALESDB/rtlsldata_1.dbf'; 

To drop the files and associated alias names from a disk group, use the DROP FILE clause of the ALTER DISKGROUP command. You can also substitute the alias name with the system-generated alias.

 ALTER DISKGROUP dskgrp10g01 DROP FILE  '+dskgrp10g01/RTLSALESDB/rtlsldata_1.dbf'; ALTER DISKGROUP dskgrp10g01 DROP FILE  '+dgroup1/qadata/testdb2/retail.472.1'; 

DROP DISKGROUP

You may want to drop an existing ASM disk group and its files for certain reasons. For this purpose, use the DROP DISKGROUP command for the disk group with the INCLUDING CONTENTS clause for its files. The default option for DROP DISKGROUP is EXCLUDING CONTENTS, which will prevent the accidental dropping of a disk group with its contents.

For a DROP operation to succeed, the ASM instance has to be up and running, the disk group has to be mounted, and no files in the disk group should be open. The DROP DISKGROUP command returns the user to the command prompt after the entire action is completed. When the server parameter file is used, the DROP DISKGROUP command will remove the disk-group name from the ASM_DISKGROUPS parameter as well. With init<SID>.ora files, you will have to manually remove the disk group from the ASM_DISKGROUPS parameter after the DROP operation and before the next shutdown of the ASM instance:

 DROP DISKGROUP dskgrp10g01 INCLUDING CONTENTS; 

Checking the Internal Consistency of Disk Groups

When you run any operations to a disk group, you should verify the internal consistency of the disk group metadata using the ALTER DISKGROUP...CHECK command. The only requirement for this consistency check is that the disk group has to be in the mounted state during the checks.

You can run the CHECK operation on specific files, on some or all disks in a disk group, or on specific failure groups in a disk group.

 ALTER DISKGROUP dskgrp10g01 CHECK ALL; 

During the CHECK operation, ASM attempts to correct any errors unless the user specifies a NOREPAIR clause. If there are any errors, they will be displayed and written to an alert log as well.

ASM Implementation in RAC Mode

ASM instances can also be implemented in RAC mode. This would eliminate ASM as a single point of failure. When implemented in RAC mode, failure of one ASM instance will not bring down the rest of the databases. The usual RAC benefitsload balancing, failover, and the likeare available to the ASM instance, along with improved storage management.




    Oracle Database 10g Insider Solutions
    SUSE LINUX Enterprise Server 9 Administrators Handbook
    ISBN: 672327910
    EAN: 2147483647
    Year: 2006
    Pages: 214

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net