By Harry Hayes,2014-10-16 16:05
9 views 0
asmcmd---asm-command-line-utility,asmcmd,command line,command line tools,linux command line,grub command line,command line tool,mac command line,command,utility

    ASMCMD - ASM command line utilityASMCMD - ASM command line utility ?ÖÀà: Ä?ÈÏ?ÖÀà

    ÈÕÆÚ: 2011-04-22 10:51



     ?ÖÀà?º Oracle ASM 2011-04-22 10:51 333ÈËÔÄ?Á ÆÀÂÛ(0) ÊÕ?Ø ?Ù??

     Oracle database 10gR2 provides two new options to accessand manageAutomatic Storage Management (ASM) files and related information via command line interface - asmcmd and ASM ftp. This article will talk about asmcmd and provide sample Linux shell script to demonstrate the asmcmd in action.

     asmcmd can be used by Oracle database administrators to query and manage their ASM systems. Oracle Support Services engineers can use asmcmd to easily retrieve ASM related info for diagnosing and debugging purposes.

     asmcmd can be used against ASM versions 10gR1 (10.1.0.n) and 10gR2 (10.2.0.n). In ASM version 10.2 asmcmd is provided by default ASM installation.

     To use asmcmd in ASM version 10.1 environment we can just copy relevant files from 10.2 installation into the 10.1 environment as follows.


    Copy/ftp asmcmd and asmcmdcore from 10.2 install into 10.1 $ORACLE_HOME/bin , where $ORACLE_HOME is the oracle home where ASM is installed. These two files should be owned by the oracle user and the dba group, and have the following permissions:

    asmcmd: 550

    asmcmdcore: 440


    Copy/ftp asmcmd.bat and asmcmdcore from 10.2 install

    into %ORACLE_HOME%/bin, where %ORACLE_HOME% is the oracle home where ASM is installed.

ASMCMD - ASM command line utility

    Reference summary of asmcmd commands.

    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 directory.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.Ò??öÐ??Å???º asm.sh, a Linux shell script,that demonstrates some of the asmcmd functionality.#!/bin/bash # #asm.sh-ASMreportsbyBaneRadulovic,OracleCorporation,2005 # #asm.sh[-dbDBNAME] #ReportonalldiskgroupsinthecurrentASMinstance; #CurrentASMinstanceisdeterminedbyenvvariableORACLE_SID; #asmcmdshouldbeinthePATH #asm.sh[-dbDBNAME]-space


    #IfDBNAMEnotspecifiedreportontotaldiskspaceusedbyalldatabases #asm.sh[-dbDBNAME]-files

    #ReportallfilesfordatabaseDBNAMEmanagedbythisASMinstance #IfDBNAMEnotspecifiedreportallfilesmanagedbythisASMinstance # #Usagenotes: #Allargumentsareoptional.

    #Ifdatabasenameisnotsupplied,reportonalldiskgroups/space/files. #Reportontotalspaceinalldiskgroupsonlyifdatabasenamenotspecified. # #Openissues

    #1.Wedon'tdetectifASMinstanceisnotupandiftheenvironmentis #notsetup(ASMsid,asmcmdinPATH)


    #3.Wemayneedtoexpandthistoshowtheextents/AUsallocation #orsomethingmoreusefull; # # #Parsecommandlinearguments # while[$#-gt0] do case$1in -db)shift;DBNAME=$1;;#Databasename -space)SPACE=TRUE;;#Userwantsthespaceusagereport

    -files)FILES=TRUE;;#UserwantsthereportonallfilesindbDBNAME -help)echo"Usage:asm.sh[-dbDBNAME][-space][-files]";exit1;; esac; shift done echo"" # #GetallASMdiskgroupsusingthe'asmcmdls'command # forDIRECTORYin`asmcmdls-d%2>/dev/null` do

    echo$DIRECTORY|cut-f1-d'/'>>/tmp/groups$$ done

    if[-s/tmp/groups$$] then

    echo"ASMinstance$ORACLE_SIDmanagesthefollowingdiskgroup(s):" echo"==================================" cat/tmp/groups$$ echo"" else echo"TherearenodiskgroupsintheASMinstance$ORACLE_SID" echo"" exit2 fi # #If-fileswasspecified,reportonallfilesfordatabaseDBNAME # if[$FILES] then if[$DBNAME] then forGRPin`cat/tmp/groups$$` do asmcmdfind$GRP/$DBNAME%>>/tmp/files$$2>/dev/null done if[-s/tmp/files$$] then echo"$ORACLE_SIDfilesfordatabase$DBNAME:" echo"==================================" cat/tmp/files$$ else echo"Database$DBNAMEdoesnothaveanyfilesindiskgroup$GRP." fi echo"" else echo"ThelistofallfilesmanagedbyASMinstance$ORACLE_SID:"

    echo"==================================" forGRPin`cat/tmp/groups$$` do asmcmdfind$GRP%2>/dev/null done fi fi #

    #If-spacewasspecified,reportonthespaceusageperASMgroup # if[$SPACE] then if[$DBNAME] then forGRPin`cat/tmp/groups$$` do asmcmddu$GRP/$DBNAME>/tmp/grp$$2>/dev/null if[-s/tmp/grp$$] then echo"Spaceusagebydatabase$DBNAMEindiskgroup$GRP:" echo"==================================" cat/tmp/grp$$ echo"" rm-f/tmp/grp$$ else echo"Database$DBNAMEdoesnotusediskgroup$GRP." fi done else forGRPin`cat/tmp/groups$$` do

    asmcmddu$GRP>/tmp/grp$$2>/dev/null if[-s/tmp/grp$$] then echo"TotalSpaceusagebyalldatabasesindiskgroup$GRP:" echo"==================================" cat/tmp/grp$$ echo"" rm-f/tmp/grp$$ fi done fi fi # #Cleanup #

    rm-f/tmp/groups$$ rm-f/tmp/files$$ rm-f/tmp/grp$$ # #Allworkdone # exit0


    1. Default output

    [oracle@rac1 bin]$ ./asm.sh

    ASM instance +ASM1 manages the following disk group(s): ==================================



