Tuesday, June 19, 2012

Renaming ASM Diskgroup

Note: Below example described here are for Renaming EMPTY diskgroup.

While working on Filesystem to ASM migraion project case, I had created necessary diskgroup as mentioned below.
 NAME                         STATE
---------------------------- ------------
ARCHLOG                      MOUNTED
DATAFILE_ORAPROD6            MOUNTED
DATAFILE_ORAPRD7             MOUNTED
LOG1                         MOUNTED
LOG2                         MOUNTED
Before to start the actual migration found DATAFILE_ORAPRD7 dg has typo error it should be like DATAFILE_ORAPRD7 so Instead of dropping the diskgroup I decided to go for rename it. Below are the steps which I followed to rename Diskgroup in 11.2 grid environment. First we need to dismount the DG which we are going to rename. Stop ASM Diskgroup.
oracle:+ASM@linuxprd5 /oracle > asmcmd umount DATAFILE_ORAPRD7
Check the Status of Diskgroup.
oracle:+ASM@linuxprd5 /oracle > crsctl stat res ora.DATAFILE_ORAPRD7.dg
NAME=ora.DATAFILE_ORAPRD7.dg
TYPE=ora.diskgroup.type
TARGET=OFFLINE
STATE=OFFLINE
Now we are good to go for Renaming Diskgroup.
Inorder to Rename any diskgroup in 11.2 gird we can use "renamedg" command.
oracle:+ASM@linuxprd5 /oracle > renamedg phase=both dgname=DATAFILE_ORAPRD7 newdgname=DATAFILE_ORAPROD7 verbose=true

Parsing parameters..

Parameters in effect:

         Old DG name       : DATAFILE_ORAPRD7
         New DG name          : DATAFILE_ORAPROD7
         Phases               :
                 Phase 1
                 Phase 2
         Discovery str        : (null)
         Clean              : TRUE
         Raw only           : TRUE
renamedg operation: phase=both dgname=DATAFILE_ORAPRD7 newdgname=DATAFILE_ORAPROD7 verbose=true
Executing phase 1
Discovering the group
Performing discovery with string:
Identified disk ASM:/opt/oracle/extapi/64/asm/orcl/1/libasm.so:ORCL:DATA_DISK1 with disk number:0 and timestamp (32971243 -722582528)
Identified disk ASM:/opt/oracle/extapi/64/asm/orcl/1/libasm.so:ORCL:DATA_DISK2 with disk number:1 and timestamp (32971243 -722582528)
Checking for hearbeat...
Re-discovering the group
Performing discovery with string:
Identified disk ASM:/opt/oracle/extapi/64/asm/orcl/1/libasm.so:ORCL:DATA_DISK1 with disk number:0 and timestamp (32971243 -722582528)
Identified disk ASM:/opt/oracle/extapi/64/asm/orcl/1/libasm.so:ORCL:DATA_DISK2 with disk number:1 and timestamp (32971243 -722582528)
Checking if the diskgroup is mounted or used by CSS
Checking disk number:0
Checking disk number:1
Generating configuration file..
Completed phase 1
Executing phase 2
Looking for ORCL:DATA_DISK1
Modifying the header
Looking for ORCL:DATA_DISK2
Modifying the header
Completed phase 2
Terminating kgfd context 0x2b4c8410a0a0
oracle:+ASM@linuxprd5 /oracle >
Connect to ASM Instance and verify the new diskgroup name.
oracle:+ASM@linuxprd5 /oracle > sqlplus / as sqlasm
SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 19 03:17:26 2012


Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Automatic Storage Management option


SQL> select name ,state from v$asm_diskgroup;
NAME                          STATE
----------------------------- ----------------
DATAFILE_ORAPROD7             DISMOUNTED  ---> Diskgroup got Renamed Now.
DATAFILE_ORAPROD6             MOUNTED
ARCHLOG                       MOUNTED
LOG1                          MOUNTED
LOG2                          MOUNTED


