20 ASMCMD useful commands

One small article on ASMCMD commands which can help you in day to day ASM Command-Line tasks.

1.  Let’s check ASMCMD’s version.

[[email protected] ~]$ asmcmd -V
asmcmd version 11.2.0.0.0

Let’s enter into ASMCMD Command-Line utility.

[[email protected] ~]$ asmcmd

ASMCMD>

Now We are in ASMCMD Command-Line utility. We will now see few asmcmd commands about diskgroups.


2. To list the diskgroups we have.

ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576     18426    15138                0           15138              0             N  DATA/

So here we see information like State, Type of redundancy, Total and Free MB, Name, etc.. But with lsdg command, we won’t get the details of the diskgroups which is unmounted from ASM.


3. 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  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED     EXTERN  N         512   4096  1048576     18426    15138                0           15138              0             N  DATA/
DISMOUNTED          N         512   4096        0         0        0                0               0              0             N  FRA/

So now we can also see the details of diskgroup which is Dismounted, i.e. FRA


4. Let’s try mounting FRA diskgroup.

ASMCMD> mount FRA

Command executed without an error.

Let’s list diskgroups now.

ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576     18426    15138                0           15138              0             N  DATA/
MOUNTED  EXTERN  N         512   4096  1048576      8189     7654                0            7654              0             N  FRA/

Now the diskgroup FRA is mounted, both the diskgroups have EXTERNAL Redundancy, which means ASM will not perform any Mirroring and Striping of data and will keep only one copy and keep redundancy work on external third party RAID solution.

I’ll cover Types of Redundancy ASM offers in details in future post.


5. To list a particular diskgroup.

ASMCMD> lsdg DATA
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576     18426    15138                0           15138              0             N  DATA/

6. To list Mounted ASM disks.

ASMCMD> lsdsk
Path
/dev/oracleasm/disks/DATA01
/dev/oracleasm/disks/FRA01

7. To check details of ASM disks.

ASMCMD> lsdsk -k
Total_MB  Free_MB  OS_MB  Name    Failgroup  Library                                                Label  UDID  Product  Redund   Path
   18426    15138  18426  DATA01  DATA01     ASM Library - Generic Linux, version 2.0.12 (KABI_V2)  DATA01                UNKNOWN  /dev/oracleasm/disks/DATA01
    8189     7654   8189  FRA01   FRA01      ASM Library - Generic Linux, version 2.0.12 (KABI_V2)  FRA01                 UNKNOWN  /dev/oracleasm/disks/FRA01

Here we can see total size, free size and OS level size in MB. Label and path of the disk. We can see Redund Status is UNKNOWN which means there is no ASM redundancy available for these disks.


8. To check above information for a particular disk.

ASMCMD> lsdsk -k -G DATA
Total_MB  Free_MB  OS_MB  Name    Failgroup  Library                                                Label  UDID  Product  Redund   Path
   18426    15138  18426  DATA01  DATA01     ASM Library - Generic Linux, version 2.0.12 (KABI_V2)  DATA                  UNKNOWN  /dev/oracleasm/disks/DATA01

Now it’s showing details of “DATA01” disk only.


9. To get Input/Output State details of disks.

ASMCMD> iostat
Group_Name  Dsk_Name  Reads    Writes
DATA        DATA01    5450240  12764160
FRA         FRA01     98304    4096

Here Group_Name shows, which ASM diskgroup this disk belongs to. We can see Reads/Writes information in bytes.


10. To check above details for a particular Disk.

ASMCMD> iostat -G FRA
Group_Name  Dsk_Name  Reads  Writes
FRA         FRA01     98304  4096

11. To retrieve information of Reads/Writes Error.

ASMCMD> iostat -e
Group_Name  Dsk_Name  Reads    Writes    Read_Err  Write_Err
DATA        DATA01    5450240  13280256  0         0
FRA         FRA01     98304    4096      0         0

This will show you IO erros of disk.


12. To get Time Statistics, Read Time & Write Time.

ASMCMD> iostat -e -t
Group_Name  Dsk_Name  Reads    Writes    Read_Err  Write_Err  Read_Time  Write_Time
DATA        DATA01    5450240  13624320  0         0          .811       1.37
FRA         FRA01     98304    4096      0         0          .011       0

