Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching

Oracle Engineered System


当前位置: 首页 » 技术文章 » ASM

asmcmd之磁盘组管理

ASMCMD Disk Group Management Commands(磁盘组管理),磁盘组管理是很重要。通过这些命令,我们可以查看磁盘组IO,备份/还原/创建/删除/修改/挂载/卸载/检查/修复磁盘组,离线/在线磁盘,查看/设置磁盘组的属性等,这些命令执行的是sql操作,可以查看ASM alert日志查看,这些命令有时更简便。主要有以下的命令:
    chdg, chkdg, dropdg, iostat, lsattr, lsdg, lsdsk, lsod, md_backup, md_restore, mkdg, mount, offline, online, rebal, remap, setattr, umount
    
chdg  通过读取xml格式的信息去修改磁盘组的属性,包括增加、删除、重新平衡磁盘,这个需要点xml的知识
      Changes a disk group (adds disks, drops disks, or rebalances) based on
        a XML configuration file.
        <chdg> update disk clause (add/delete disks/failure groups)
             name        disk group to change
             power       power to perform rebalance
        <add>  items to add are placed here
        </add>

        <drop>  items to drop are placed here
        </drop>

        <fg> failure group
             name         failure group name
        </fg>

        <dsk>
             name         disk name
             path         disk path
             size         size of the disk to add
        </dsk>
        </chdg>
        
        <chdg name="data" power="3">
             <drop>
             <fg name="fg1"></fg>
             <dsk name="data_0001" />
             </drop>

             <add>
                  <fg name="fg2">
                  <dsk string="/dev/disk5"/>
                  <fg>
             </add>
        </chdg>          
ASMCMD> chdg '<chdg name="ohsdba"><add><dsk string="/dev/oracleasm/disks/ASMDISK10"/></add></chdg>'    
Diskgroup altered.
ASMCMD>  

chkdg  检查磁盘组,包括检查和修复
       Checks or repairs the metadata of a disk group.

        chkdg [--repair] diskgroup

        The options for the chkdg command are described below.
        --repair        - Repairs the disk group.
        diskgroup       - Name of disk group to check or repair.

        chkdg checks the metadata of a disk group for errors and optionally
        repairs the errors.

ASMCMD> chkdg ohsdba
Diskgroup altered. 

dropdg  删除一个磁盘组
        Drops a disk group.
        dropdg [-r [-f]] diskgroup
        The options for the dropdg command are described below.

        -f      - Force the operation. Only applicable if the disk group
                  cannot be mounted.
        -r      - Recursive, include contents.
        diskgroup       - Name of disk group to drop.
ASMCMD> dropdg -r ohs
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     12235    10395                0           10395              0             N  DATA_PGOLD/
MOUNTED  EXTERN  N         512   4096  1048576      4894     2734                0            2734              0             N  OHSDBA/
MOUNTED  NORMAL  N         512   4096  1048576      7341     6415             2447            1984              0             Y  SYSTEMDG/
ASMCMD>


iostat  查看ASM disk的IO,热区域、冷区域等信息
        Displays I/O statistics for Oracle ASM disks in mounted disk groups.

        iostat [-et][--io] [--suppressheader] [--region] [-G diskgroup] [interval]

        iostat lists disk group statistics using the V$ASM_DISK_IOSTAT view.
        The options for the iostat command are described below.

        -e              - Displays error statistics (Read_Err, Write_Err).
        -G diskgroup    - Displays statistics for the disk group name.
        --suppressheader        - Suppresses column headings.
        --io            - Displays information in number of I/Os, instead
                          of bytes.
        -t              - Displays time statistics (Read_Time, Write_Time).
        --region        - Displays information for cold and hot disk regions
                          (Cold_Reads, Cold_Writes, Hot_Reads, Hot_Writes).
        interval        - Refreshes the statistics display based on the
                          interval value (seconds).
        The attribute descriptions for iostat command output are described
        below. To view the complete set of statistics for a disk group,
        use the V$ASM_DISK_IOSTAT view.
        Group_Name              Name of the disk group.
        Dsk_Name                Name of the disk.
        Reads                   Total number of bytes read from the disk.
                                If the --io option is entered, then the value
                                is displayed as number of I/Os.
        Writes                  Total number of bytes written from the disk.
                                If the --io option is entered, then the value
                                is displayed as number of I/Os.
        Cold_Reads              Total number of bytes read from the cold disk
                                region. If the --io option is entered, then
                                the value is displayed as number of I/Os.
        Cold_Writes             Total number of bytes written from the cold
                                disk region. If the --io option is entered,
                                then the value is displayed as number of I/Os.
        Hot_Reads               Total number of bytes read from the hot
                                disk region. If the --io option is entered,
                                then the value is displayed as number of I/Os.
        Hot_Writes              Total number of bytes written from the hot disk
                                region. If the --io option is entered, then the
                                value is displayed as number of I/Os.
        Read_Err                Total number of failed I/O read requests for
                                the disk.
        Write_Err               Total number of failed I/O write requests for
                                the disk.
        Read_Time               Total I/O time (in hundredths of a second) for
                                read requests for the disk if the
                                TIMED_STATISTICS initialization parameter is
                                set to TRUE (0 if set to FALSE).
        Write_Time              Total I/O time (in hundredths of a second) for
                                write requests for the disk if the
                                TIMED_STATISTICS initialization parameter is
                                set to TRUE (0 if set to FALSE).
