Thursday, March 12, 2015

How to change disk group name


Pre-requisites:
  When we are planning to change any disk group name
1. Make a note what are the resource is using this disk group name using crsctl,srvctl
2. cross verify whether any database using this disk group in parameter level like archivelog, online redo log files, datafiles, flash recovery area,controlfiles ,backups and spfiles


Note: here I set bash profile like sql='sqlplus /as sysasm' & sql='sqlplus /as sysdba';


step1: Check the cluster status 
[grid@linux01 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
ora.DATA.dg
               ONLINE  ONLINE       linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
ora.OCR_VOTE_DG.dg
               ONLINE  OFFLINE      linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
ora.net1.network
               ONLINE  ONLINE       linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
ora.ons
               ONLINE  ONLINE       linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
ora.proxy_advm
               ONLINE  ONLINE       linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       linux02                  STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       linux01                  STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       linux01                  STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       linux01                  169.254.125.16 192.1
                                                             01.5.11,STABLE
ora.asm
      1        ONLINE  INTERMEDIATE linux01                  STABLE
      2        ONLINE  ONLINE       linux02                  STABLE
ora.cvu
      1        ONLINE  ONLINE       linux01                  STABLE
ora.gns
      1        ONLINE  ONLINE       linux01                  STABLE
ora.gns.vip
      1        ONLINE  ONLINE       linux01                  STABLE
ora.mgmtdb
      1        ONLINE  OFFLINE      linux01                  STARTING
ora.oc4j
      1        ONLINE  ONLINE       linux01                  STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       linux02                  STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       linux01                  STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       linux01                  STABLE
ora.db12c.db
      1        OFFLINE OFFLINE                               STABLE
      2        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
ora.linux01.vip
      1        ONLINE  ONLINE       linux01                  STABLE
ora.linux02.vip
      1        ONLINE  ONLINE       linux02                  STABLE
--------------------------------------------------------------------------------

step 2: Findout the disk group name

[grid@linux01 ~]$ asmcmd
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    307194   303413                0          303413              0             N  DATA/
MOUNTED  NORMAL  N         512   4096  1048576     18426     9758             6142            1808              0             Y  OCR_VOTE_DG/

or

[grid@linux01 ~]$ sql

SQL*Plus: Release 12.1.0.1.0 Production on Thu Mar 5 03:03:20 2015

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL> show parameter asm_disk

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string      OCR_VOTE_DG, DATA
asm_diskstring                       string
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

step 3:  Our aim is to change disk group name from DATA to BASE.

Befoure renaming disk group we have to dismount the disk group across  all the nodes.  Make a note if any data is stored in the disk group like spfile,datafiles,controlfiles,archivelogs, redo logs,ocr files, voting files.

#su - grid
$asmcmd
$umount DATA

[grid@linux01 ~]$ renamedg

Parsing parameters..
KFNDG-01000: USAGE:  renamedg [-phase <phase>] -dgname <dgname> -newdgname <newdgname> [-config <configfile> ] [-check -confirm]
Try renamedg -help for more information

[grid@linux01 ~]$ renamedg -dgname DATA -newdgname BASE verbose=true

Parsing parameters..

Parameters in effect:

         Old DG name       : DATA
         New DG name          : BASE
         Phases               :
                 Phase 1
                 Phase 2
         Discovery str        : (null)
         Clean              : TRUE
         Raw only           : TRUE
renamedg operation: -dgname DATA -newdgname BASE verbose=true
Executing phase 1
Discovering the group
Performing discovery with string:
Identified disk ASM:ASM Library - Generic Linux, version 2.0.4 (KABI_V2):ORCL:DISK4 with disk number:0 and timestamp (33016644 2072692736)
Identified disk ASM:ASM Library - Generic Linux, version 2.0.4 (KABI_V2):ORCL:DISK5 with disk number:1 and timestamp (33016644 2072692736)
Identified disk ASM:ASM Library - Generic Linux, version 2.0.4 (KABI_V2):ORCL:DISK6 with disk number:2 and timestamp (33016644 2072692736)
Checking for hearbeat...
Re-discovering the group
Performing discovery with string:
Identified disk ASM:ASM Library - Generic Linux, version 2.0.4 (KABI_V2):ORCL:DISK4 with disk number:0 and timestamp (33016644 2072692736)
Identified disk ASM:ASM Library - Generic Linux, version 2.0.4 (KABI_V2):ORCL:DISK5 with disk number:1 and timestamp (33016644 2072692736)
Identified disk ASM:ASM Library - Generic Linux, version 2.0.4 (KABI_V2):ORCL:DISK6 with disk number:2 and timestamp (33016644 2072692736)
Checking if the diskgroup is mounted or used by CSS
Checking disk number:0
Checking disk number:1
Checking disk number:2
Generating configuration file..
Completed phase 1
Executing phase 2
Looking for ORCL:DISK4
Modifying the header
Looking for ORCL:DISK5
Modifying the header
Looking for ORCL:DISK6
Modifying the header
Completed phase 2
Terminating kgfd context 0x7f97685990a0

check here , renamedg_config file is created.  There is no error.

[grid@linux01 ~]$ ll
total 16
drwxr-xr-x 3 grid oinstall 4096 Feb 16 04:05 oradiag_grid
-rw-r--r-- 1 grid oinstall   63 Mar  5 03:07 renamedg_config
drwxr-xr-x 3 grid oinstall 4096 Feb 20 05:00 report
-rw-r--r-- 1 grid oinstall 2482 Feb 20 03:52 test.sh

Step 4:  Mount the disk group name

[grid@linux01 ~]$ asmcmd mount BASE
[grid@linux01 ~]$ asmcmd
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    307194   303413                0          303413              0             N  BASE/
MOUNTED  NORMAL  N         512   4096  1048576     18426     9758             6142            1808              0             Y  OCR_VOTE_DG/
ASMCMD> exit


step 5:  Update the disk group name in asm_diskgroup parameters for all nodes.


[grid@linux01 ~]$ sql

SQL*Plus: Release 12.1.0.1.0 Production on Thu Mar 5 03:09:44 2015

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL> show parameter asm

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string      OCR_VOTE_DG, DATA, BASE
asm_diskstring                       string
asm_power_limit                      integer     1
asm_preferred_read_failure_groups    string
SQL> select name from v$asm_diskgroup;

NAME
------------------------------
BASE
OCR_VOTE_DG
SQL> alter system set asm_diskgroups='OCR_VOTE_DG','BASE';

System altered.

SQL> show parameter asm_disk

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string      OCR_VOTE_DG, BASE
asm_diskstring                       string

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options


[grid@linux01 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
ora.BASE.dg
               ONLINE  ONLINE       linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
ora.DATA.dg
               OFFLINE OFFLINE      linux01                  STABLE
               OFFLINE OFFLINE      linux02                  STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
ora.OCR_VOTE_DG.dg
               ONLINE  ONLINE       linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
ora.net1.network
               ONLINE  ONLINE       linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
ora.ons
               ONLINE  ONLINE       linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
ora.proxy_advm
               ONLINE  ONLINE       linux01                  STABLE
               ONLINE  ONLINE       linux02                  STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       linux02                  STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       linux01                  STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       linux01                  STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       linux01                  169.254.125.16 192.1
                                                             01.5.11,STABLE
ora.asm
      1        ONLINE  ONLINE       linux01                  STABLE
      2        ONLINE  ONLINE       linux02                  STABLE
ora.cvu
      1        ONLINE  ONLINE       linux01                  STABLE
ora.gns
      1        ONLINE  ONLINE       linux01                  STABLE
ora.gns.vip
      1        ONLINE  ONLINE       linux01                  STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       linux01                  Open,STABLE
ora.oc4j
      1        ONLINE  ONLINE       linux01                  STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       linux02                  STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       linux01                  STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       linux01                  STABLE
ora.db12c.db
      1        OFFLINE OFFLINE                               STABLE
      2        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
ora.linux01.vip
      1        ONLINE  ONLINE       linux01                  STABLE
ora.linux02.vip
      1        ONLINE  ONLINE       linux02                  STABLE
--------------------------------------------------------------------------------

step 6:  Check the  each database configuation 
[root@linux02 ~]# su - oracle

[oracle@linux02 ~]$ srvctl config database -d db12c
Database unique name: db12c
Database name: db12c
Oracle home: /u01/app/oracle/product/12.1.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/db12c/spfiledb12c.ora
Password file: +DATA/db12c/orapwdb12c
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: db12c
Database instances: db12c1,db12c2
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
Database is administrator managed


[oracle@linux02 ~]$ srvctl modify database -db db12c -spfile +BASE/db12c/spfiledb12c.ora -pwfile +BASE/db12c/orapwdb12c
[oracle@linux02 ~]$ srvctl config database -d db12c
Database unique name: db12c
Database name: db12c
Oracle home: /u01/app/oracle/product/12.1.0/dbhome_1
Oracle user: oracle
Spfile: +BASE/db12c/spfiledb12c.ora
Password file: +BASE/db12c/orapwdb12c
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: db12c
Database instances: db12c1,db12c2
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
Database is administrator managed


[oracle@linux02 ~]$ sql

SQL*Plus: Release 12.1.0.1.0 Production on Thu Mar 5 03:15:01 2015

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

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 2.0176E+10 bytes
Fixed Size                  4264864 bytes
Variable Size            3623881824 bytes
Database Buffers         1.6509E+10 bytes
Redo Buffers               39460864 bytes
SQL> show parameter control

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      +DATA/db12c/CONTROLFILE/curren
                                                 t.257.872659369
control_management_pack_access       string      NONE
SQL> alter system set control_files='+BASE/db12c/CONTROLFILE/current.257.872659369','+BASE' scope=spfile;

System altered.

SQL> exit
Disconnected from Oracle Database 12c Release 12.1.0.1.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options


[oracle@linux02 ~]$ sql

SQL*Plus: Release 12.1.0.1.0 Production on Thu Mar 5 03:17:13 2015

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


Connected to:
Oracle Database 12c Release 12.1.0.1.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL>  alter system set control_files='+BASE/db12c/CONTROLFILE/current.257.872659369' scope=spfile;

System altered.

SQL> shut immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.

Total System Global Area 2.0176E+10 bytes
Fixed Size                  4264864 bytes
Variable Size            3623881824 bytes
Database Buffers         1.6509E+10 bytes
Redo Buffers               39460864 bytes
SQL> show parameter control

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      +BASE/db12c/CONTROLFILE/curren
                                                 t.257.872659369
control_management_pack_access       string      NONE
SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +BASE/db12c/spfiledb12c.ora
SQL> alter database mount;

Database altered.

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/db12c/DATAFILE/system.260.872659369
+DATA/db12c/DATAFILE/sysaux.261.872659373
+DATA/db12c/DATAFILE/undotbs1.262.872659375
+DATA/db12c/DATAFILE/undotbs2.264.872659383
+DATA/db12c/DATAFILE/users.265.872659383


datafiles:


SQL> alter database rename file '+DATA/db12c/DATAFILE/system.260.872659369' to '+BASE/db12c/DATAFILE/system.260.872659369';

Database altered.

SQL> alter database rename file '+DATA/db12c/DATAFILE/sysaux.261.872659373' to '+BASE/db12c/DATAFILE/sysaux.261.872659373';

Database altered.

SQL>  alter database rename file '+DATA/db12c/DATAFILEundotbs1.262.872659375' to '+BASE/db12c/DATAFILE/undotbs1.262.872659375
  2
SQL>
SQL>
SQL> alter database rename file '+DATA/db12c/DATAFILE/undotbs1.262.872659375' to '+BASE/db12c/DATAFILE/undotbs1.262.872659375';

Database altered.

SQL> alter database rename file '+DATA/db12c/DATAFILE/undotbs2.264.872659383' to '+BASE/db12c/DATAFILE/undotbs2.264.872659383';

Database altered.

SQL>  alter database rename file '+DATA/db12c/DATAFILE/users.265.872659383' to '+BASE/db12c/DATAFILE/users.265.872659383';

Database altered.

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
+DATA/db12c/TEMPFILE/temp.263.872659375

SQL> alter database rename file '+DATA/db12c/TEMPFILE/temp.263.872659375' to '+BASE/db12c/TEMPFILE/temp.263.872659375';

Database altered.


redo log files:
+++++++++++++++++++++++++++

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DATA/db12c/ONLINELOG/group_1.258.872659369
+DATA/db12c/ONLINELOG/group_2.259.872659369
+DATA/db12c/ONLINELOG/group_3.266.872661965
+DATA/db12c/ONLINELOG/group_4.267.872661965

SQL> alter database rename file '+DATA/db12c/ONLINELOG/group_1.258.872659369' to '+BASE/db12c/ONLINELOG/group_1.258.872659369';

Database altered.

SQL>  alter database rename file '+DATA/db12c/ONLINELOG/group_2.259.872659369' to '+BASE/db12c/ONLINELOG/group_2.259.872659369';

Database altered.

SQL> alter database rename file '+DATA/db12c/ONLINELOG/group_3.266.872661965' to '+BASE/db12c/ONLINELOG/group_3.266.872661965';

Database altered.

SQL>  alter database rename file '+DATA/db12c/ONLINELOG/group_4.267.872661965' to '+BASE/db12c/ONLINELOG/group_4.267.872661965';

Database altered.

change the archive log path & db_create_file_dest,flash recovery area path ifs it required.



[root@linux02 ~]# su - oracle
[oracle@linux02 ~]$ sql

SQL*Plus: Release 12.1.0.1.0 Production on Thu Mar 5 03:28:24 2015

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


Connected to:
Oracle Database 12c Release 12.1.0.1.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL> select member from gv$logfile;

MEMBER
--------------------------------------------------------------------------------
+BASE/db12c/ONLINELOG/group_1.258.872659369
+BASE/db12c/ONLINELOG/group_2.259.872659369
+BASE/db12c/ONLINELOG/group_3.266.872661965
+BASE/db12c/ONLINELOG/group_4.267.872661965

SQL> alter database open;

Database altered.

change the path in init file


[oracle@linux02 ~]$ cd $ORACLE_HOME
[oracle@linux02 dbhome_1]$ cd dbs
[oracle@linux02 dbs]$ ll
total 524
-rw-rw---- 1 oracle asmadmin   1544 Mar  5 03:29 hc_db12c2.dat
-rw-rw---- 1 oracle asmadmin 524288 Mar  5 03:29 id_db12c2.dat
-rw-r--r-- 1 oracle oinstall   2992 Feb 26 04:10 init.ora
-rw-r----- 1 oracle oinstall     37 Feb 26 06:06 initdb12c2.ora
[oracle@linux02 dbs]$ cat initdb12c2.ora
SPFILE='+DATA/db12c/spfiledb12c.ora'
[oracle@linux02 dbs]$ vi initdb12c2.ora
[oracle@linux02 dbs]$

step 7: remove the disk group name

[oracle@linux01 ~]$ srvctl remove diskgroup -diskgroup DATA;
PRCA-1002 : Failed to remove CRS resource ora.DATA.dg for ASM Disk Group DATA
PRCR-1028 : Failed to remove resource ora.DATA.dg
PRCR-1072 : Failed to unregister resource ora.DATA.dg
CRS-0222: Resource 'ora.DATA.dg' has dependency error.


[oracle@linux01 ~]$ srvctl remove diskgroup -diskgroup DATA -force
[oracle@linux01 ~]$ exit
logout

step 8: add the disk group name to respective database.

[oracle@linux01 ~]$ srvctl modify database -db db12c -diskgroup BASE;

[oracle@linux01 ~]$ srvctl config database -db db12c
Database unique name: db12c
Database name: db12c
Oracle home: /u01/app/oracle/product/12.1.0/dbhome_1
Oracle user: oracle
Spfile: +BASE/db12c/spfiledb12c.ora
Password file: +BASE/db12c/orapwdb12c
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: db12c
Database instances: db12c1,db12c2
Disk Groups: BASE
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
Database is administrator managed
[oracle@linux01 ~]$




No comments:

Post a Comment

Share your knowledge it really improves, don't show off...