Oracle ASM Administration - Diskgroups, Disks & ASMCMD
Oracle ASM Administration - Diskgroups, Disks & ASMCMD
Section titled “Oracle ASM Administration - Diskgroups, Disks & ASMCMD”Oracle Automatic Storage Management (ASM) provides a built-in volume manager and file system designed specifically for Oracle database files. It handles striping, mirroring, rebalancing, and failure group management automatically, eliminating the need for third-party volume managers for Oracle storage. This guide covers day-to-day ASM administration from diskgroup creation through disk replacement and ASMCMD usage.
Architecture Overview
Section titled “Architecture Overview”Core Components
Section titled “Core Components”| Component | Description |
|---|---|
| ASM Instance | A special Oracle instance (no database) that manages diskgroups |
| Diskgroup | A logical storage pool composed of one or more physical disks |
| Failure Group | A subset of disks within a diskgroup representing a single failure domain |
| ASM Disk | A raw block device, partition, or LUN visible to ASM |
| ASM File | An Oracle-managed file within a diskgroup (e.g., datafiles, redo logs) |
| ASMCMD | Command-line utility for navigating ASM file system |
| ASMLIB / AFD | Optional disk stamping layers (ASMLIB on older Linux, ASM Filter Driver on 12.2+) |
Redundancy Types
Section titled “Redundancy Types”| Type | Description | Minimum Disks | Mirrors |
|---|---|---|---|
| EXTERNAL | No ASM mirroring (rely on storage hardware RAID) | 1 | None |
| NORMAL | Two-way mirroring (two failure groups) | 2 | 2x |
| HIGH | Three-way mirroring (three failure groups) | 3 | 3x |
| FLEX | Variable mirroring per file (12.2+) | 3 | 2x or 3x per file |
-- Connect to the ASM instance (not the database instance)-- export ORACLE_SID=+ASM-- sqlplus / as sysasm
-- View diskgroups and their current stateSELECT name, state, type AS redundancy, total_mb, free_mb, ROUND((total_mb - free_mb) / total_mb * 100, 1) AS pct_used, usable_file_mb, required_mirror_free_mb, offline_disks, compatibility, database_compatibilityFROM v$asm_diskgroupORDER BY name;Diskgroup Creation
Section titled “Diskgroup Creation”External Redundancy (Hardware RAID)
Section titled “External Redundancy (Hardware RAID)”-- Single failure group, no ASM mirroringCREATE DISKGROUP DATA_EXT EXTERNAL REDUNDANCY DISK '/dev/sdc', '/dev/sdd', '/dev/sde' ATTRIBUTE 'AU_SIZE' = '4M', 'CELL_SMART_SCAN_CAPABLE' = 'FALSE', 'compatible.asm' = '19.0', 'compatible.rdbms' = '19.0';Normal Redundancy (Two-Way Mirror)
Section titled “Normal Redundancy (Two-Way Mirror)”-- Two failure groups - each group represents one storage controller or shelfCREATE DISKGROUP DATA NORMAL REDUNDANCY FAILGROUP CTRL1 DISK '/dev/sdc' NAME DATA_0001, '/dev/sdd' NAME DATA_0002 FAILGROUP CTRL2 DISK '/dev/sde' NAME DATA_0003, '/dev/sdf' NAME DATA_0004 ATTRIBUTE 'AU_SIZE' = '4M', 'compatible.asm' = '19.0', 'compatible.rdbms' = '19.0';High Redundancy (Three-Way Mirror)
Section titled “High Redundancy (Three-Way Mirror)”CREATE DISKGROUP RECO HIGH REDUNDANCY FAILGROUP CTRL1 DISK '/dev/sdg' NAME RECO_0001 FAILGROUP CTRL2 DISK '/dev/sdh' NAME RECO_0002 FAILGROUP CTRL3 DISK '/dev/sdi' NAME RECO_0003 ATTRIBUTE 'compatible.asm' = '19.0', 'compatible.rdbms' = '19.0';Flex Diskgroup (12.2+)
Section titled “Flex Diskgroup (12.2+)”-- Flex diskgroup allows per-file redundancy selectionCREATE DISKGROUP DATA_FLEX FLEX REDUNDANCY FAILGROUP CTRL1 DISK '/dev/sdj', '/dev/sdk' FAILGROUP CTRL2 DISK '/dev/sdl', '/dev/sdm' FAILGROUP CTRL3 DISK '/dev/sdn', '/dev/sdo' ATTRIBUTE 'compatible.asm' = '12.2', 'compatible.rdbms' = '12.2';Adding and Removing Disks
Section titled “Adding and Removing Disks”Adding Disks to an Existing Diskgroup
Section titled “Adding Disks to an Existing Diskgroup”-- Add disks to expand capacity (triggers rebalance automatically)ALTER DISKGROUP DATA ADD DISK '/dev/sdp' NAME DATA_0005, '/dev/sdq' NAME DATA_0006;
-- Add disks to a specific failure groupALTER DISKGROUP DATA ADD FAILGROUP CTRL1 DISK '/dev/sdp' NAME DATA_0005, FAILGROUP CTRL2 DISK '/dev/sdq' NAME DATA_0006;
-- Add with controlled rebalance power (1=slow, 11=maximum speed)ALTER DISKGROUP DATA ADD DISK '/dev/sdr' NAME DATA_0007 REBALANCE POWER 4;Removing Disks
Section titled “Removing Disks”-- Remove a disk (triggers rebalance to redistribute data)ALTER DISKGROUP DATA DROP DISK DATA_0001;
-- Remove multiple disksALTER DISKGROUP DATA DROP DISK DATA_0001, DATA_0002;
-- Force drop a disk even if it causes imbalance (use with caution)ALTER DISKGROUP DATA DROP DISK DATA_0001 FORCE;
-- Undrop a disk (cancel pending drop before rebalance completes)ALTER DISKGROUP DATA UNDROP DISKS;Replacing a Failed Disk
Section titled “Replacing a Failed Disk”-- Step 1: Identify the failed diskSELECT group_number, disk_number, name, path, mode_status, state, failgroup, total_mb, free_mbFROM v$asm_diskWHERE state != 'NORMAL' OR mode_status != 'ONLINE'ORDER BY group_number, disk_number;
-- Step 2: Drop the failed diskALTER DISKGROUP DATA DROP DISK DATA_FAILED_001;
-- Step 3: After physical replacement, add the new disk-- ASM will automatically detect it if ASM_DISKSTRING covers the pathALTER DISKGROUP DATA ADD FAILGROUP CTRL1 DISK '/dev/sdc' NAME DATA_REPLACEMENT_001;Monitoring Rebalance Operations
Section titled “Monitoring Rebalance Operations”-- Current rebalance operationsSELECT group_number, operation, state, power, actual, sofar, est_work, est_rate, est_minutesFROM v$asm_operationORDER BY group_number;
-- Adjust rebalance power while in progressALTER DISKGROUP DATA REBALANCE POWER 8;
-- Wait for rebalance to complete before proceeding-- Poll this until no rows returned:SELECT * FROM v$asm_operation WHERE operation = 'REBAL';
-- Detailed rebalance progressSELECT dg.name AS diskgroup, op.operation, op.state, op.power, op.sofar, op.est_work, ROUND(op.sofar / NULLIF(op.est_work, 0) * 100, 1) AS pct_done, op.est_minutesFROM v$asm_operation opJOIN v$asm_diskgroup dg ON op.group_number = dg.group_number;Disk Discovery and ASM_DISKSTRING
Section titled “Disk Discovery and ASM_DISKSTRING”Configuring ASM_DISKSTRING
Section titled “Configuring ASM_DISKSTRING”ASM_DISKSTRING controls which device paths ASM scans for candidate disks. An incorrect value means ASM cannot see new disks.
-- Check current ASM_DISKSTRINGSHOW PARAMETER asm_diskstring;
-- Add a new path pattern (do not remove existing patterns)ALTER SYSTEM SET asm_diskstring = '/dev/sd*', '/dev/oracleasm/disks/*' SCOPE = BOTH;
-- Rescan for new disks matching the discovery stringALTER DISKGROUP DATA MOUNT; -- Full remount with rediscovery-- Or simply reference the new path in ADD DISK; ASM scans automatically
-- List all visible disks (including unclaimed ones)SELECT path, name, group_name, mode_status, state, total_mb, free_mb, failgroupFROM v$asm_diskORDER BY group_name, failgroup, name;ASM Compatibility Attributes
Section titled “ASM Compatibility Attributes”Compatibility attributes control which database version can use the diskgroup and what ASM features are available. They can only be advanced, never rolled back.
-- Check compatibility attributesSELECT dg.name, attr.name AS attribute, attr.valueFROM v$asm_diskgroup dgJOIN v$asm_attribute attr ON attr.group_number = dg.group_numberWHERE attr.name IN ('compatible.asm', 'compatible.rdbms', 'au_size', 'sector_size')ORDER BY dg.name, attr.name;
-- Advance compatibility (irreversible)ALTER DISKGROUP DATA SET ATTRIBUTE 'compatible.asm' = '19.0';ALTER DISKGROUP DATA SET ATTRIBUTE 'compatible.rdbms' = '19.0';ASM Preferred Read (Preferred Read Failure Groups)
Section titled “ASM Preferred Read (Preferred Read Failure Groups)”In extended clusters or Data Guard environments with ASM, you can configure ASM to prefer reads from the local failure group to reduce cross-site I/O.
-- Set preferred read failure group (typically set to local storage group)-- Set in the database instance (not ASM instance), in init.ora / SPFILEALTER SYSTEM SET asm_preferred_read_failure_groups = 'DATA.CTRL1' SCOPE = BOTH;
-- Verify preferred read settingSHOW PARAMETER asm_preferred_read_failure_groups;
-- On each node of a RAC or extended cluster, set to the local failure group:-- Node 1: ASM_PREFERRED_READ_FAILURE_GROUPS = 'DATA.SITE1_FG,RECO.SITE1_FG'-- Node 2: ASM_PREFERRED_READ_FAILURE_GROUPS = 'DATA.SITE2_FG,RECO.SITE2_FG'ASMCMD Commands
Section titled “ASMCMD Commands”ASMCMD is a command-line utility for browsing and managing ASM files. Run it on the ASM host as the oracle user.
# Start ASMCMDasmcmd
# Or run a single command non-interactivelyasmcmd ls +DATA
# Alternatively with privilegeasmcmd --privilege sysdbaNavigation and File Management
Section titled “Navigation and File Management”# List diskgroupsASMCMD> ls
# List contents of a diskgroupASMCMD> ls +DATA
# List with details (size, creation time)ASMCMD> ls -l +DATA/ORCL/DATAFILE/
# Show disk usageASMCMD> du +DATAASMCMD> du +DATA/ORCL
# Change directoryASMCMD> cd +DATA/ORCL/DATAFILE
# Show current directoryASMCMD> pwd
# Find a fileASMCMD> find +DATA '*.dbf'ASMCMD> find +DATA 'SYSTEM*'
# Copy a file (within ASM or between ASM and OS)ASMCMD> cp +DATA/ORCL/DATAFILE/USERS.268.1234567890 /tmp/users_backup.dbfASMCMD> cp /tmp/users_backup.dbf +DATA/ORCL/DATAFILE/
# Move or rename a fileASMCMD> mv +DATA/ORCL/DATAFILE/oldname.dbf +DATA/ORCL/DATAFILE/newname.dbf
# Delete a file (use with extreme caution)ASMCMD> rm +DATA/ORCL/TEMPFILE/TEMP.267.1234567890Diskgroup Management via ASMCMD
Section titled “Diskgroup Management via ASMCMD”# List diskgroup metadataASMCMD> lsdgASMCMD> lsdg --discovery # Also list undiscovered disks
# List disksASMCMD> lsdskASMCMD> lsdsk --discovery # Include unclaimed disksASMCMD> lsdsk --member # Only member disks
# List failure groupsASMCMD> lsfg
# Check diskgroup attributesASMCMD> lsattr -l -G DATA
# Set a diskgroup attributeASMCMD> setattr -G DATA compatible.rdbms 19.0Metadata Backup and Restore
Section titled “Metadata Backup and Restore”# Backup ASM diskgroup metadata (critical before disk replacement)ASMCMD> md_backup -b /tmp/asm_metadata_backup.bkp -g DATAASMCMD> md_backup -b /tmp/asm_all_metadata.bkp # All diskgroups
# Restore from backupASMCMD> md_restore -b /tmp/asm_metadata_backup.bkp -t full -g DATA
# List contents of a metadata backupASMCMD> md_backup -b /tmp/asm_all_metadata.bkp -t checkMigrating Datafiles to ASM
Section titled “Migrating Datafiles to ASM”-- Use RMAN to copy datafiles into ASM while database is open (online migration)-- Connect RMAN to the database (not ASM instance)
-- Copy a specific datafile to ASMRMAN> COPY DATAFILE '/oradata/users01.dbf' TO '+DATA';
-- Copy all datafiles to ASMRMAN> BACKUP AS COPY DATABASE FORMAT '+DATA';RMAN> SWITCH DATABASE TO COPY;
-- Or use ALTER DATABASE to move one file at a time (12c online move)ALTER DATABASE MOVE DATAFILE '/oradata/users01.dbf' TO '+DATA';
-- Move with renameALTER DATABASE MOVE DATAFILE '/oradata/users01.dbf' TO '+DATA/ORCL/DATAFILE/users.dbf';
-- Track progress of an online datafile moveSELECT sid, serial#, opname, target_desc, sofar, totalwork, ROUND(sofar / NULLIF(totalwork, 0) * 100, 1) AS pct_done, time_remainingFROM v$session_longopsWHERE opname = 'MOVE DATAFILE' AND sofar < totalwork;Monitoring ASM Health
Section titled “Monitoring ASM Health”-- Diskgroup health summarySELECT name, state, type, total_mb, free_mb, usable_file_mb, offline_disks, voting_filesFROM v$asm_diskgroupORDER BY name;
-- Disk-level detail including I/O statisticsSELECT dg.name AS diskgroup, d.failgroup, d.name AS disk_name, d.path, d.mode_status, d.state, d.total_mb, d.free_mb, d.reads, d.writes, d.read_time, d.write_time, d.bytes_read / 1024 / 1024 / 1024 AS gb_read, d.bytes_written / 1024 / 1024 / 1024 AS gb_writtenFROM v$asm_disk dJOIN v$asm_diskgroup dg ON d.group_number = dg.group_numberORDER BY dg.name, d.failgroup, d.name;
-- ASM files by database and file typeSELECT dg.name AS diskgroup, af.type, COUNT(*) AS file_count, ROUND(SUM(af.bytes) / 1024 / 1024 / 1024, 2) AS total_gbFROM v$asm_file afJOIN v$asm_diskgroup dg ON af.group_number = dg.group_numberGROUP BY dg.name, af.typeORDER BY dg.name, af.type;
-- Alert log equivalent for ASM (check for errors)-- Located in: $ORACLE_BASE/diag/asm/+asm/<SID>/trace/alert_+ASM1.log-- Or query through ADRCI or V$DIAG_INFO:SELECT value AS log_locationFROM v$diag_infoWHERE name = 'Diag Trace';Best Practices
Section titled “Best Practices”- Always define failure groups explicitly - Let ASM choose failure groups automatically only for EXTERNAL redundancy. For NORMAL and HIGH, define failure groups matching your storage topology (controllers, shelves, or data centre sites).
- Use NORMAL or HIGH redundancy even on hardware RAID - Hardware RAID protects against disk failure but not against controller failure or accidental file deletion. ASM mirroring provides an independent protection layer.
- Set
AU_SIZE = 4Mfor OLTP,8Mfor data warehousing - The default 1 MB allocation unit works but larger AU sizes reduce metadata overhead on large files. - Run
md_backupbefore any disk operation - Metadata backups are small and fast; losing ASM metadata is catastrophic. - Monitor
V$ASM_OPERATIONduring rebalance - Control power to avoid saturating I/O during business hours. - Keep
ASM_DISKSTRINGtight - Overly broad patterns increase discovery scan time and risk of ASM claiming wrong devices. - Advance
compatible.rdbmsonly after all databases are upgraded - Lowering it later is impossible.
Related Topics
Section titled “Related Topics”- ASM Analysis Scripts - V$ view queries for ASM monitoring
- Oracle RMAN Backup Guide - Backup to ASM diskgroups
- Oracle Error ORA-15001 - Diskgroup does not exist or not mounted
- Oracle Error ORA-15042 - ASM disk is missing from diskgroup