ASMCMD> iostat
Group_Name  Dsk_Name         Reads      Writes    
DATA_PGOLD  DATA_PGOLD_0000  49641984   13974528  
DATA_PGOLD  DATA_PGOLD_0001  128687616  11868160  
DATA_PGOLD  DATA_PGOLD_0002  144556032  37805056  
DATA_PGOLD  DATA_PGOLD_0003  74684928   9715712   
DATA_PGOLD  DATA_PGOLD_0004  52492800   8384512   
OHSDBA      OHSDBA_0000      7116800    8509440   
SYSTEMDG    SYSTEMDG_0000    2994176    3235840   
SYSTEMDG    SYSTEMDG_0001    2162688    4812800   
SYSTEMDG    SYSTEMDG_0002    1306624    4718592
ASMCMD> iostat --region -G ohsdba
Group_Name  Dsk_Name     Reads    Writes   Cold_Reads  Cold_Writes  Hot_Reads  Hot_Writes  
OHSDBA      OHSDBA_0000  2316288  6199296  34816       26624        0          0           
OHSDBA      OHSDBA_0001  812544   77824    38400       0            0          0           
ASMCMD>

lsattr  查看磁盘组的属性
        Lists the attributes of a disk group.
ASMCMD> lsattr -l -G ohsdba
Name                     Value       
access_control.enabled   FALSE       
access_control.umask     066         
au_size                  1048576     
cell.smart_scan_capable  FALSE       
compatible.advm          11.2.0.0.0  
compatible.asm           11.2.0.0.0  
compatible.rdbms         11.2.0.0.0  
disk_repair_time         3.6h        
sector_size              512         
ASMCMD>
 
lsdg  列出磁盘组的信息,下面有字段的解释。如果采用normal,high方式的磁盘组,Usable_file_MB可能会出现负值的情况
      Lists disk groups and their information. lsdg queries
        V$ASM_DISKGROUP_STAT by default. If the --discovery flag is specified,
        the V$ASM_DISKGROUP is queried instead. The output also includes
        notification of any current rebalance operation for a disk group. If
        a disk group is specified, then lsdg returns only information about
        that disk group.

        lsdg [-g][--suppressheader][--discovery][pattern]

        The options for the lsdg command are described below.

        (none)           - Displays the disk group attributes
        --discovery      - Selects from V$ASM_DISKGROUP, or from
                           GV$ASM_DISKGROUP if the -g flag is also specified.
                           This option is always enabled if the Oracle ASM
                           instance is version 10.1 or earlier. This flag is
                           disregarded if lsdsk is running in non-connected mode.
        -g               - Selects from GV$ASM_DISKGROUP_STAT, or from
                           GV$ASM_DISKGROUP if the -c flag is also specified.
                           GV$ASM_DISKGOUP.INST_ID is included in the output.
                           The REBALcolumn of the GV$ASM_OPERATION view is also
                           included in the output.
        --suppressheader - Suppresses column headings.
        pattern          - Returns only information about the specified disk
                           group or disk groups that match the supplied pattern.
                           The attribute descriptions for lsdg command output
                           are described below.  To view the complete set of
                           attributes for a disk group, use the
                           V$ASM_DISKGROUP_STAT or V$ASM_DISKGROUP view.

        The attribute descriptions for lsdg command output are described
        below.  To view the complete set of attributes for a disk group,
        use the V$ASM_DISKGROUP_STAT or V$ASM_DISKGROUP view.

        State           - State of the disk group. Values include BROKEN,
                          CONNECTED, DISMOUNTED, MOUNTED, QUIESCING, and UNKNOWN.
        Type            - Disk group redundancy (NORMAL, HIGH, EXTERNAL).
        Rebal           - Y if a rebalance operation is in progress.
        Sector          - Sector size in bytes.
        Block           - Block size in bytes.
        AU              - Allocation unit size in bytes.
        Total_MB        - Size of the disk group in megabytes.
        Free_MB         - Free space in the disk group in megabytes, without
                          regard to redundancy. From the V$ASM_DISKGROUP view.
        Req_mir_free_MB - Amount of space that must be available in the disk
                          group to restore full redundancy after the most
                          severe failure that can be tolerated by the disk
                          group. This is the REQUIRED_MIRROR_FREE_MB column
                          from the V$ASM_DISKGROUP view.
        Usable_file_MB  - Amount of free space, adjusted for mirroring, that
                          is available for new files. From the
                          V$ASM_DISKGROUP view.
        Offline_disks   - Number of offline disks in the disk group.
                          Offline disks are eventually dropped.
        Voting_files    - Specifies whether the disk group contains voting
                          disks (Y or N).
        Name            - Disk group name.        
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     12235    10401                0           10401              0             N  DATA_PGOLD/
MOUNTED  EXTERN  N         512   4096  1048576      2447      295                0             295              0             N  OHSDBA/
MOUNTED  NORMAL  N         512   4096  1048576      7341     6415             2447            1984              0             Y  SYSTEMDG/
ASMCMD> 

