How to manage ASM (Automatic Storage Management) disks in Oracle
ASM is used by Oracle to manage the disk groups and disk groups used to store the data files. It will help to manage the disk groups and
provide the feature of ASM for striping and mirroring to provide balanced performance and security to the storage. ASM is managed with an ASM instance.
ASM instance is like the Oracle database instance, it only allocates memory structure in the RAM area it does not have its own database, it will use information from its PFILE or SPFILE.
When you add or remove disks from a disk group, Oracle ASM automatically redistributes the data.
A few points for configuring ASM:
1. All ASM disks in a disk group have similar storage performance and availability. If one disk is slow causes an I/O bottleneck.
2. ALL ASM disks in a disk group have the same capacity to maintain balance because it distributes data according to capacity.
In 11g, ASM introduced two compatibility attributes that determine the version of the ASM and database software that can use specific disk groups
COMPATIBLE.ASM – The minimum version of the ASM software that can access the disk group default setting is 10.1.
COMPATIBLE.RDBMS – minimum COMPATIBLE database initialization parameter setting for any database instance that uses the disk group default setting is 10.1.
Check compatibility of ASM and Database
SELECT group_number, name, compatibility, database_compatibility FROM v$asm_diskgroup;
SELECT software_version ,compatible_version FROM v$asm_client;
PFILE Parameters:
INSTANCE_TYPE: ASM or RDBMS, let you know instance is of ASM or Database
DB_UNIQUE_VALUE: +ASM, Global unique name for the database. but in this case it name of automatic storage management
ASM_POWER_LIMIT: value from 1 to 11, used for rebalance operation after storage configuration changes, such as when you add, drop, or resize disks. The default value is 1, it represents the speed with which rebalancing operations occur.
ASM_DISKGROUPS: diskgroup1,diskgroup2 List of diskgroups which is mounted automatically at startup. you can set it manually after instance startup “ALTER SYSTEM SET ASM_DISKGROUPS = DISKGRP1, DISKGRP2;”
ASM_DISKSTRING: initialization parameter specifies its discovery strings like ASM_DISKSTRING = ‘/dev/rdsk/*disk3’, ‘/dev/rdsk/*disk4’ wildcard character is used for discovery disk. Only disks that match one of the strings are discovered.
The default value is NULL, NULL value causes Oracle ASM to search a default path for all disks in the system to which the Oracle ASM instance has read and write access.
Start the ASM instance in Oracle
1. You have the file for starting the ASM.
create spfile from pfile;
2. Start the ASM in no-mount state as a database
Note: ASM instance is started
startup nomount
3. For mount the ASM disk group which is present in the ASM_DISKGROUPS parameter in SPFILE or PFILE.
alter database mount;
Stop Or Shutdown the ASM instance in Oracle
Shut down the instance as the normal database with the shutdown command.
SHUTDOWN
--The ASM instance waits for all connected ASM instances and SQL sessions to exit then shuts down.
SHUTDOWN iMMEDIATE
--The ASM instance waits for any SQL transactions to complete then shuts down. It doesn't wait for sessions to exit.
Disks group is configured with CREATE or ALTER DISKGROUP statement, you have the following option to choose the redundancy level of disk groups:
EXTERNAL REDUNDANCY means no mirroring for the disks. They may be protected at hardware level mirroring RAID or customer no need of mirroring
NORMAL REDUNDANCY means two-way mirroring, requiring two failure groups to configure the disk in normal redundancy mode.
HIGH REDUNDANCY means three-way mirroring and requires three failure groups for mirroring the data in high redundancy.
Following are the useful commands used in ASM:
Create the disk group of EXTERNAL Redundancy
CREATE DISKGROUP diskgroup1 EXTERNAL REDUNDANCY
FAILGROUP failuregroup1 DISK
'/raw/devices/diska1' NAME diska1,
'/raw/devices/diska2' NAME diska2
Create the disk group of Normal Redundancy:
CREATE DISKGROUP diskgroup2 NORMAL REDUNDANCY
FAILGROUP failuregroup1 DISK
'/raw/devices/diska1' NAME diska1,
'/raw/devices/diska2' NAME diska2
FAILGROUP failuregroup2 DISK
'/raw/devices/diskb1' NAME diskb1,
'/raw/devices/diskb2' NAME diskb2;
Create the disk group of High Redundancy
CREATE DISKGROUP diskgroup3 high REDUNDANCY
FAILGROUP failuregroup1 DISK
'/raw/devices/diska1' NAME diska1,
'/raw/devices/diska2' NAME diska2
FAILGROUP failuregroup2 DISK
'/raw/devices/diskb1' NAME diskb1,
'/raw/devices/diskb2' NAME diskb2;
FAILGROUP failuregroup3 DISK
'/raw/devices/diskc1' NAME diskc1,
'/raw/devices/diskc2' NAME diskc2;
Check the ASM disk group present in Oracle
SELECT name, failgroup FROM v$asm_disk;
NAME FAILGROUP
-------------- ---------------
diska1 failuregroup1
diska2 failuregroup1
Mount or dismount the disk group with sqlplus
ALTER DISKGROUP diskgroup1 DISMOUNT;
ALTER DISKGROUP diskgroup1 MOUNT;
ALTER DISKGROUP diskgroup1 MOUNT FORCE;
-- For all disk mounted
ALTER DISKGROUP ALL DISMOUNT;
ALTER DISKGROUP ALL MOUNT;
Drop the ASM disk group
DROP DISKGROUP diskgroup1 INCLUDING CONTENTS;
Add or Remove the data file from the disk group of ASM
Note: During adding or removing please note all disk sizes should be equal and the rebalance operation performed may cause performance issues at that time.
-- Add disks in diskgroup
ALTER DISKGROUP diskgroup2 ADD DISK
'/raw/devices/diska3',
'/raw/devices/diska4';
-- Drop a disk from diskgroup
ALTER DISKGROUP diskgroup2 DROP DISK diska1;
Resize the disk or disk group all disk
-- Resize a specific disk of a disk group
ALTER DISKGROUP diskgroup1 RESIZE DISK diska1 SIZE 10G;
-- Resize all disks in a failure group.
ALTER DISKGROUP diskgroup1 RESIZE DISKS IN FAILGROUP failuregroup1 SIZE 10G;
-- Resize all disks in a disk group may it present more than one failure group it will do for all.
ALTER DISKGROUP diskgroup1 RESIZE ALL SIZE 10G;
Check the consistency or integrity of the Disk group
ALTER DISKGROUP data1 CHECK ALL;
Check the ASM Disk Information or view ASM_DISK
FORMER Disk: The disk assigned to the disk group and then dropped from the disk group is the former disk
CANDIDATE Disk: discovered disk but not assigned to disk group is candidate disk
MEMBER Disk: A disk that belongs to a disk group is a member disk.
SQL> SELECT name, header_status, path FROM V$ASM_DISK WHERE path LIKE '/devices/disk0%';
NAME HEADER_STATUS PATH
--------- ------------- ---------------------
FORMER /raw/devices/disk01
FORMER /raw/devices/disk02
CANDIDATE /raw/devices/disk03
DISK04 MEMBER /raw/devices/disk04
DISK05 MEMBER /raw/devices/disk05
DISK06 MEMBER /raw/devices/disk06
Check the size of the ASM diskgroup
SELECT name, type, total_mb, free_mb, required_mirror_free_mb,
usable_file_mb FROM V$ASM_DISKGROUP;
Note: Column descriptions
TOTAL_MB column is the total usable capacity of a disk group in megabytes.
FREE_MB column is the unused capacity of the disk group in megabytes
REQUIRED_MIRROR_FREE_MB column is the amount of space that need to be available in a diskgroup to restore full redundancy after the failure tolerated without adding additional storage.
USABLE_FILE_MB column is the amount of free space used for adjusted mirroring for new files to restore redundancy after a disk failure.