Focus On Oracle

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

Oracle Engineered System


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

什么是asmcmd

从10g开始Oracle引入了ASM,到10gR2有了命令行工具asmcmd,只不过那时的命令很简单,只能做些比较简单的工作,比如查看空间使用情况等基本操作。到11gR2,这个命令行工具功能越来越完善,我们可以用它来管理ASM instances,Disk Groups,磁盘组文件访问控制,文件和目录,磁盘组模板等。实际上一些asmcmd命令行的操作,还是通过连接到ASM实例,然后进行的操作,从日志alert_+ASM1.log中可以看到这些命令对应的SQL命令。asmcmd命令行工具可以以交互式和非交互式模式运行。在12c Oracle引入了Flex ASM,还增加了ASMFD(ASM Filter Driver),这个从asmcmd上也可以看到。

ASMCMD is a command-line utility that you can use to manage Oracle ASM instances, disk groups, file access control for disk groups, files and directories within disk groups, templates for disk groups, and volumes.You can run the ASMCMD utility in either interactive or noninteractive mode.

ASMCMD is a command-line utility that you can use to easily view and manipulate files and directories within Automatic Storage Management (ASM) disk groups. It can list the contents of disk groups, perform searches, create and remove directories and aliases, display space utilization, and more.

10gR1中关于ASM的描述
Automatic Storage Management (ASM) simplifies database administration. It eliminates the need for you, as a DBA, to directly manage potentially thousands of Oracle database files. It does this by enabling you to create disk groups, which are comprised of disks and the files that reside on them. You only need to manage a small number of disk groups.

10gR2中关于ASM的描述
Automatic Storage Management (ASM) is an integrated file system and volume manager expressly built for Oracle database files. ASM provides the performance of raw I/O with the easy management of a file system. It simplifies database administration by eliminating the need for you to directly manage potentially thousands of Oracle database files. It does this by enabling you to divide all available storage into disk groups. You manage a small set of disk groups and ASM automates the placement of the database files within those disk groups.

ASM Mirroring Options

Mirroring Option      Description
2-way mirroring       Each extent has 1 mirrored copy.
3-way mirroring       Each extent has 2 mirrored copies.
Unprotected           ASM provides no mirroring. Used when mirroring is provided by the disk subsystem itself.


ASM Instance

ASM is implemented as a special kind of Oracle instance, with its own System Global Area (SGA) and background processes. The ASM instance typically has a much smaller SGA than a database instance.


11gR1,11gR2中关于ASM的描述
ASM is a volume manager and a file system for Oracle database files that supports single-instance Oracle Database and Oracle Real Application Clusters (Oracle RAC) configurations. ASM is Oracle's recommended storage management solution that provides an alternative to conventional volume managers, file systems, and raw devices.

When you create a disk group, you can set the ASM AU size to be between 1 MB and 64 MB in powers of two, such as, 1, 2, 4, 8, 16, 32, or 64. Larger AU sizes typically provide performance advantages for data warehouse applications that use large sequential reads.


About Oracle ASM Instances

An ASM instance is built on the same technology as an Oracle Database instance. An ASM instance has a System Global Area (SGA) and background processes that are similar to those of Oracle Database. However, because ASM performs fewer tasks than a database, an ASM SGA is much smaller than a database SGA. In addition, ASM has a minimal performance effect on a server. ASM instances mount disk groups to make ASM files available to database instances; ASM instances do not mount databases.


ASM metadata is the information that ASM uses to control a disk group and the metadata resides within the disk group. ASM metadata includes the following information:
The disks that belong to a disk group
The amount of space that is available in a disk group
The filenames of the files in a disk group
The location of disk group datafile data extents
A redo log that records information about atomically changing data blocks
ASM and database instances require shared access to the disks in a disk group. ASM instances manage the metadata of the disk group and provide file layout information to the database instances.

12c中关于variable size extents的描述
To accommodate increasingly larger files, Oracle ASM uses variable size extents.