lsdsk   列出ASM disk,这个命令很管用,比如查看哪些磁盘已经使用了,哪些磁盘还没有使用。
        List Oracle ASM disks.

        lsdsk [-kptgMI][-G diskgroup ] [--suppressheader] [ --member|--candidate] [--discovery][--statistics][pattern]

        The options for the lsdsk command are described below.

        (none)  - Displays the PATH column of the V$ASM_DISK view.
        -k      - Displays the TOTAL_MB, FREE_MB, OS_MB,NAME, FAILGROUP,
                  LIBRARY, LABEL, UDID, PRODUCT, REDUNDANCY, and PATH
                  columns of the V$ASM_DISK view.
        --statistics    - Displays the READS, WRITES, READ_ERRS, WRITE_ERRS,
                  READ_TIME, WRITE_TIME, BYTES_READ, BYTES_WRITTEN, and
                  the PATH columns of the V$ASM_DISK view.
        -p      - Displays the GROUP_NUMBER, DISK_NUMBER, INCARNATION,
                  MOUNT_STATUS, HEADER_STATUS, MODE_STATUS, STATE,
                  and the PATH columns of the V$ASM_DISK view.
        -t      - Displays the CREATE_DATE, MOUNT_DATE, REPAIR_TIMER, and
                  the PATH columns of the V$ASM_DISK view.
        -g      - Selects from GV$ASM_DISK_STAT, or from GV$ASM_DISK if
                  the --discovery flag is also specified.
                  GV$ASM_DISK.INST_ID is included in the output.
        --discovery     - Selects from V$ASM_DISK, or from GV$ASM_DISK
                  if the -g flag is also specified. This option is always
                  enabled if the Oracle ASM instance is version 10.1 or
                  earlier. This flag is disregarded if lsdsk is running
                  in non-connected mode.
        -I      - Scans disk headers for information rather than
                  extracting the information from an Oracle ASM instance.
                  This option forces non-connected mode.
        -G      - Restricts results to only those disks that belong to
                  the group specified by diskgroup.
        -M      - Displays the disks that are visible to some but not
                  all active instances. These are disks that, if included
                  in a disk group, will cause the mount of that disk group
                  to fail on the instances where the disks are not visible.
        --suppressheader       - Suppresses column headings.
        --candidate     - Restricts results to only disks having
                  membership status equal to CANDIDATE.
        --member        - Restricts results to only disks having membership
                  status equal to MEMBER.
        pattern - Returns only information about the specified disks
                  that match the supplied pattern.

        The lsdsk command can run in connected or non-connected mode.
        The connected mode is always attempted first. The -I option
        forces non-connected mode.

        In connected mode, lsdsk uses the V$ASM_DISK_STAT and V$ASM_DISK
        dynamic views to retrieve disk information. The V$ASM_DISK_STAT
        view is used by default.
        In non-connected mode, lsdsk scans disk headers to retrieve
        disk information. Some information is not available in this
        mode and some options are not valid combinations with this mode.

        Note: The non-connected mode is not supported on Microsoft Windows.
        pattern restricts the output to only disks that match the pattern
        specified. Wild-card characters and slashes (/ or \) can be part
        of the pattern. pattern should be specified as the last option for
        the command. See "Wildcard Characters".   
