ASM Command-Line Utility (ASMCMD)

What is ASMCMD Utility?

ASMCMD is a command-line utility that you can use to easily view and manipulate files and directories within Automatic Storage Management (ASM) disk groups. It can list the contents of disk groups, perform searches, create and remove directories and aliases, display space utilization, and more.

ASMCMD  is a command line utility for managing files and directories in ASM (Automatic Storage Management ) disk-groups. It offers Unix-style filesystem commands for managing ASM directories and files. Prior to Oracle 10gR2, ASM had to be administered via OEM or SQL statements while connected to a special ASM instance.

 Note that ASMCMD cannot be used to create or drop diskgroups, or to add or drop disks in a disk group. These ASM administrative tasks must be accomplished via SQL commands.

 ASMCMD offers two modes of operation: interactive and non-interactive. Interactive mode provides a shell-like environment for executing ASMCMD commands. It resembles how SQL*Plus interactive mode works and looks like this:

Note:

You cannot use ASMCMD to create or drop disk groups or to add or drop disks in a disk group. For these operations, you must use SQL commands.

Summary of ASM Commands

CommandDescription
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 directories.
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.

Summary of ASMCMD Disk group management commands

CommandDescription

chdg

Changes a disk group (add, drop, or rebalance).

chkdg

Checks or repairs a disk group.

dropdg

Drops a disk group.

iostat

Displays I/O statistics for disks.

lsattr

Lists the attributes of a disk group.

lsdg

Lists disk groups and their information.

lsdsk

Lists disks Oracle ASM disks.

lsod

Lists open devices.

md_backup

Creates a backup of the metadata of mounted disk groups.

md_restore

Restores disk groups from a backup of the metadata.

mkdg

Creates a disk group.

mount

Mounts a disk group.

offline

Offlines a disk or a failure group.

online

Onlines a disk or a failure group.

rebal

Rebalances a disk group.

remap

Relocates data in a range of physical blocks on a disk.

setattr

Sets attributes in a disk group.

stamp

Stamps the disk, site, and failure group labels in disk headers.

stamplist

Displays the disk, site, and failure group labels in disk headers.

umount

Dismounts a disk group.


Preparing to Run ASMCMD

Before running ASMCMD, check the following:

To use most of the ASMCMD commands, ensure that the ASM instance is started and the ASM disk groups are mounted.

If the ASM instance is not running or if the ORACLE_SID is set incorrectly, ASMCMD will still run, 

but only those commands that do not require an ASM instance will run. The commands are lsdsk, help, and exit. 

If you attempt to run other ASMCMD commands, an error message displays.

Running ASMCMD in Interactive Mode

The interactive mode of the ASMCMD utility provides a shell-like environment where you are prompted to enter ASMCMD commands.

To run ASMCMD in interactive mode:

[grid@ora-prod]$ asmcmd

ASMCMD> ls -l

State    Type    Rebal  Name

MOUNTED  EXTERN  N      DATA/

MOUNTED  EXTERN  N      RECO/

ASMCMD>

ASMCMD> pwd

+DATA/ora_data/19744798347947/DATAFILE

ASMCMD> ls -l

DATAFILE  UNPROT  COARSE   OCT 26 21:00:00  Y    SYSTEM.348.1009978273

DATAFILE  UNPROT  COARSE   OCT 26 21:00:00  Y    SYSTEM.354.1013346191

DATAFILE  UNPROT  COARSE   OCT 26 21:00:00  Y    SYSTEM.363.1022606279

DATAFILE  UNPROT  COARSE   OCT 26 21:00:00  Y    SYSTEM.366.1017318075

DATAFILE  UNPROT  COARSE   OCT 26 21:00:00  Y    SYSTEM.370.1019732645

DATAFILE  UNPROT  COARSE   OCT 26 21:00:00  Y    SYSTEM.374.1024834305

To list the diskgroups we have.
ASMCMD> lsdg
State    Type    Rebal  Sector  Logical_Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512             512   4096  4194304   1048576   376496                0          376496              0             Y  DATA/
MOUNTED  EXTERN  N         512             512   4096  4194304    262144   258856                0          258856              0             N  RECO/


ASMCMD> lsct
DB_Name   Status     Software_Version  Compatible_version  Instance_Name  Disk_Group
+APX      CONNECTED        12.2.0.1.0          12.2.0.1.0  +APX1          DATA
_OCR      CONNECTED                 -                   -  ora-prod   DATA
prod  CONNECTED        12.2.0.1.0          12.2.0.1.0  prod       DATA
prod  CONNECTED        12.2.0.1.0          12.2.0.1.0  prod       RECO
ASMCMD>

ASMCMD> du DATA/
Used_MB      Mirror_used_MB
 666788              666788

