Focus On Oracle

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

Oracle Engineered System


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

asmcmd之实例管理

ASMCMD Instance Management Commands(实例管理),涉及到磁盘组位置字符串的设置,用户权限的管理,spfile的操作,asm实例的启动和关闭等操作。其中关于spfile的操作很实用,比如在从文件系统迁移到ASM,或者从原有磁盘组迁移到新的磁盘组等。

dsget, dsset, lsct, lsop, lspwusr, orapwusr, shutdown, spbackup, spcopy, spget, spmove, spset, startup

dsget  获取diskstring的值,参数不同,取值的地方也不一样
        Retrieves the discovery diskstring value that is
        used by the Oracle ASM Instance and its clients

        dsget [[--normal] [--profile [-f]] [--parameter]]

        The options for the dsget command are described below.

        --normal        - Retrieves the discovery string from the Grid Plug
                          and Play (GPnP) profile and the one that is set in
                          the Oracle ASM instance. It returns one row each for
                          the profile and parameter setting. This is the
                          default setting.

        --profile [-f] - Retrieves the discovery string from the GPnP
                          profile.  If -f is specified, retrieves the
                          discovery string from the local GPnP profile.

        --parameter     - Retrieves the ASM_DISKSTRING parameter setting of
                          the Oracle ASM instance.
ASMCMD> dsget --normal
parameter:/dev/oracleasm/disks*
profile:/dev/oracleasm/disks*
ASMCMD> dsget --profile
profile:/dev/oracleasm/disks*
ASMCMD> dsget --parameter
parameter:/dev/oracleasm/disks*
ASMCMD> 

dsset  设置diskstring的值,参数不同,设置的范围也不同
        Sets the discovery diskstring value that is used by the Oracle ASM
        instance and its clients.  The specified diskstring must be valid for
        existing mounted disk groups. The updated value takes effect
        immediately.

        dsset [--normal] [--parameter] [--profile [-f]] diskstring

        The options for the dsget command are described below.

        --normal                - Sets the discovery string in the Grid Plug
                                  and Play (GPnP) profile and in the Oracle
                                  ASM instance.  The update occurs after the
                                  Oracle ASM instance has successfully
                                  validated that the specified discovery
                                  string has discovered all the necessary disk
                                  groups and voting files. Note that this
                                  command fails if the instance is not using
                                  a server parameter file (SPFILE).  This is
                                  the default setting.
        --profile [-f]  - Specifies the discovery diskstring that is
                                  pushed to the GPnP profile without any
                                  validation by the Oracle ASM instance,
                                  ensuring that the instance can discover
                                  all the required disk groups.  The update
                                  is guaranteed to be propagated to all the
                                  nodes that are part of the cluster

                                  If -f is specified, the specified
                                  diskstring is pushed to the local GPnP
                                  profile without any synchronization with
                                  other nodes in the cluster. Note that this
                                  command option updates only the local profile
                                  file. This option should only be used in the
                                  case of recovery. The command fails if the
                                  Oracle Clusterware stack is running.
        --parameter             - Specifies that the diskstring is updated in
                                  memory after validating that the discovery
                                  diskstring discovers all the current mounted
                                  disk groups and voting files. The diskstring
                                  is not persistently recorded in either the
                                  SPFILE or the GPnP profile.
        diskstring              - Specifies the value for the discovery
                                  diskstring

ASMCMD> dsset --normal /dev/oracleasm
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-15014: path '/dev/oracleasm/disks/ASMDISK10' is not in the discovery set (DBD ERROR: OCIStmtExecute)
ASMCMD>

如果根据disktring找不到合适的磁盘,会报错,使用用这个修改还是比较靠谱的,因为这个会做验证。

lsct 列出V$ASM_CLIENT的信息
     Lists information about current Oracle ASM clients from the
        V$ASM_CLIENT view. A client, such as Oracle Database or Oracle ASM
        Dynamic Volume Manager (Oracle ADVM), uses disk groups that are manage
        by the Oracle ASM instance to which ASMCMD is currently connected.
        