ASMCMD> lsdsk --candidate -p
Group_Num  Disk_Num      Incarn  Mount_Stat  Header_Stat  Mode_Stat  State   Path
        0         4  3915949075  CLOSED      PROVISIONED  ONLINE     NORMAL  /dev/oracleasm/disks/ASMDISK10
        0         3  3915949074  CLOSED      PROVISIONED  ONLINE     NORMAL  /dev/oracleasm/disks/ASMDISK11
        0         2  3915949073  CLOSED      PROVISIONED  ONLINE     NORMAL  /dev/oracleasm/disks/ASMDISK12
        0         1  3915949072  CLOSED      PROVISIONED  ONLINE     NORMAL  /dev/oracleasm/disks/ASMDISK13
        0         0  3915949071  CLOSED      PROVISIONED  ONLINE     NORMAL  /dev/oracleasm/disks/ASMDISK14
ASMCMD> 

lsod    列出正在使用的ASM disk,包括进程名字,进程号,磁盘的路径等信息
        Lists the open ASM disks.

        lsod [-G diskgroup] [--suppressheader] [--process process] [pattern]

        The options for the lsod command are described below.

        -G diskgroup    - Specifies the disk group that contains the open disks.
        --suppressheader        - Suppresses column header information from the output.
        --process - Specifies a pattern to filter the list of processes.
        pattern - Specifies a pattern to filter the list of disks.

        The rebalance operation (RBAL) opens a disk both globally and
        locally so the same disk may be listed twice in the output for
        the RBAL process.
ASMCMD> lsod
Instance Process                             OSPID Path                          
1        oracle@ohs1 (DBW0)      6075  /dev/oracleasm/disks/ASMDISK1
1        oracle@ohs1 (DBW0)      6075  /dev/oracleasm/disks/ASMDISK2
1        oracle@ohs1 (DBW0)      6075  /dev/oracleasm/disks/ASMDISK3
1        oracle@ohs1 (DBW0)      6075  /dev/oracleasm/disks/ASMDISK4
1        oracle@ohs1 (DBW0)      6075  /dev/oracleasm/disks/ASMDISK5
1        oracle@ohs1 (DBW0)      6075  /dev/oracleasm/disks/ASMDISK6
1        oracle@ohs1 (DBW0)      6075  /dev/oracleasm/disks/ASMDISK7
1        oracle@ohs1 (DBW0)      6075  /dev/oracleasm/disks/ASMDISK8
1        oracle@ohs1 (DBW0)      6075  /dev/oracleasm/disks/ASMDISK9
1        oracle@ohs1 (GMON)      6085  /dev/oracleasm/disks/ASMDISK1
1        oracle@ohs1 (GMON)      6085  /dev/oracleasm/disks/ASMDISK2
1        oracle@ohs1 (GMON)      6085  /dev/oracleasm/disks/ASMDISK3
1        oracle@ohs1 (GMON)      6085  /dev/oracleasm/disks/ASMDISK4
1        oracle@ohs1 (GMON)      6085  /dev/oracleasm/disks/ASMDISK5
1        oracle@ohs1 (GMON)      6085  /dev/oracleasm/disks/ASMDISK6
1        oracle@ohs1 (GMON)      6085  /dev/oracleasm/disks/ASMDISK7
1        oracle@ohs1 (GMON)      6085  /dev/oracleasm/disks/ASMDISK8
1        oracle@ohs1 (GMON)      6085  /dev/oracleasm/disks/ASMDISK9
1        oracle@ohs1 (LGWR)      6077  /dev/oracleasm/disks/ASMDISK1
1        oracle@ohs1 (LGWR)      6077  /dev/oracleasm/disks/ASMDISK2
1        oracle@ohs1 (LGWR)      6077  /dev/oracleasm/disks/ASMDISK3
1        oracle@ohs1 (LGWR)      6077  /dev/oracleasm/disks/ASMDISK4
1        oracle@ohs1 (LGWR)      6077  /dev/oracleasm/disks/ASMDISK5
1        oracle@ohs1 (LGWR)      6077  /dev/oracleasm/disks/ASMDISK6
1        oracle@ohs1 (LGWR)      6077  /dev/oracleasm/disks/ASMDISK9
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK1
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK1
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK2
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK2
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK3
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK3
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK4
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK4
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK5
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK6
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK6
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK7
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK8
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK9
1        oracle@ohs1 (RBAL)      6083  /dev/oracleasm/disks/ASMDISK9
1        oracle@ohs1 (TNS V1-V3) 6101  /dev/oracleasm/disks/ASMDISK1
1        oracle@ohs1 (TNS V1-V3) 6140  /dev/oracleasm/disks/ASMDISK1
1        oracle@ohs1 (TNS V1-V3) 6101  /dev/oracleasm/disks/ASMDISK2
1        oracle@ohs1 (TNS V1-V3) 6140  /dev/oracleasm/disks/ASMDISK2
1        oracle@ohs1 (TNS V1-V3) 6101  /dev/oracleasm/disks/ASMDISK3
1        oracle@ohs1 (TNS V1-V3) 6140  /dev/oracleasm/disks/ASMDISK3
1        oracle@ohs1 (TNS V1-V3) 6101  /dev/oracleasm/disks/ASMDISK4
1        oracle@ohs1 (TNS V1-V3) 6101  /dev/oracleasm/disks/ASMDISK5
1        oracle@ohs1 (TNS V1-V3) 6101  /dev/oracleasm/disks/ASMDISK6
1        oracle@ohs1 (TNS V1-V3) 6101  /dev/oracleasm/disks/ASMDISK7
1        oracle@ohs1 (TNS V1-V3) 6101  /dev/oracleasm/disks/ASMDISK8
1        oracle@ohs1 (TNS V1-V3) 6101  /dev/oracleasm/disks/ASMDISK9
1        oracle@ohs1 (TNS V1-V3) 9710  /dev/oracleasm/disks/ASMDISK9
1        oracle@ohs1 (VBG0)      6108  /dev/oracleasm/disks/ASMDISK9
ASMCMD>
 
