ASMCMD examples
- Posted by Gavin Soorma
- On September 30, 2009
- 1 Comments
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 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: 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 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
du: Total space in MB used by files – particular directory can also be specified
ASMCMD> pwd +DATA/TESTDB/DATAFILE ASMCMD> du Used_MB Mirror_used_MB 1574 1574 ASMCMD> du +DATA/TESTDB/ONLINELOG Used_MB Mirror_used_MB 153 153
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
lsdg: Uses V$ASM_DISKGROUP_STAT view to list information about a particular disk group
ASMCMD> lsdg DATA State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Name MOUNTED EXTERN N 512 4096 1048576 51200 49375 0 49375 DATA/ ASMCMD> lsdsk -t -G DATA Create_Date Mount_Date Repair_Timer Path 18-SEP-09 18-SEP-09 0 /dev/raw/raw1
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
1 Comments