ASMCMD> lsct
DB_Name  Status     Software_Version  Compatible_version  Instance_Name  Disk_Group
+ASM     CONNECTED        11.2.0.3.0          11.2.0.3.0  +ASM1          SYSTEMDG  
asmvol   CONNECTED        11.2.0.3.0          11.2.0.3.0  +ASM1          OHSDBA    
pgold    CONNECTED        11.2.0.3.0          11.2.0.0.0  pgold1         DATA_PGOLD
ASMCMD> 

lsop  列出磁盘或者实例的当前操作
      Lists the current operations on a disk group or Oracle ASM instance.

        lsop

        lsop displays information from the V$ASM_OPERATION view

        The following are examples of the lsop command. The examples list
        operations on the disk groups of the current Oracle ASM instance.

ASMCMD> lsop
Group_Name  Dsk_Num  State  Power
DATA_PGOLD        REBAL    WAIT   2     
ASMCMD> 

lspwusr  列出在ASM密码文件中的用户
         List the users from the local Oracle ASM password file
ASMCMD> lspwusr
Username sysdba sysoper sysasm
     SYS   TRUE    TRUE   TRUE
 ASMSNMP   TRUE   FALSE  FALSE
ASMCMD>

orapwusr  添加/删除/修改密码文件中用户
        Add, drop, or modify an Oracle ASM password file user.

        orapwusr { { { --add | --modify [--password] }[--privilege {sysasm|sysdba|sysoper} ] } | --delete } user

        The options for the orapwusr command are described below.

        --add              - Adds a user to the password file. Also prompts
                             for a password.
        --delete           - Drops a user from the password file.
        --modify           - Changes a user in the password file.
        --privilege role   - Sets the role for the user. The options are
                             sysasm, sysdba, and sysoper.
        --password         - Prompts for and then changes the password
                             of a user.
        user               - the user to add, drop, or modify.

       orapwusr attempts to update passwords on all nodes in a cluster.
       The command requires the SYSASM privilege to run. A user logged in
       as SYSDBA cannot change its password using this command.

ASMCMD> orapwusr --modify --privilege sysoper asmsnmp
ASMCMD> lspwusr
Username sysdba sysoper sysasm
     SYS   TRUE    TRUE   TRUE
 ASMSNMP  FALSE    TRUE  FALSE
ASMCMD>

shutdown  关闭ASM实例,在尝试shutdown abort ASM实例之前,Oracle强烈建议你关闭数据库和ADVM
        Shuts down an Oracle ASM instance.

        shutdown [ --normal |--abort|--immediate ]

        The options for the shutdown command are described below.

        --normal        - optional, if no option is specified,
                          --normal is assumed.
                          option specified
        --abort         - Shut down aborting all existing operations.
        --immediate     - Shut down immediately.

        The default action is a normal shutdown.

        Oracle strongly recommends that you shut down all database instances
        that use the Oracle ASM instance and dismount all file systems mounted
        on Oracle ASM Dynamic Volume Manager (Oracle ADVM) volumes before
        attempting to shut down the Oracle ASM instance with the abort
        (--abort) option.

        The following are examples of the shutdown command.
        The first example performs a shut down of the Oracle ASM instance with
        normal action. The second example performs a shut down with immediate
        action. The third example performs a shut down that aborts all existing
        operations.
        
ASMCMD> shutdown --immediate
ORA-15097: cannot SHUTDOWN ASM instance with connected client (process 13952)
ASMCMD> shutdown --abort
ASM instance shutdown
Connected to an idle instance.
ASMCMD>