mkdg   读取xml配置文件信息去创建磁盘组
       Creates a disk group based on an XML configuration file.
        <dg name="data" redundancy="normal">
             <fg name="fg1">
                  <dsk string="/dev/disk1"/>
                  <dsk string="/dev/disk2"/>
             </fg>
             <fg name="fg2">
                  <dsk string="/dev/disk3"/>
                  <dsk string="/dev/disk4"/>
             </fg>

             <a name="compatible.asm" value="11.2" />
             <a name="compatible.rdbms" value="11.2" />
             <a name="compatible.advm" value="11.2" />
        </dg>
ASMCMD> mkdg '<dg name="ohsdba" redundancy="external"><dsk string="/dev/oracleasm/disks/ASMDISK9"/></dg>'

asmca去创建磁盘组

[oracle@ohs1 ~]$ asmca -h
asmca [-silent] [-sysAsmPassword <SYS user password>] [-asmsnmpPassword <ASM monitor password>] {<command> <options>}
Please refer to the manual for details.
You can enter one of the following commands:

1. Configure an ASM instance by specifying the following command and parameters:
        -configureASM
                [-sysAsmPassword <SYS user password>]
                [-asmsnmpPassword <ASM monitor password>]
                [(-param <paramname=paramvalue>)]
                -diskString <disk discovery path>
                (-diskGroupName <disk group name>
                        (-disk <disk path> [-diskName <disk name>] |
                         -diskList <comma separated disk list>
                                [-diskSize <disk size in MB>]
                                [-failuregroup <failure group name>]
                                [-force|-noforce]
                                [-quorum|-noquorum])
                        [-redundancy <HIGH|NORMAL|EXTERNAL>]
                        [-au_size <2^0 ~ 2^6 (1 ~ 64)>]
                        [-compatible.asm <10.1 ~ 11.2>]
                        [-compatible.rdbms <10.1 ~ 11.2>]
                        [-compatible.advm <11.2>])

2. Upgrade an existing ASM instance by specifying the following command and parameters:
        -upgradeASM
                [-asmsnmpPassword <ASM monitor password>]

3. Configure ASM parameters by specifying the following command and parameters:
        -configureParameter
                (-param <paramname=paramvalue>)
                [-sysAsmPassword <SYS user password>]

4. Create Disk Groups by specifying the following command and parameters:
        -createDiskGroup
                [-diskString <disk discovery path>]
                (-diskGroupName <disk group name>
                        (-disk <disk path> [-diskName <disk name>] |
                         -diskList <comma separated disk list>
                                [-diskSize <disk size in MB>]
                                [-failuregroup <failure group name>]
                                [-force|-noforce]
                                [-quorum|-noquorum])
                        [-redundancy <HIGH|NORMAL|EXTERNAL>]
                        [-au_size <2^0 ~ 2^6 (1 ~ 64)>]
                        [-compatible.asm <10.1 ~ 11.2>]
                        [-compatible.rdbms <10.1 ~ 11.2>]
                        [-compatible.advm <11.2>])
                [-sysAsmPassword <SYS user password>]