Variable size extents enable support for larger Oracle ASM data files, reduce SGA memory requirements for very large databases, and improve performance for file create and open operations. The initial extent size equals the disk group allocation unit size and it increases by a factor of 4 or 16 at predefined thresholds. The various extent sizes are described in this section.

For disk groups with AU size less than 4 MB:

Extent size always equals the disk group AU size for the first 20000 extent sets (0 - 19999).

Extent size equals 4*AU size for the next 20000 extent sets (20000 - 39999).

Extent size equals 16*AU size for the next 20000 and higher extent sets (40000+).

For disk groups with AU size greater than or equal to 4 MB and the disk group RDBMS compatibility greater than or equal to 11.2.0.4, the counts for extents of sizes (the disk group AU size, 4*AU size, or 16*AU size) are calculated using the application block size to support maximum file size.

The extent sizing feature is automatic for newly created and resized data files when specific disk group compatibility attributes are set to 11.1 or higher. For information about compatibility attributes, see "Disk Group Compatibility".


从官方文档以上的描述也可以看出,11g的更完整,更详尽,12c还做了一些补充。

11gR2下运行asmcmd需要满足几个条件
A.Log in to the host which contains the Oracle ASM instance that you plan to administer.

   You must log in as a user that has SYSASM or SYSDBA privileges through operating system authentication. The SYSASM privilege is the required  connection to administer the Oracle ASM instance.

B.To connect to the Oracle ASM instance, run ASMCMD that is located in the bin subdirectory of the Oracle Grid Infrastructure home (Oracle ASM home).

C.To use most of the ASMCMD commands, ensure that the Oracle ASM instance is started and the Oracle ASM disk groups are mounted.

D.You can connect to the database instance as SYSDBA by running ASMCMD that is located in the bin directory of the Oracle Database home.


运行asmcmd在Interactive Mode
The interactive mode of the ASMCMD utility provides a shell-like environment where you are prompted to enter ASMCMD commands. The syntax for starting ASMCMD in interactive mode is:

asmcmd [-V]
asmcmd [-v {errors|warnings|normal|info|debug}] [ --privilege connection_type ] [-p]
         -V : 显示asmcmd版本
         -v : 显示一些额外的信息帮助用户诊断问题,默认是Normal模式
         -p : 显示当前目录信息
 -privilege : 访问ASM实例连接的权限,SYSASM/SYSDBA,默认是SYSASM

[oracle@ohs1 ~]$ asmcmd -p -v info
ASMCMD [+] >

运行asmcmd在非交互模式

asmcmd command options

    command is any valid ASMCMD command

    options is a list of command options

[oracle@ohs1 ~]$ asmcmd ls -l
State    Type    Rebal  Name
MOUNTED  EXTERN  N      DATA_PGOLD/
MOUNTED  EXTERN  N      OHSDBA/
MOUNTED  NORMAL  N      SYSTEMDG/

11g R2 asmcmd的分类及命令
ASMCMD Instance Management Commands(实例管理)
    dsget, dsset, lsct, lsop, lspwusr, orapwusr, shutdown, spbackup, spcopy, spget, spmove, spset, startup

ASMCMD File Management Commands(文件管理)
    cd, cp, du, find, ls, lsof, mkalias, pwd, rm, rmalias

ASMCMD Disk Group Management Commands(磁盘组管理)
    chdg, chkdg, dropdg, iostat, lsattr, lsdg, lsdsk, lsod, md_backup, md_restore, mkdg, mount, offline, online, rebal, remap, setattr, umount

ASMCMD Template Management Commands(模板管理)
    chtmpl, lstmpl, mktmpl, rmtmpl

ASMCMD File Access Control Commands(文件访问控制)
    chgrp, chmod, chown, groups, grpmod, lsgrp, lsusr, mkgrp, mkusr, passwd, rmgrp, rmusr

ASMCMD Volume Management Commands(卷管理)
    volcreate, voldelete, voldisable, volenable, volinfo, volresize, volset, volstat

10gR2 asmcmd命令
Command      Description
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 directories.
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.

11gR2 asmcmd命令
md_backup, md_restore

lsattr, setattr