13. To get information about OracleASM ServerParameter file.

ASMCMD> spget
+DATA/rc-scan/asmparameterfile/registry.253.986765603

This will show you the location of spfile for ASM instance.


14. To List the current directory.

ASMCMD> ls -l
State    Type    Rebal  Name
MOUNTED  EXTERN  N      DATA/
MOUNTED  EXTERN  N      FRA/

15. To navigate to sub-directory.

ASMCMD> cd DATA
ASMCMD> ls -l
Type Redund Striped Time Sys Name
Y PRODDB/
Y rc-scan/

Here we can see sub-directories under DATA directory.
‘Y’ flag under Sys colunmn shows, sub-directories are owned by SYS user.


16. To print current directory path in ASMCMD Command-Line utility, connect ASMCMD using -p argument.

[[email protected] ~]$ asmcmd -p

ASMCMD [+] >

We can see It is showing '+' that is Root Directory.

Let’s navigate to sub-directory.

ASMCMD [+] > ls
DATA/
FRA/
ASMCMD [+] > cd +DATA/PRODDB/DATAFILE
ASMCMD [+DATA/PRODDB/DATAFILE] > ls
EXAMPLE.264.986768097
SYSAUX.257.986767995
SYSTEM.256.986767993
TBS.269.986769231
UNDOTBS1.258.986767995
UNDOTBS2.265.986768163
USERS.259.986767995

Here we can see current directory “ASMCMD [+DATA/PRODDB/DATAFILE] >” Even after navigating to subdirectory.

We are now in datafile directory of PRODDB database.


17. To check permissions on file.

ASMCMD [+DATA/PRODDB/DATAFILE] > ls --permission
User  Group  Permission  Name
              rw-rw-rw-  EXAMPLE.264.986768097
              rw-rw-rw-  SYSAUX.257.986767995
              rw-rw-rw-  SYSTEM.256.986767993
              rw-rw-rw-  TBS.269.986769231
              rw-rw-rw-  UNDOTBS1.258.986767995
              rw-rw-rw-  UNDOTBS2.265.986768163
              rw-rw-rw-  USERS.259.986767995

18. To check disk usage.

ASMCMD [+DATA] > du
Used_MB      Mirror_used_MB
   3154                3154

19. To find file with name.

ASMCMD [+DATA] > find + system*
+DATA/PRODDB/DATAFILE/SYSTEM.256.986767993

Here we found file containing system in its name.


20. To list currently open files by all instances in ASM Use Below Command.

ASMCMD [+] > lsof
DB_Name  Instance_Name  Path
PRODDB   PRODDB         +DATA/PRODDB/CONTROLFILE/current.265.987302781
PRODDB   PRODDB         +DATA/PRODDB/DATAFILE/sysaux.269.987302597
PRODDB   PRODDB         +DATA/PRODDB/DATAFILE/system.261.987302651
PRODDB   PRODDB         +DATA/PRODDB/DATAFILE/undotbs1.268.987302719
PRODDB   PRODDB         +DATA/PRODDB/DATAFILE/users.272.987302717
PRODDB   PRODDB         +DATA/PRODDB/ONLINELOG/group_1.264.987302785
PRODDB   PRODDB         +DATA/PRODDB/ONLINELOG/group_2.263.987302789
PRODDB   PRODDB         +DATA/PRODDB/ONLINELOG/group_3.262.987302793
PRODDB   PRODDB         +DATA/PRODDB/TEMPFILE/temp.273.987302813
PRODDB   PRODDB         +FRA/PRODDB/CONTROLFILE/current.256.987302781
PRODDB   PRODDB         +FRA/PRODDB/ONLINELOG/group_1.259.987302787
PRODDB   PRODDB         +FRA/PRODDB/ONLINELOG/group_2.258.987302791
PRODDB   PRODDB         +FRA/PRODDB/ONLINELOG/group_3.257.987302795

These are some ASMCMD commands which I could found useful for day to day activities.

3 thoughts on “20 ASMCMD useful commands

Comments are closed.