5. Add disks to Disk Groups by specifying the following command and parameters:
        -addDisk
                [-diskString <disk discovery path>]
                (-diskGroupName <disk group name>
                        (-disk <disk path> [-diskName <disk name>] |
                         -diskList <comma separated disk list>
                                [-diskSize <disk size in MB>]
                                [-failuregroup <failure group name>]
                                [-force|-noforce]
                                [-quorum|-noquorum])
                [-sysAsmPassword <SYS user password>]

6. Create volumes by specifying the following command and parameters:
        -createVolume
                (-volumeName <ASM volume name>
                -volumeDiskGroup <ASM disk group name for the volume>
                -volumeSizeGB <ASM volume size in GB>
                [-volumeRedundancy <INHERIT|HIGH|NORMAL|EXTERNAL>])
                [-sysAsmPassword <SYS user password>]

7. Create ASM Cluster File Systems by specifying the following command and parameters:
        -createACFS
                (-acfsVolumeDevice <ASM volume device>)
                [-sysAsmPassword <SYS user password>]

8. Delete ASM instance(s) by specifying the following command and parameters:
        -deleteASM
                [-force]
                [-dropDiskGroups]
                [-sysAsmPassword <SYS user password>]
[oracle@ohs1 ~]$ asmca -silent -configureASM 
-sysAsmPassword oracle -asmsnmpPassword oracle -diskString  
'/dev/oracleasm/disks/ASMDISK*' -diskGroupName DATA_PGOLD -disk 
'/dev/oracleasm/disks/ASMDISK1' -redundancy EXTERNAL -au_size 4M  
-compatible.asm 11.2 -compatible.rdbms 11.2 asmca -silent -addDisk -diskGroupName DATA_PGOLD -disk '/dev/oracleasm/disks/ASMDISK2' -sysAsmPassword oracle 

mount   挂载磁盘组,也可以使用restrict模式

        Mounts a disk group
        mount [--restrict] { [-a] | [-f] diskgroup[ diskgroup ...] }

        The options for the mount command are described below.

        diskgroup       - Name of the disk group.
        -a              - Mounts all disk groups.
        --restrict      - Mounts in restricted mode.
        -f              - Forces the mount operation.

        This operation mounts one or more disk groups. A disk group
        can be mounted with or without force or restricted options.
ASMCMD> mount ohsdba
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     12235    10395                0           10395              0             N  DATA_PGOLD/
MOUNTED  EXTERN  N         512   4096  1048576      2447      289                0             289              0             N  OHSDBA/
MOUNTED  NORMAL  N         512   4096  1048576      7341     6415             2447            1984              0             Y  SYSTEMDG/
ASMCMD>

offline 使磁盘组中的disk或failure groups离线,注意disk_repair_time这个参数
        Offline disks or failure groups that belong to a disk group.

        offline -G diskgroup { -F failgroup |-D disk} [-t {minutes | hours}]

        The options for the offline command are described below.

        -G diskgroup    - Disk group name.
        -F failgroup    - Failure group name.
        -D disk         - Specifies a single disk name.
        -t              - minutes | hours

        Specifies the time before the specified disk is dropped as nm or nh,
        where m specifies minutes and h specifies hours. The default unit
        is hours.

        When a failure group is specified, this implies all the disks that
        belong to it should be offlined.

        The following are examples of the offline command. The first example
        offlines the failgroup1 failure group of the DATA disk group. The
        second example offlines the data_0001 disk of the DATA disk group with
        a time of 1.5 hours before the disk is dropped.

        ASMCMD [+] > offline -G DATA -F FAILGROUP1
        ASMCMD [+] > offline -G DATA -D data_0001 -t 1.5h
ASMCMD> lsattr -G ohs -l
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         
ASMCMD> offline -G ohs -D OHS_0000 -t 8h
Diskgroup altered.
ASMCMD> 

online  使磁盘组中的disk,failure group在线
        Online all disks, a single disk, or a failure group that belongs
        to a disk group.

        online { [-a] -G diskgroup | -F failgroup |-D disk} [-w]

        The options for the online command are described below.

        -a              - Online all offline disks in the disk group.
        -G diskgroup    - Disk group name.
        -F failgroup    - Failure group name.  When a failure group is
                          specified, this implies all the disks that belong
                          to it should be onlined.
        -D disk         - Disk name.
        -w              - Wait option. Causes ASMCMD to wait for the
                          disk group to be rebalanced before returning
                          control to the user. The default is not waiting.

        The following are examples of the online command. The first example
        onlines all disks in the failgroup1 failure group of the DATA disk
        group with the wait option enabled. The second example onlines the
        data_0001 disk in the DATA disk group.

        ASMCMD [+] > online -G DATA -F failgroup1 -w
        ASMCMD [+] > online -G DATA -D data_0001
ASMCMD> online -G ohs
Diskgroup altered.
ASMCMD>

rebal   平衡一个磁盘组,可以适当调整power参数来加快速度。增加磁盘时尽量选择空闲时间
        Rebalances a disk group.
        rebal [--power power] [-w] diskgroup

        The options for the rebal command are described below.

        diskgroup       - Disk group name.
        --power power   - Power setting (0 to 11).
        -w              - Wait option. Causes ASMCMD to wait for the
                          disk group to be rebalanced before returning
                          control to the user. The default is not waiting.

                          The power level can be set from 0 to 11. A value
                          of 0 disables rebalancing. If the rebalance power
                          is not specified, the value defaults to the setting
                          of the ASM_POWER_LIMIT initialization parameter.

        You can determine if a rebalance operation is occurring with
        the ASMCMD lsop command.

        The following is an example of the rebal command that rebalances the
        FRA disk group with a power level set to 4.

        ASMCMD [+] > rebal --power 4 FRA
        ASMCMD [+] > lsop
        Group_Name  Dsk_Num  State  Power
        FRA         REBAL    RUN    4

ASMCMD> rebal --power 2 ohs
Rebal on progress.
ASMCMD>

remap   调整数据在磁盘上的物理块的范围
        Marks a range of blocks as unusable on the disk and relocates any
        data allocated in that range.

        remap diskgroup disk block_range

        The options for the remap command are described below.

        diskgroup       - Disk group name in which a disk must have
                          data relocated.
        disk            - Name of the disk that must have data relocated.
                          The name must match the NAME column in the
                          V$ASM_DISK view.
        block_range     - Range of physical blocks to relocate in the format
                          start_range_number-end_range_number.

        The remap command only relocates blocks. It does not correct or
        repair blocks that contain corrupted contents.
        The command uses a physical block size based on the SECTOR_SIZE
        disk group attribute.        
        
ASMCMD> remap OHS OHS_0002 2000-2500
ASMCMD> 

setattr 设置磁盘组的属性
        Sets the attributes for an Oracle ASM disk group.
ASMCMD> setattr -G ohsdba disk_repair_time 8h
ASMCMD> lsattr -l -G ohsdba %time%
Name              Value  
disk_repair_time  8h     
ASMCMD> 

umount  卸载一个磁盘组
        Dismounts a disk group.
        umount { -a | [-f] diskgroup }

        The options for the umount command are described below.

        diskgroup       - Name of the disk group.
        -a              - Dismounts all mounted disk groups. These disk
                          groups are listed in the output of the
                          V$ASM_DISKGROUP view.
        -f              - Forces the dismount operation.
ASMCMD> umount ohsdba
ASMCMD>

md_backup 备份磁盘组的metadata
        The md_backup command creates a backup file containing metadata
        for one or more disk groups.
        Volume and Oracle Automatic Storage Management Cluster File System
        (Oracle ACFS) file system information is not backed up.

        md_backup backup_file [-G diskgroup [,diskgroup,...]]

        The options for the md_backup command are described below.

        backup_file     - Specifies the backup file in which you want to
                          store the metadata.
        -G diskgroup    - Specifies the disk group name of the disk group
                          that must be backed up

        By default all the mounted disk groups are included in the backup file,
        which is saved in the current working directory.

ASMCMD> md_backup /tmp/dgbak -G data_pgold
Disk group metadata to be backed up: DATA_PGOLD
Current alias directory path: PGOLD/TEMPFILE
Current alias directory path: PGOLD/DATAFILE
Current alias directory path: PGOLD/ONLINELOG
Current alias directory path: PGOLD
Current alias directory path: PGOLD/CONTROLFILE
Current alias directory path: PGOLD/PARAMETERFILE
ASMCMD> exit
[oracle@ohs1 ~]$ ls -l /tmp/dgbak
-rw-r--r-- 1 oracle oinstall 15228 May 13 23:37 /tmp/dgbak
[oracle@ohs1 ~]$ file /tmp/dgbak
/tmp/dgbak:
[oracle@ohs1 ~]$ 

md_restore 还原磁盘组的元数据
        This command restores a disk group metadata backup.
        md_restore backup_file [--silent][--full|--nodg|--newdg -o 'old_diskgroup:new_diskgroup [,...]'][-S sql_script_file] [-G 'diskgroup [,diskgroup...]']

        The options for the md_restore command are described below.

        backup_file             - Reads the metadata information from
                                  backup_file.
        --silent                - Ignore errors. Normally, if md_restore
                                  encounters an error, it will stop.
                                  Specifying this flag ignores any errors.
        --full                  - Specifies to create a disk group and restore
                                  metadata.
        --nodg                  - Specifies to restore metadata only.
        --newdg -o old_diskgroup:new_diskgroup  - Specifies to create a disk
                                  group with a different name when restoring
                                  metadata. The -o option is required
                                  with --newdg.
        -S sql_script_file      - Write SQL commands to the specified SQL
                                  script file instead of executing the commands.
        -G diskgroup            - Select the disk groups to be restored.
                                  If no disk groups are defined, then all
                                  disk groups will be restored.

        The first example restores the disk group DATA from the backup script
        and creates a copy. The second example takes an existing disk group
        DATA and restores its metadata. The third example restores disk group
        DATA completely but the new disk group that is created is called DATA2.
        The fourth example restores from the backup file after applying the
        overrides defined in the override.sql script file

        ASMCMD [+] > md_restore --full -G data --silent /tmp/dgbackup20090714
        ASMCMD [+] > md_restore --nodg -G data --silent /tmp/dgbackup20090714
        ASMCMD [+] > md_restore --newdg -o 'data:data2' --silent /tmp/dgbackup20090714
        ASMCMD [+] > md_restore -S override.sql --silent /tmp/dgbackup20090714

md_backup和md_restore是磁盘组级别的备份和还原,只备份磁盘组的基本信息,如果是磁盘组坏掉的话,可以通过md_restore还原去修复磁盘组,然后再通过RMAN还原数据库,最后再做恢复。如果是其中某一块盘换掉,通过这个是不能修复的,可以先offline这个盘(磁盘组的冗余模式必须是normal或者high才可以),重新换盘,添加盘,做rebalance。一般来说,容易出问题的是ASM Disk Header,可以通过kfed,dd去备份磁盘的头部信息。从10.2.0.5之后,Oracle增加了Asm Disk Header的自动备份功能,备份块的位置在第2个AU的倒数第2个块上(对于默认1M的AU来说,是第510个块),详情参考Kamus的测试http://www.dbform.com/html/2012/1875.html

[oracle@ohs1 ~]$ kfed help=y
as/mlib         ASM Library [asmlib='lib']
aun/um          AU number to examine or update [AUNUM=number]
aus/z           Allocation Unit size in bytes [AUSZ=number]
blkn/um         Block number to examine or update [BLKNUM=number]
blks/z          Metadata block size in bytes [BLKSZ=number]
ch/ksum         Update checksum before each write [CHKSUM=YES/NO]
cn/t            Count of AUs to process [CNT=number]
de/v            ASM device to examine or update [DEV=string]
dm/pall         Don't suppress repeated lines when dumping corrupt blocks [DMPALL=YES/NO]
o/p             KFED operation type [OP=READ/WRITE/MERGE/REPAIR/NEW/FORM/FIND/STRUCT]
p/rovnm         Name for provisioning purposes [PROVNM=string]
s/eek           AU number to seek to [SEEK=number]
te/xt           File name for translated block text [TEXT=string]
ty/pe           ASM metadata block type number [TYPE=number]
[oracle@ohs1 ~]$


Reference
http://docs.oracle.com/cd/B14117_01/server.101/b10739/storeman.htm
http://docs.oracle.com/cd/B19306_01/server.102/b14231/storeman.htm#i1021337
http://docs.oracle.com/cd/B19306_01/server.102/b14215/asm_util.htm
http://docs.oracle.com/cd/E11882_01/server.112/e18951/asmcon.htm
http://docs.oracle.com/cd/E11882_01/server.112/e18951/asm_util001.htm
http://docs.oracle.com/database/121/OSTMG/GUID-34A732CD-CC55-4A25-982A-209FDF6134BE.htm
http://docs.oracle.com/database/121/OSTMG/GUID-1E5C4FAD-087F-4598-B959-E66670804C4F.htm
http://docs.oracle.com/database/121/OSTMG/GUID-995198B7-9235-4FCF-988E-A48B3B62B405.htm 


关键词:asm 

相关文章

12c 如何将Standard ASM转化为Flex ASM
How to use amdu(ASM Metadata Dump Utility)
How to use kfed(Kernel Files metadata Editor)
How to use kfod(Kernel Files OSM Disk)
如何计算ASM磁盘头自动备份的位置
What is disk_repair_time?
Find block in ASM
12c新特性ASMFD
asmcmd之文件访问控制管理
asmcmd之卷管理
asmcmd之模板管理
asmcmd之磁盘组管理

联系我们

韩朝阳



    Phone:186-9589-1286

    E-mail:ohsdba@qq.com

    微  信: ohsdba


电话(186-9589-1286)

QQ(375349564)

微信(ohsdba)


常用链接

Oracle
eDelivery
My Oracle Support

Exadata 12.1 Document

Exadata 12.2 Document

Oracle 11gR2 Document

Oracle 12cR1 Document

Oracle 12cR2 Document

GoldenGate 12c

Oracle Fusion Middleware

Mysql Document

PostgreSQL

Python

github

sourceforge



Top
Cell186-9589-1286
QQ 375349564
E-mail ohsdba@qq.com