cd, cp, du, find, help, ls, lsct, lsdg, lsof, mkalias
mkdir, pwd, rm, rmalias

chdg, chkdg, dropdg, iostat, lsdsk, lsod, mkdg, mount
offline, online, rebal, remap, umount

dsget, dsset, lsop, shutdown, spbackup, spcopy, spget
spmove, spset, startup

chtmpl, lstmpl, mktmpl, rmtmpl

chgrp, chmod, chown, groups, grpmod, lsgrp, lspwusr, lsusr
mkgrp, mkusr, orapwusr, passwd, rmgrp, rmusr

volcreate, voldelete, voldisable, volenable, volinfo
volresize, volset, volstat

12cR1 asmcmd命令

commands:
--------
md_backup, md_restore
amdu_extract

lsattr, setattr

audcleanaudittrail, audclearproperty, audcleartimestamp
audcreatejob, auddropjob, audloaduniauditfiles, audsetdebug
audsetjobinterval, audsetjobstatus, audsetproperty, audsettimestamp
audsettraillocation, audshowtimestamp, lsaudcleanevents
lsaudcleanupjobs, lsaudconfigparams

cd, cp, du, find, help, ls, lsct, lsdg, lsof, mkalias
mkdir, pwd, rm, rmalias, showclustermode, showclusterstate
showpatches, showversion

mapau, mapextent

chdg, chkdg, dropdg, iostat, lsdsk, lsod, mkdg, mount
offline, online, rebal, remap, umount

pwcopy, pwcreate, pwdelete, pwget, pwmove, pwset

afd_configure, afd_deconfigure, afd_dsget, afd_dsset
afd_filter, afd_label, afd_lsdsk, afd_scan, afd_state
afd_unlabel, dsget, dsset, lsop, mkcc, rmcc, shutdown
spbackup, spcopy, spget, spmove, spset, startup

chtmpl, lstmpl, mktmpl, rmtmpl

chgrp, chmod, chown, groups, grpmod, lsgrp, lspwusr, lsusr
mkgrp, mkusr, orapwusr, passwd, rmgrp, rmusr, rpusr

volcreate, voldelete, voldisable, volenable, volinfo
volresize, volset, volstat


12c增加的asmcmd命令
ASMCMD instance management commands
   pwcopy             Copies a password file to the specified location.
   pwcreate           Creates a password file at the specified location.
   pwdelete           Deletes a password file at the specified location.
   pwget              Returns the location of the password file.
   pwmove             Moves the location of the password file.
   pwset              Sets the location of the password file.
   showclustermode    Displays the current mode of the Oracle ASM cluster.
   showclusterstate   Displays the current state of the cluster.
   showpatches        Lists the patches applied to the Oracle Grid Infrastructure home.
   showversion        Displays the Oracle ASM cluster release and software patch levels.


ASMCMD File Management Commands

  amdu_extract Extracts a file from a disk group.


ASMCMD Oracle ASM Filter Driver Management Commands

  afd_configure     Configures Oracle ASM Filter Driver.
  afd_deconfigure   Deconfigures Oracle ASM Filter Driver.
  afd_dsget         Retrieves the Oracle ASM Filter Driver diskstring value.
  afd_dsset         Sets the Oracle ASM Filter Driver diskstring value.
  afd_filter        Sets the Oracle ASM Filter Driver mode on a given disk path.
  afd_label         Sets an Oracle ASM Filter Driver label to a disk.
  afd_lsdsk         Lists Oracle ASM Filter Driver disks.
  afd_scan          Scans for Oracle ASM Filter Driver disks.
  afd_state         Returns the state of Oracle ASM Filter Driver.
  afd_unlabel       Clears an existing Oracle ASM Filter Driver label.  


其它命令:mkcc,rmcc,mapau,mapextent,还增加了ACFS审计功能,不过这部分从白皮书上找不到帮助文档


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 

相关文章

Oracle ASM from 10g to 18c
在18c中通过ASM Flex DiskGroup克隆PDB
Exadata and ASM
Oracle ASM Storage Limits
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
Top