2. Report on disk space for database dave

    [oracle@rac1 bin]$ ./asm.sh -db dave -space

    ASM instance +ASM1 manages the following disk group(s): ==================================



Space usage by database dave in disk group DATA:


    Used_MB Mirror_used_MB

     226 226

Space usage by database dave in disk group FRA:


    Used_MB Mirror_used_MB

     3185 3185

3. Report all files for database dave

[oracle@rac1 bin]$ ./asm.sh -db dave -files

    ASM instance +ASM1 manages the following disk group(s): ==================================



+ASM1 files for database dave:













    +FRA/dave/ARCHIVELOG/2011_03_29/thread_1_seq_1.270.747082809 +FRA/dave/ARCHIVELOG/2011_03_29/thread_2_seq_1.269.747068457 ...

    +FRA/dave/ARCHIVELOG/2011_04_21/thread_1_seq_36.332.749084429 +FRA/dave/ARCHIVELOG/2011_04_21/thread_2_seq_28.331.749080839 +FRA/dave/ONLINELOG/





    4. Report on space and all files for database dave [oracle@rac1 bin]$ ./asm.sh -space -db dave -filesSome minor issues and usage warnings for asmcmd version

     1. When using asmcmd non interactively (e.g. in ashell scripts) it may be easier to use % (not *) for wildcard matching, to avoid shell substitution issues.

     2. asmcmd does not support wildcard substitution in CD command. This will be addressed in later versions of asmcmd.

     3. 'asmcmd du' always reports "Mirror_used_MB" space for all ASM disk

    groups. If the disk group is not mirrored, "Used_MB" and "Mirror_used_MB" values would be the same (represening the taken disk space in megabytes). In a normal redundancy disk group (i.e. with one mirror) the space reported under "Mirror_used_MB" would be double the ammout reported under "Used_MB". Similarly, for the triple mirrored disk group we would expect the three times the space reported under "Mirror_used_MB".

From Oracle


    Blog?º http://blog.csdn.net/tianlesoftware

    Email: dvd.dba@gmail.com

    DBA1 Ⱥ?º62697716(Âú); DBA2 Ⱥ?º62697977(Âú) DBA3 Ⱥ?º62697850(Âú) DBA ????Ⱥ?º63306533(Âú); DBA4 Ⱥ?º 83829929 DBA5Ⱥ?º 142216823 ÁÄÌì Ⱥ?º40132017 ÁÄÌì2Ⱥ?º69087192


Report this document

For any questions or suggestions please email