Friday, November 11, 2011

ASMCMD utitlity commands


Check how much disk space is allocated/ in-use by an ASM instance

Login to your +ASM instance (SYS AS SYSDBA) and execute the following query:
SQL> SELECT name, free_mb, total_mb, free_mb/total_mb*100 "%" FROM v$asm_diskgroup;
NAME                              FREE_MB   TOTAL_MB     %
------------------------------ ---------- ---------- -----
DATA                               917104    1482145  61.9
RECOVER                             17387      17437  99.7

From Oracle 10g Release 2, one can also use the asmcmd command line utility:

du: Total space in MB used by files – particular directory can also be specified
ASMCMD> du
Used_MB      Mirror_used_MB
   1523                1523

lsdg: Uses V$ASM_DISKGROUP_STAT view to list information about a particular disk group
ASMCMD> lsdg
State    Type    Rebal  Unbal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Name
MOUNTED  EXTERN  N      N         512   4096  1048576     11264     9885                0            9885              0  DISKGROUP1/
MOUNTED  EXTERN  N      N         512   4096  1048576     10240     9906                0            9906              0  FLASH/
 
ASMCMD> lsdsk -t -G DATA
Create_Date  Mount_Date  Repair_Timer  Path
18-SEP-09    18-SEP-09   0             /dev/raw/raw1

lsct: Lists information about current Oracle ASM clients from the V$ASM_CLIENT view.

ASMCMD> lsct
DB_Name  Status     Software_Version  Compatible_version  Instance_Name  Disk_Group
+ASM     CONNECTED        11.2.0.1.0          11.2.0.1.0  +ASM           DATA
testdb   CONNECTED        11.2.0.1.0          11.2.0.0.0  testdb         DATA

 cp: Copy files from ASM to OS as wel as from OS to ASM disk groups
 
ASMCMD> cp EXAMPLE.265.697907183 /tmp/example01.bak
copying +DATA/TESTDB/DATAFILE/EXAMPLE.265.697907183 -> /tmp/example01.bak
 
ASMCMD> cp /tmp/example01.bak +DATA/TESTDB/DATAFILE/example01.bak
copying /tmp/example01.bak -> +DATA/TESTDB/DATAFILE/example01.bak
 
ASMCMD> ls
EXAMPLE.265.697907183
SYSAUX.257.697907095
SYSTEM.256.697907095
UNDOTBS1.258.697907095
USERS.259.697907095
example01.bak

find: we can use the wildcard or can specify a particular file type by using the ‘–type’ clause
ASMCMD> find --type ONLINELOG +DATA *
+DATA/TESTDB/ONLINELOG/group_1.261.697907177
+DATA/TESTDB/ONLINELOG/group_2.262.697907179
+DATA/TESTDB/ONLINELOG/group_3.263.697907179
 
ASMCMD> find +DATA example*
+DATA/ASM/DATAFILE/example01.bak.267.698929915
+DATA/TESTDB/DATAFILE/EXAMPLE.265.697907183
+DATA/TESTDB/DATAFILE/example01.bak

ls: list the contents of an ASM Disk Group directory as well as attributes of files located in the directory
ASMCMD> ls -s
Block_Size  Blocks      Bytes      Space  Name
      8192   12801  104865792  106954752  EXAMPLE.265.697907183
      8192   89601  734011392  736100352  SYSAUX.257.697907095
      8192   89601  734011392  736100352  SYSTEM.256.697907095
      8192    7681   62922752   65011712  UNDOTBS1.258.697907095
      8192     641    5251072    6291456  USERS.259.697907095
                                          example01.bak => +DATA/ASM/DATAFILE/example01.bak.267.698929915
 
ASMCMD> ls -l
Type      Redund  Striped  Time             Sys  Name
DATAFILE  UNPROT  COARSE   SEP 30 11:00:00  Y    EXAMPLE.265.697907183
DATAFILE  UNPROT  COARSE   SEP 28 23:00:00  Y    SYSAUX.257.697907095
DATAFILE  UNPROT  COARSE   SEP 29 22:00:00  Y    SYSTEM.256.697907095
DATAFILE  UNPROT  COARSE   SEP 18 22:00:00  Y    UNDOTBS1.258.697907095
DATAFILE  UNPROT  COARSE   SEP 18 22:00:00  Y    USERS.259.697907095
                                            N    example01.bak => +DATA/ASM/DATAFILE/example01.bak.267.698929915

iostat: Uses the V$ASM_DISK_IOSTAT view to display I/O statistics of disks in mounted ASM disk groups

ASMCMD> iostat -G DATA
Group_Name  Dsk_Name   Reads        Writes
DATA        DATA_0000  25448671744  19818926592
 
ASMCMD> iostat -t
Group_Name  Dsk_Name   Reads        Writes       Read_Time    Write_Time
DATA        DATA_0000  25450195456  19819686912  6491.434444  8042.604156

lsattr: List attributes of a disk group
ASMCMD> lsattr -l -G DATA
Name                     Value
access_control.enabled   FALSE
access_control.umask     066
au_size                  1048576
cell.smart_scan_capable  FALSE
compatible.asm           11.2.0.0.0
compatible.rdbms         10.1.0.0.0
disk_repair_time         3.6h
sector_size              512

Use the setattr command to change an attribute
ASMCMD> setattr -G data compatible.rdbms 11.2.0.0.0
ASMCMD> lsattr -l -G DATA
Name                     Value
access_control.enabled   FALSE
access_control.umask     066
au_size                  1048576
cell.smart_scan_capable  FALSE
compatible.asm           11.2.0.0.0
compatible.rdbms         11.2.0.0.0
disk_repair_time         3.6h
sector_size              512

No comments: