Wednesday, April 3, 2013

Automatic Storage Management (ASM) lessons 3

Manually rebalancing disks within ASM is typically not required since ASM will perform
this operation automatically. However, in cases where you might want to have some more
granular control over the disk-rebalance process, you can use the alter diskgroup command
along with the rebalance parameter to manually rebalance ASM disks.

When we discuss rebalancing disks in ASM, we often discuss the power level that is
assigned to that rebalance operation. Setting power with regard to a rebalance operation
really deļ¬nes the urgency of that operation with respect to other operations occurring on
the system (for example, other databases or applications). When a rebalance operation
occurs with a low power (for example, 1, the typical default), then that operation is not
given a high priority on the system As a result, the rebalance operation can take some time.When a higher power setting is used (for example, 11, the maximum), the ASM is given higher priority.

Note: what is re balancing ? 
ASM ensures that file extents are evenly distributed across all disks in a disk group. This is true for the initial file creation and for file resize operations. That means we should always have a balanced space distribution across all disks in a disk group.

You can set the default power limit for the ASM instance by changing the asm_power_limit parameter. Here is an example of starting a manual rebalance of a disk group:

SQL> alter diskgroup cooked_dgroup1 rebalance power 5 wait;

In this example, you will notice that we used the wait parameter. This makes this rebalance operation synchronous for our session. Thus, when the SQL prompt returns, we know that the rebalance operation has completed. The default is nowait, which will cause the operation to be synchronous in nature. You can check the status of the rebalance operation using the V$ASM_OPERATION view during asynchronous rebalance operations.

Finally, you can also use the rebalance parameter along with the power parameter when
adding, dropping, or resizing disks within a disk group, as shown in this example:
SQL> alter diskgroup cooked_dgroup1 resize all rebalance power 5;

Note:- ASM automatically initiates a rebalance after storage configuration changes, such as when you add, drop, or resize disks. The power setting parameter determines the speed with which rebalancing operations occur.

Checking the Consistency of a Disk Group
On occasion you might wonder if there is some problem with an ASM disk group, and you
will want to check the consistency of the ASM disk group metadata. This need might arise
because of an error that occurs when the ASM instance is started or as the result of an Oracle database error that might be caused by some ASM corruption. To perform this check, simply use the alter diskgroup command with the check all parameter, as shown in this example:
SQL> alter diskgroup sp_dgroup2 check all;
When you execute the alter diskgroup check all command the results are written to
the alert log of the instance. ASM will attempt to correct any errors that are detected.

Creating ASM Disk Group Directories
When you create an ASM disk group, it includes a system-generated directory structure for
the ASM files that will be stored in that disk group. The system-generated directory structure takes on the following format, where disk_group is the root of the directory hierarchy:
+disk_group/database_name/object_type/ASM_file_name
for Eg, +DATA/oracle/datafile/system.259.724180831
The database name will be the name of the database that the data is associated with. The
object_type is the type of object being stored (for example, datafile) and the ASM_file_
name is the system-generated filename assigned to that ASM file.
ASM allows you to create your own directories within these predefined structures. This
allows you to give alias names to the ASM files that you will create. This can make working
with ASM files easier.
To create a directory structure within a diskgroup, you use the alter diskgroup command with the add directory parameter, as shown in this example:
SQL> ALTER DISKGROUP cooked_dgroup1 ADD DIRECTORY ‘+cooked_dgroup1/stuff’;

Using the ASMCMD Command-Line Utility

The ASMCMD tool is a command-line utility that allows you to manage ASM instances
and the disk structures and files within those instances. With ASMCMD, you can do the
following:
  • List contents of ASM disk groupNN s
  • Perform searches (like directory listings)
  • Add or remove directories
  • Display space availability and utilization 

Starting ASMCMD
To start ASMCMD, simply set your ORACLE_SID to +ASM and then type asmcmd from the
command line, as shown here:
C:\>set ORACLE_SID=+ASM
C:\>asmcmd
Or from Unix:
/opt/oracle>export ORACLE_SID=+ASM
/opt/oracle>asmcmd

Note:- You will need to make sure that perl.exe is in the path before you run ASMCMD. If you have installed more than one ORACLE_HOME, it may take some setup to get the environment to  set correctly. Make sure the following is set to the correct 
ORACLE_HOME, PATH, PERL5LIB,PERLBIN .

ASMCMD Commands
ASMCMD has a basic set of commands, many of which mimic Unix commands. You can
see these commands from the ASMCMD prompt if you type in help. The commands are
pretty straightforward and easy to use.Below Table  lists the different ASMCMD commands
and their purposes. Reference summary of commonly used asmcmd commands:

cd Changes the current directory to the specified directory.

du Displays the total disk space occupied by ASM files in the
specified ASM directory and all its subdirectories, recursively.

exit Exits ASMCMD.

find Lists the paths of all occurrences of the specified name (with
wildcards) under the specified directory.

help Displays the syntax and description of ASMCMD commands.

ls Lists the contents of an ASM directory, the attributes of the
specified file, or the names and attributes of all disk groups.

lsct Lists information about current ASM clients.

lsdg Lists all disk groups and their attributes.

mkalias Creates an alias for a system-generated filename.

mkdir Creates ASM directory.

pwd Displays the path of the current ASM directory.

rm Deletes the specified ASM files or directories.

rmalias Deletes the specified alias, retaining the file that the alias points to.

Overview of ASM Data Dictionary Views


Several data dictionary views exist to help manage ASM. These data dictionary views are available both when connected to the ASM instance as well as any Oracle 10g database. Each view is slightly different in its presentation depending on whether the instance you are looking at is an ASM instance or a database instance (and some views are only used in the ASM instance). The table below shows these views.


View NameDescription
V$ASM_DISKGROUP
In an ASM Instance: This view will describe a given disk group.
In a Database: This view contains a single row for each ASM disk group that is mounted by the local ASM instance.Note that discovery will occur each time you query thisview. This can have performance impacts.
V$ASM_DISK
In an ASM Instance: This view describes each disk that was discovered by the ASM instance. All disks are reported, even those not assigned to disk groups.
In a Database: This view describes each disk that is assigned to that database.Note that discovery will occur each time you query thisview. This can have performance impacts.
V$ASM_DISKGROUP_STAT
This view is equivalent to the V$ASM_DISKGROUP view. However, this view will not cause discovery to occur. This can help with performance, but the data in the view may not be accurate.
V$ASM_FILE
In an ASM Instance: Displays each ASM file contained in the ASM instance.
In a Database: Not used in a database instance.
V$ASM_DISK_STATThis view is equivalent to the V$ASM_DISK view. However, this view will not cause discovery to occur. This can help with performance, but the data in the view may not be accurate.
V$ASM_TEMPLATE
In an ASM Instance: Displays each ASM template contained in the ASM instance by disk group.
In a Database: Not used in a database instance.
V$ASM_ALIAS
In an ASM Instance: Displays each alias contained in the ASM instance by disk group.
In a Database: Not used in a database instance.
V$ASM_OPERATION
In an ASM Instance: Displays each long running operation occurring on the ASM instance.
In a Database: Not used in a database instance
V$ASM_CLIENT
In an ASM Instance: Displays each database that is using at least one disk group managed by the ASM instance.
In a Database: Not used in a database instance.

No comments:

Post a Comment