SQL> alter diskgroup DATAFILE_ORAPROD7 mount;
Diskgroup altered.


SQL> select name ,state from v$asm_diskgroup;
NAME                          STATE
----------------------------- -------------
DATAFILE_ORAPROD7             MOUNTED
DATAFILE_ORAPROD6             MOUNTED
ARCHLOG                       MOUNTED
LOG1                          MOUNTED
LOG2                          MOUNTED

After Renaming the diskgroup we need to remove old diskgroup name from the cluster resource also.
oracle:+ASM@linuxprd5 /oracle > crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCHLOG.dg
               ONLINE  ONLINE       linuxprd5
ora.DATAFILE_ORAPROD6.dg
               ONLINE  ONLINE       linuxprd5
ora.DATAFILE_ORAPRD7.dg
               OFFLINE OFFLINE      linuxprd5   --> Still this resource is not removed from the cluster but its in OFFLINE.
ora.DATAFILE_COORAPROD73A.dg
               ONLINE  ONLINE       linuxprd5
ora.LOG1.dg
               ONLINE  ONLINE       linuxprd5
ora.LOG2.dg
               ONLINE  ONLINE       linuxprd5
ora.asm
               ONLINE  ONLINE       linuxprd5                 Started
ora.ons
               OFFLINE OFFLINE      linuxprd5
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       linuxprd5
ora.diskmon
      1        OFFLINE OFFLINE
ora.evmd
      1        ONLINE  ONLINE       linuxprd5
Below are the detailed info for the new and old diskgroup resource status.
oracle:+ASM@linuxprd5 /oracle > crsctl stat res ora.DATAFILE_ORAPRD7.dg ora.DATAFILE_ORAPROD7.dg
NAME=ora.DATAFILE_ORAPRD7.dg
TYPE=ora.diskgroup.type
TARGET=OFFLINE
STATE=OFFLINE


NAME=ora.DATAFILE_ORAPROD7.dg
TYPE=ora.diskgroup.type
TARGET=ONLINE
STATE=ONLINE on linuxprd5
To remove diksgroup from the cluster resource we can use SRVCTL command.
oracle:+ASM@linuxprd5 /oracle > srvctl remove diskgroup -g DATAFILE_ORAPRD7


oracle:+ASM@linuxprd5 /oracle > crsctl stat res -t
-------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
-------------------------------------------------------------------------------
Local Resources
-------------------------------------------------------------------------------
ora.ARCHLOG.dg
               ONLINE  ONLINE       linuxprd5
ora.DATAFILE_ORAPROD6.dg
               ONLINE  ONLINE       linuxprd5
ora.DATAFILE_ORAPROD7.dg
               ONLINE  ONLINE       linuxprd5
ora.LOG1.dg
               ONLINE  ONLINE       linuxprd5
ora.LOG2.dg
               ONLINE  ONLINE       linuxprd5
ora.asm
               ONLINE  ONLINE       linuxprd5                 Started
ora.ons
               OFFLINE OFFLINE      linuxprd5
-------------------------------------------------------------------------------
Cluster Resources
-------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       linuxprd5
ora.diskmon
      1        OFFLINE OFFLINE
ora.evmd
      1        ONLINE  ONLINE       linuxprd5
How do I rename the ASM disk group with datafile in it?

Before to rename any diskgroup we need to OFFLINE the datafiles which are present in that diskgroup. Then do the rename as described above then all those datafiles needs to be renamed like below, to update the new location in the controlfile.

"alter database datafile file# 'old_path' to 'new_path';

then do recover on those datafiles and open it.

Monday, June 18, 2012

Stopping ASM instance on stand alone database.