spbackup   备份ASM实例的SPFILE

        Backs up an Oracle ASM SPFILE.
        spbackup source destination
        The options for the spbackup command are described below:
        source          - specifies the source name
        destination     - specifies the destination name

        spbackup does not affect the GPnP profile.  The backup file that is
        created is not a special file type and is not identified as a SPFILE.
        The file cannot be copied with spcopy.  To copy this backup file, use
        the ASMCMD cp command

        The following are examples of the spbackup command.
        The first example backs up the Oracle ASM SPFILE from one operating
        system location to another. The second example backs up the SPFILE
        from an operating system location to the DATA disk group.
ASMCMD> spbackup +OHSDBA/ohs/spfile.ora +systemdg/spfile.ora.bak

spcopy  复制asm spfile到新的位置,加-u会更新GPnp profile,如果没加,可以通过spset设置
        Copies an Oracle ASM SPFILE from source to destination.
        spcopy [-u] source destination
        The options for the spcopy command are described below.
        -u              - Updates the Grid Plug and Play (GPnP) profile.
        source          - Specifies the source file name.
        destination     - Specifies the destination.
        After copying the SPFILE, you must restart the instance with the
        SPFILE in the new location if you want to use that SPFILE. When the
        Oracle ASM instance is running with the SPFILE in the new location,
        you can remove the source SPFILE.
ASMCMD> spcopy +SYSTEMDG/ohs-cluster/asmparameterfile/registry.253.911134633 +DATA_PGOLD/spfile.ora
ASMCMD> 

spget   从GPnp中获取asm spfile的位置
        Retrieves the location of the Oracle ASM SPFILE from the Grid Plug
        and Play (GPnP) profile.
ASMCMD> spget
+SYSTEMDG/ohs-cluster/asmparameterfile/registry.253.911134633
ASMCMD>


spmove  移动asm spfile到目的地,并更新GPnp profile

        Moves an Oracle ASM SPFILE from source to destination and
         automatically updates the GPnP profile.
ASMCMD> spget     
+DATA_PGOLD/spfile.ora
ASMCMD> spmove +DATA_PGOLD/spfile.ora +OHSDBA/ohs/spfile.ora
ASMCMD> ls -l +OHSDBA/ohs/spfile.ora
Type              Redund  Striped  Time             Sys  Name
                                                    N    spfile.ora => +OHSDBA/ohs-cluster/ASMPARAMETERFILE/REGISTRY.253.911689503
ASMCMD> spget
+OHSDBA/ohs/spfile.ora
ASMCMD>
重启之后spfile值才会变化
SQL> show parameter spf

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +OHSDBA/ohs/spfile.ora
SQL>

spset   设置GPnp profile中ASM实例spfile的位置
        Set the location of the ORACLE ASM SPFILE in Grid Plug and Play
        (GPnP) profile
ASMCMD> spset +DATA_PGOLD/spfile.ora
ASMCMD> spget
+DATA_PGOLD/spfile.ora
ASMCMD>  


startup 启动asm实例

        Starts up an Oracle ASM instance.
        startup [--nomount] [--restrict] [ --pfile pfile ]
        The options for the startup command are described below.
        --nomount       - Specifies no mount operation.
        --restrict      - Specifies restricted mode.
        --pfile pfile   - Oracle ASM initialization parameter file.

        The default action is a start up that mounts disk groups and enables
        Oracle ADVM volumes.

        The following is an example of the startup command that starts the
        Oracle ASM instance without mounting disk groups and uses the asm_init.
        ora initialization parameter file.

        ASMCMD> startup --nomount --pfile asm_init.ora      
[oracle@ohs1 ~]$ asmcmd -v debug
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory (DBD ERROR: OCISessionBegin)
ASMCMD-8103: failed to connect to ASM; ASMCMD running in non-connected mode, ORACLE_SID='+ASM1'
Connected to an idle instance.
ASMCMD> startup
ASM instance started
Total System Global Area  284565504 bytes
Fixed Size                  1344456 bytes
Variable Size             258055224 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted
ASM diskgroups volume enabled
ASMCMD>

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