Manage ASM Diskgroup commands in Oracle ASM
Check ASM Disk Attribute with V$ASM_ATTRIBUTE
SELECT name, value FROM V$ASM_ATTRIBUTE WHERE (name = 'sector_size' OR name = 'logical_sector_size') AND group_number = 1;
SELECT logical_sector_size, sector_size FROM V$ASM_DISKGROUP WHERE group_number = 1;
Alter or modify disk attribute=
ALTER DISKGROUP data2 SET ATTRIBUTE 'compatible.asm' = '12.2', 'compatible.rdbms' = '12.2';
ALTER DISKGROUP data2 SET ATTRIBUTE 'sector_size'='4096', 'logical_sector_size'='4096';
Create a disk group with command in Normal redundancy
Note: All disks in the disk group must be of equal size
CREATE DISKGROUP data NORMAL REDUNDANCY
FAILGROUP controller1 DISK
'/devices/diska1' NAME diska1,
'/devices/diska2' NAME diska2
FAILGROUP controller2 DISK
'/devices/diskb1' NAME diskb1,
'/devices/diskb2' NAME diskb2
ATTRIBUTE 'au_size'='4M',
'compatible.asm' = '18.0',
'compatible.rdbms' = '18.0',
'compatible.advm' = '18.0';
Adding Disks to a Disk Group
Note: the disk must be the same size as the other disks in the disk group.
-- Add disk to already present disk-group only candidate disk are able to add.
ALTER DISKGROUP data1 ADD DISK
'/devices/diska5' NAME diska5,
'/devices/diska6' NAME diska6;
-- Add disk with rebalance operation with wait clause. It will not return until balance operation completed
ALTER DISKGROUP data1 ADD DISK '/devices/diskd*' REBALANCE POWER 5 WAIT;
-- For add multiple disk withh naming conventions.
ALTER DISKGROUP data1 ADD DISK '/devices/diska*';
--FORCE option to add the disk as a member of another disk group. If disk is not mounted then only it move to another diskgroup.
ALTER DISKGROUP data2 ADD DISK '/devices/diskc3' FORCE;
Replacing Disks in Disk Groups
Note: More efficient then drop or add disk in disk-group
-- Replace disk diska2 with diska6
ALTER DISKGROUP data1 REPLACE DISK diska2 WITH '/devices/diska6' POWER 4;
Wait or no wait clause let you decide return back or not.
Renaming Disks in Disk Groups
-- Open disk-group in restricted mode
ALTER DISKGROUP DATA2 MOUNT RESTRICTED;
-- Rename the disk in disk group
ALTER DISKGROUP data2 RENAME DISK 'diska1' TO 'diskb1','diska2' TO 'diskb2';
Drop the disk from disk-group
-- Drop the disk if all other disk have less space then this disk drop operation is failed.
ALTER DISKGROUP data1 DROP DISK diska5;
-- Droping and adding is done in one command to avoid overhead for rebalance operation.
ALTER DISKGROUP data1 DROP DISK diska5
ADD FAILGROUP failgrp1 DISK '/devices/diska9' NAME diska9
Resizing Disks in Disk Groups
Resize operation is placed for all disk in disk-group to keep all disk size equal.
If size is increasing then it immediately allocation to disk-group.
If it decreasing then rebalance operation take placed and move data to other available space to make size upto that level.
ALTER DISKGROUP data1 RESIZE ALL SIZE 100G;
UNDROP DISK in Disk Groups
it enable you to cancel all pending drops of disks within disk groups.
-- command cancel the operation of dropping going on disk group data1. If not completed.
ALTER DISKGROUP data1 UNDROP DISKS;