Couple of days back, I got a project case to migrate database from Filesystem to ASM, After I installed Grid infrastructure binaries for stand alone server. I created ASM instance manually, then I created necessary diskgroup as below.
NAME                         STATE
---------------------------- -------
ARCHLOG                      MOUNTED
DATAFILE_ORAPROD6            MOUNTED
DATAFILE_ORAPROD7            MOUNTED
LOG1                         MOUNTED
LOG2                         MOUNTED
Before to create above said diskgroups, I am able to start and stop ASM instance but After the diskgroup creation I was not able to stop ASM instance using SRVCTL command. When I tried to stop ASM instance it got failed with below error.
oracle:+ASM@linuxora15 /oracle > srvctl stop asm
PRCR-1065 : Failed to stop resource ora.asm
CRS-2529: Unable to act on 'ora.asm' because that would require stopping or relocating 'ora.LOG2.dg', but the force option was not specified
Then I obsorved that in single instance configuration if any of diskgroup got mounted we can't stop ASM instance untill unless we dismount all diskgroup for that Instance. this is because, from 11g R2 onwards, each diskgroup will have separate service running on each node, after ASM instance started.
oracle:+ASM@linuxora15 /oracle > crs_stat -t
Name           Type           Target    State     Host
-----------------------------------------------------------
ora.ARCHLOG.dg ora....up.type ONLINE    ONLINE    linuxora15
ora....ROD6.dg ora....up.type ONLINE    ONLINE    linuxora15
ora....ROD7.dg ora....up.type ONLINE    ONLINE    linuxora15
ora.LOG1.dg    ora....up.type ONLINE    ONLINE    linuxora15
ora.LOG2.dg    ora....up.type ONLINE    ONLINE    linuxora15
ora.asm        ora.asm.type   ONLINE    ONLINE    linuxora15
ora.cssd       ora.cssd.type  ONLINE    ONLINE    linuxora15
ora.diskmon    ora....on.type OFFLINE   OFFLINE
ora.evmd       ora.evm.type   ONLINE    ONLINE    linuxora15
ora.ons        ora.ons.type   OFFLINE   OFFLINE
Since all diskgroups on this ASM instance are in ONLINE status, I was not able to stop the instance. In this case to stop ASM instance, follow below procedure.
SQL> select name,state from v$asm_diskgroup;
NAME                         STATE
---------------------------- -----------
ARCHLOG                      MOUNTED
DATAFILE_ORAPROD6            MOUNTED
DATAFILE_ORAPROD7            MOUNTED
LOG1                         MOUNTED
LOG2                         MOUNTED

SQL> alter diskgroup all dismount; --> This will dismount all DG on this instance.
Diskgroup altered.
Note : Before to stop diskgroup you should connect to ASM instance with SYSASM privilege
SQL> select name,state from v$asm_diskgroup;
NAME                         STATE
---------------------------- -----------
DATAFILE_ORAPROD6            DISMOUNTED
DATAFILE_ORAPROD7            DISMOUNTED
LOG2                         DISMOUNTED
LOG1                         DISMOUNTED
ARCHLOG                      DISMOUNTED

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Automatic Storage Management option
oracle:+ASM@linuxora15 /oracle >
oracle:+ASM@linuxora15 /oracle > srvctl stop asm

oracle:+ASM@linuxora15 /oracle > crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora.ARCHLOG.dg ora....up.type OFFLINE   OFFLINE
ora....OD69.dg ora....up.type OFFLINE   OFFLINE
ora....D73A.dg ora....up.type OFFLINE   OFFLINE
ora.LOG1.dg    ora....up.type OFFLINE   OFFLINE
ora.LOG2.dg    ora....up.type OFFLINE   OFFLINE
ora.asm        ora.asm.type   OFFLINE   OFFLINE
ora.cssd       ora.cssd.type  ONLINE    ONLINE    linuxora15
ora.diskmon    ora....on.type OFFLINE   OFFLINE
ora.evmd       ora.evm.type   ONLINE    ONLINE    linuxora15
ora.ons        ora.ons.type   OFFLINE   OFFLINE
oracle:+ASM@linuxora15 /oracle >