ASMCMD to Manage ASM instance

asmcmd is a command line tool that we can use to manage Oracle ASM instances, ASM disk groups, files and dierctories, templates very much as in the same way we would do while working with say a UNIX file system.

ASMCMD can be launched in interactive or non-interactive modes and we need to first ensure that our environment points to the “Grid Infrastructure Home” as in 11g R2, ASM is not part of the standard database software installation. Also chec that the ORACLE_SID points to the ASM instance which should be running.

Let us have a quick look at some of the useful command options which are now available with 11g Release 2.

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  +ASM           DATA
testdb   CONNECTED  testdb         DATA

cp: We can copy files from ASM to OS as wel as from OS to ASM disk groups

ASMCMD> cp EXAMPLE.265.697907183 /tmp/example01.bak<br />copying +DATA/TESTDB/DATAFILE/EXAMPLE.265.697907183 -> /tmp/example01.bak<br /><br />ASMCMD> cp /tmp/example01.bak +DATA/TESTDB/DATAFILE/example01.bak<br />copying /tmp/example01.bak -> +DATA/TESTDB/DATAFILE/example01.bak<br /><br />ASMCMD> ls<br />EXAMPLE.265.697907183<br />SYSAUX.257.697907095<br />SYSTEM.256.697907095<br />UNDOTBS1.258.697907095<br />USERS.259.697907095<br />example01.bak<br />

du: Total space in MB used by files – particular directory can also be specified

ASMCMD> pwd<br />+DATA/TESTDB/DATAFILE<br /><br />ASMCMD> du<br />Used_MB      Mirror_used_MB<br />   1574                1574<br /><br />ASMCMD> du +DATA/TESTDB/ONLINELOG<br />Used_MB      Mirror_used_MB<br />    153                 153<br />

find: we can use the wildcard or can specify a particular file type by using the ‘–type’ clause

ASMCMD> find --type ONLINELOG +DATA *<br />+DATA/TESTDB/ONLINELOG/group_1.261.697907177<br />+DATA/TESTDB/ONLINELOG/group_2.262.697907179<br />+DATA/TESTDB/ONLINELOG/group_3.263.697907179<br /><br />ASMCMD> find +DATA example*<br />+DATA/ASM/DATAFILE/example01.bak.267.698929915<br />+DATA/TESTDB/DATAFILE/EXAMPLE.265.697907183<br />+DATA/TESTDB/DATAFILE/example01.bak<br />

ls: list the contents of an ASM Disk Group directory as well as attributes of files located in the directory

ASMCMD> ls -s<br />Block_Size  Blocks      Bytes      Space  Name<br />      8192   12801  104865792  106954752  EXAMPLE.265.697907183<br />      8192   89601  734011392  736100352  SYSAUX.257.697907095<br />      8192   89601  734011392  736100352  SYSTEM.256.697907095<br />      8192    7681   62922752   65011712  UNDOTBS1.258.697907095<br />      8192     641    5251072    6291456  USERS.259.697907095<br />                                          example01.bak => +DATA/ASM/DATAFILE/example01.bak.267.698929915<br /><br />ASMCMD> ls -l<br />Type      Redund  Striped  Time             Sys  Name<br />DATAFILE  UNPROT  COARSE   SEP 30 11:00:00  Y    EXAMPLE.265.697907183<br />DATAFILE  UNPROT  COARSE   SEP 28 23:00:00  Y    SYSAUX.257.697907095<br />DATAFILE  UNPROT  COARSE   SEP 29 22:00:00  Y    SYSTEM.256.697907095<br />DATAFILE  UNPROT  COARSE   SEP 18 22:00:00  Y    UNDOTBS1.258.697907095<br />DATAFILE  UNPROT  COARSE   SEP 18 22:00:00  Y    USERS.259.697907095<br />                                            N    example01.bak => +DATA/ASM/DATAFILE/example01.bak.267.698929915<br />

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

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

lsdg: Uses V$ASM_DISKGROUP_STAT view to list information about a particular disk group

ASMCMD> lsdg DATA<br />State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB    Name<br />MOUNTED  EXTERN  N         512   4096  1048576     51200    49375                0           49375    DATA/<br /><br />ASMCMD> lsdsk -t -G DATA<br />Create_Date  Mount_Date  Repair_Timer  Path<br />18-SEP-09    18-SEP-09   0             /dev/raw/raw1<br />

lsattr: List attributes of a disk group

ASMCMD> lsattr -l -G DATA<br />Name                     Value<br />access_control.enabled   FALSE<br />access_control.umask     066<br />au_size                  1048576<br />cell.smart_scan_capable  FALSE<br />compatible.asm <br />compatible.rdbms<br />disk_repair_time         3.6h<br />sector_size              512<br />

Use the setattr command to change an attribute

ASMCMD> setattr -G data compatible.rdbms<br />ASMCMD> lsattr -l -G DATA<br />Name                     Value<br />access_control.enabled   FALSE<br />access_control.umask     066<br />au_size                  1048576<br />cell.smart_scan_capable  FALSE<br />compatible.asm <br />compatible.rdbms<br />disk_repair_time         3.6h<br />sector_size              512<br />


About this entry