ASMCMD> du RECO/
Used_MB      Mirror_used_MB
   3160                3160

To check details of all the diskgroups, i.e. Mounted and Dismounted, We would use lsdg command with ‘ – – discovery’ argument.

ASMCMD> lsdg --discovery
State    Type    Rebal  Sector  Logical_Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512             512   4096  4194304   1048576   376496                0          376496              0             Y  DATA/
MOUNTED  EXTERN  N         512             512   4096  4194304    262144   258856                0          258856              0             N  RECO/
ASMCMD>

 To list Mounted ASM disks.
ASMCMD> lsdsk
Path
/dev/DATADISK5
/dev/DATADISK6
/dev/DATADISK7
/dev/DATADISK8
/dev/RECODISK1
/dev/RECODISK2
/dev/RECODISK3
/dev/RECODISK4
ASMCMD>

To check details of ASM disks.
ASMCMD> lsdsk -k
Total_MB  Free_MB   OS_MB  Name       Failgroup  Site_Name  Site_GUID                         Site_Status  Failgroup_Type  Library  Label             Failgroup_Label  Site_Label  UDID  Product  Redund   Path
  262144    94092  262144  DATA_0004  DATA_0004             00000000000000000000000000000000               REGULAR         System                                                                 UNKNOWN  /dev/DATADISK5
  262144    94156  262144  DATA_0005  DATA_0005             00000000000000000000000000000000               REGULAR         System                                                                 UNKNOWN  /dev/DATADISK6



Let’s check ASMCMD’s version.

[oracle@ora ~]$ asmcmd -V
asmcmd version 11.2.0.0.0

To list a particular diskgroup.

ASMCMD> lsdg DATA

To list Mounted ASM disks.

ASMCMD> lsdsk

To check details of ASM disks.

ASMCMD> lsdsk -k

To get Input/Output State details of disks.

ASMCMD> iostat

To check above details for a particular Disk.

ASMCMD> iostat -G FRA

To retrieve information of Reads/Writes Error.

ASMCMD> iostat -e

To get Time Statistics, Read Time & Write Time.

ASMCMD> iostat -e -t

To get information about OracleASM ServerParameter file.

ASMCMD> spget

 To List the current directory.

ASMCMD> ls -l


To run ASMCMD in noninteractive mode:

At the command prompt, enter:

asmcmd command arguments

where:

command is any valid ASMCMD command. arguments is a list of command flags and arguments.

The following example demonstrates running ASMCMD in the noninteractive mode.

[grid@ora-prod ~]$ asmcmd ls -l
State    Type    Rebal  Unbal  Name
MOUNTED  NORMAL  N      N      DGROUP1/
MOUNTED  NORMAL  N      N      DGROUP2/

Rebalance from asmcmd :
Now we can do rebalance of diskgroup from asmcmd prompt also.

To rebalance a diskgroup with power limit of 100

SYNTAX –
rebal –power < POWER_LIMIT> < DISKGROUP_NAME>

ASMCMD> rebal --power 100 B2BWMDB
Rebal on progress.

To monitor the rebalance operation:
ASMCMD> lsop
Group_Name Pass State Power EST_WORK EST_RATE EST_TIME
B2BWMDB COMPACT WAIT 1 0 0 0
B2BWMDB REBALANCE RUN 1 12072 4400 2

 Miscellaneous asmcmd commands:
Check the patches installed in grid home:

ASMCMD> showpatches
Check asm instance version:

ASMCMD> showversion
Check the cluster mode:

ASMCMD> showclustermode
ASM cluster : Flex mode disabled
Check the cluster state:

ASMCMD> showclusterstate
Normal

============================================
SQL> set lines 150
 column path format a30
 column DiskGroup format a15
 column DiskName format a30
 col free_mb for 999,999,999
 compute sum of total_mb on DiskGroup
 compute sum of free_mb on DiskGroup
 break on DiskGroup skip 1 on report
 set pages 255



SELECT name, free_mb, total_mb, total_mb-free_mb "USED_MB", free_mb/total_mb*100 "%FREE" FROM v$asm_diskgroup;

=============================================
select a.name DiskGroup,b.disk_number Disk#,b.name DiskName,b.total_mb,
 b.free_mb,
     b.path,
 b.header_status
from v$asm_disk b, v$asm_diskgroup a
    where a.group_number (+) =b.group_number
and b.header_status != 'FOREIGN'
order by b.group_number, b.disk_number, b.name;

No comments:

ORA-00059: Maximum Number Of DB_FILES Exceeded in 19C database

When I am adding datafile to my 19C database facing the below error. SQL> alter tablespace DATA  add datafile '/u01/data/data15.dbf&#...