0x00 - Introduction to Environment
VMware version: VMware 12pro
Host operating system: RHEL6.5_64
Shared Storage Creates Shared Disk Files Using VMWARE
Database version: Oracle 11gR2 11.2.0.4.0_RAC
Oracle database files are deployed on ASM disk groups and need to complete storage migration without downtime or as short as possible. Because it is only designed for storage replacement, there is no need to use third-party tools. The migration is completed by migrating ASM DISKGROUP. In the simulated reality environment, ASM disk groups are stored on storage devices. Because of device upgrade, storage virtualization integration or storage device obsolescence, storage replacement is needed.
First, use the new ASM GROUP, replace the old storage ASM group with rman copy, and then use ASM Rebalance to migrate back online. Two methods
ASM GROUP-Rman copy migration
0x01 -- Migration step
Data is important, first of all, there should be a complete and recoverable data backup to ensure data security. Then migrate. Before migration, collect the existing information of the database.
1) partition asm disk and check or change UDEV configuration file to make the newly stored asm disk recognizable to ASM instances. 2) Backup OCR, Voting Disk, ASM disk header and database. 3) Create a new DISKGROUP 4) Migrate OCR and Vote Disks to the new disk group (ASM disk group) 5) Migrate ASM Spfile to the new disk group (ASM disk group) 6) Migrate database-related files to the new disk group (ASM disk group) 7) On-line modification of database parameter files (filing path, flash back, etc.) 8) Delete old disk groups 9) Observation period. 10) Perform database backup
0x02 -- New storage partition space
In the simulation environment, VMware is used to create shared disk files to achieve new storage partitioning. Three new 10G shared storage disks, ndata1, ndata2 and ndata3, are created to store data files. Three new 1GB shared storage disks, nocr1, nocr2 and nocr3, are created to store OCR and VOTE information and migrate all the data stored in the original storage.
1 C:\Windows\system32>cd c:\VM\VM12 2 3 c:\VM\VM12>vmware-vdiskmanager.exe -c -s 10240Mb -a lsilogic -t 2 C:\VM\VM12\sharedisk\ndata1.vmdk 4 Creating disk 'C:\VM\VM12\sharedisk\ndata1.vmdk' 5 Create: 100% done. 6 Virtual disk creation successful. 7 8 c:\VM\VM12>vmware-vdiskmanager.exe -c -s 10240Mb -a lsilogic -t 2 C:\VM\VM12\sharedisk\ndata2.vmdk 9 Creating disk 'C:\VM\VM12\sharedisk\ndata2.vmdk' 10 Create: 100% done. 11 Virtual disk creation successful. 12 13 c:\VM\VM12>vmware-vdiskmanager.exe -c -s 10240Mb -a lsilogic -t 2 C:\VM\VM12\sharedisk\ndata3.vmdk 14 Creating disk 'C:\VM\VM12\sharedisk\ndata3.vmdk' 15 Create: 100% done. 16 Virtual disk creation successful. 17 18 c:\VM\VM12>vmware-vdiskmanager.exe -c -s 1024Mb -a lsilogic -t 2 C:\VM\VM12\sharedisk\nocr1.vmdk 19 Creating disk 'C:\VM\VM12\sharedisk\nocr1.vmdk' 20 Create: 100% done. 21 Virtual disk creation successful. 22 23 c:\VM\VM12>vmware-vdiskmanager.exe -c -s 1024Mb -a lsilogic -t 2 C:\VM\VM12\sharedisk\nocr2.vmdk 24 Creating disk 'C:\VM\VM12\sharedisk\nocr2.vmdk' 25 Create: 100% done. 26 Virtual disk creation successful. 27 28 c:\VM\VM12>vmware-vdiskmanager.exe -c -s 1024Mb -a lsilogic -t 2 C:\VM\VM12\sharedisk\nocr3.vmdk 29 Creating disk 'C:\VM\VM12\sharedisk\nocr3.vmdk' 30 Create: 100% done. 31 Virtual disk creation successful.
0x03 -- Virtual Machine Add Disk
Select independent mode, retain the existing format, disk settings, advanced settings, modify virtual device nodes, and local disks are not on the same bus. Six new disks are added to both nodes.
Host side identifies the new scratch disk: sdh, sdi, sdj, three 10GB disks, sdk, sdl, sdm, three 1GB disks.
0x04--Create New ASM diskgroup to create ASM DISKGROUP
View current ASM disk group information
1 ASMCMD> lsdg 2 State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name 3 MOUNTED NORMAL N 512 4096 1048576 23529 18226 10236 3995 0 Y DATA/ 4 MOUNTED EXTERN N 512 4096 1048576 10236 9709 0 9709 0 N ORADATA1/ 5 ASMCMD> 6 7 [grid@myrac1 ~]$ sqlplus / as sysasm 8 9 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 05:22:17 2017 10 11 Copyright (c) 1982, 2013, Oracle. All rights reserved. 12 13 14 Connected to: 15 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 16 With the Real Application Clusters and Automatic Storage Management options 17 18 SQL> select instance_name from v$instance; 19 20 INSTANCE_NAME 21 ---------------- 22 +ASM1 23 24 SQL> col name for a10 25 SQL> set linesize 150 26 SQL> select NAME, ALLOCATION_UNIT_SIZE, STATE, TOTAL_MB, FREE_MB USABLE_FILE_MB from gv$asm_diskgroup; 27 28 NAME ALLOCATION_UNIT_SIZE STATE TOTAL_MB USABLE_FILE_MB 29 ---------- -------------------- ----------- ---------- -------------- 30 DATA 1048576 MOUNTED 23529 18234 31 ORADATA1 1048576 MOUNTED 10236 9709 32 DATA 1048576 MOUNTED 23529 18234 33 ORADATA1 1048576 MOUNTED 10236 9709 34 35 SQL> select failgroup, name from v$asm_disk where group_number=(select group_number from v$asm_diskgroup where name = 'DATA'); 36 37 FAILGROUP NAME 38 ------------------------------ ---------- 39 DATA2 DATA2 40 DATA3 DATA3 41 OCR1 OCR1 42 OCR2 OCR2 43 OCR3 OCR3 44 45 46 SQL> select NAME,PATH,total_mb,free_mb from v$asm_disk; 47 NAME PATH TOTAL_MB FREE_MB 48 ---------- --------------- ---------- ---------- 49 DATA1 ORCL:DATA1 10236 9709 50 DATA2 ORCL:DATA2 10236 8180 51 DATA3 ORCL:DATA3 10236 8200 52 OCR1 ORCL:OCR1 1019 612 53 OCR2 ORCL:OCR2 1019 618 54 OCR3 ORCL:OCR3 1019 616 55 56 6 rows selected. 57 58 SQL>
fdisk partitions new partitioned disks to create ASM disks
1 [root@myrac2 ~]# oracleasm listdisks 2 DATA1 3 DATA2 4 DATA3 5 OCR1 6 OCR2 7 OCR3 8 [root@myrac2 ~]# oracleasm createdisk NDATA1 /dev/sdh1 9 Writing disk header: done 10 Instantiating disk: done 11 [root@myrac2 ~]# oracleasm createdisk NDATA2 /dev/sdi1 12 Writing disk header: done 13 Instantiating disk: done 14 [root@myrac2 ~]# oracleasm createdisk NDATA3 /dev/sdj1 15 Writing disk header: done 16 Instantiating disk: done 17 [root@myrac2 ~]# oracleasm createdisk NOCR1 /dev/sdk1 18 Writing disk header: done 19 Instantiating disk: done 20 [root@myrac2 ~]# oracleasm createdisk NOCR2 /dev/sdl1 21 Writing disk header: done 22 Instantiating disk: done 23 [root@myrac2 ~]# oracleasm createdisk NOCR3 /dev/sdm1 24 Writing disk header: done 25 Instantiating disk: done 26 [root@myrac2 ~]# oracleasm listdisks 27 DATA1 28 DATA2 29 DATA3 30 NDATA1 31 NDATA2 32 NDATA3 33 NOCR1 34 NOCR2 35 NOCR3 36 OCR1 37 OCR2 38 OCR3 39 [root@myrac2 ~]# 40 41 [root@myrac1 ~]# oracleasm scandisks 42 Reloading disk partitions: done 43 Cleaning any stale ASM disks... 44 Scanning system for ASM disks... 45 Instantiating disk "NDATA1" 46 Instantiating disk "NDATA2" 47 Instantiating disk "NDATA3" 48 Instantiating disk "NOCR1" 49 Instantiating disk "NOCR2" 50 Instantiating disk "NOCR3" 51 [root@myrac1 ~]# oracleasm listdisks 52 DATA1 53 DATA2 54 DATA3 55 NDATA1 56 NDATA2 57 NDATA3 58 NOCR1 59 NOCR2 60 NOCR3 61 OCR1 62 OCR2 63 OCR3 64 [root@myrac1 ~]#
0x05 - ASMCA Creates New ASM GROUP
1 SQL> CREATE DISKGROUP NDATA EXTERNAL REDUNDANCY DISK ' /dev/oracleasm/disks/NDATA1' ' /dev/oracleasm/disks/NDATA2 SIZE 10240M ATTRIBUTE 'compatible.asm'='11.2.0.0. 2 0','au_size'='1M' /* ASMCA */ 3 SQL> CREATE DISKGROUP FRA2 EXTERNAL REDUNDANCY DISK '/dev/asm-diskl' SIZE 5120M ATTRIBUTE 'compatible.asm'='11.2.0.0.0' 4 ,'au_size'='1M' /* ASMCA */ 5 6 [grid@myrac1 ~]$ sqlplus / as sysasm 7 8 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 06:41:11 2017 9 10 Copyright (c) 1982, 2013, Oracle. All rights reserved. 11 12 13 Connected to: 14 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 15 With the Real Application Clusters and Automatic Storage Management options 16 17 SQL> select name,state from v$asm_diskgroup; 18 19 NAME STATE 20 ------------------------------ ----------- 21 DATA MOUNTED 22 ORADATA1 MOUNTED 23 NDATA MOUNTED 24 NOCR MOUNTED 25 26 SQL>
0x06 -- Moving OCR & VOTE DISK to new ASM diskgroup migrates OCR and Vote Disks to new disk groups
1 [grid@myrac1 ~]$ ocrcheck 2 Status of Oracle Cluster Registry is as follows : 3 Version : 3 4 Total space (kbytes) : 262120 5 Used space (kbytes) : 3152 6 Available space (kbytes) : 258968 7 ID : 943942235 8 Device/File Name : +ORADATA1 9 Device/File integrity check succeeded 10 11 Device/File not configured 12 13 Device/File not configured 14 15 Device/File not configured 16 17 Device/File not configured 18 19 Cluster registry integrity check succeeded 20 21 Logical corruption check bypassed due to non-privileged user
Add OCR disk groups
1 [root@myrac1 dev]# ocrconfig -add +NOCR 2 [root@myrac1 dev]# ocrcheck 3 Status of Oracle Cluster Registry is as follows : 4 Version : 3 5 Total space (kbytes) : 262120 6 Used space (kbytes) : 3152 7 Available space (kbytes) : 258968 8 ID : 943942235 9 Device/File Name : +ORADATA1 10 Device/File integrity check succeeded 11 Device/File Name : +NOCR 12 Device/File integrity check succeeded 13 14 Device/File not configured 15 16 Device/File not configured 17 18 Device/File not configured 19 20 Cluster registry integrity check succeeded 21 22 Logical corruption check succeeded 23 24 [root@myrac1 dev]#
Delete old OCR disk groups
1 [root@myrac1 ~]# ocrconfig -delete +ORADATA1 2 [root@myrac1 ~]# ocrcheck 3 Status of Oracle Cluster Registry is as follows : 4 Version : 3 5 Total space (kbytes) : 262120 6 Used space (kbytes) : 3152 7 Available space (kbytes) : 258968 8 ID : 943942235 9 Device/File Name : +NOCR 10 Device/File integrity check succeeded 11 12 Device/File not configured 13 14 Device/File not configured 15 16 Device/File not configured 17 18 Device/File not configured 19 20 Cluster registry integrity check succeeded 21 22 Logical corruption check succeeded 23 24 [root@myrac1 ~]#
View votedisks information and migrate to a new disk group
1 [root@myrac1 ~]# crsctl query css votedisk 2 ## STATE File Universal Id File Name Disk group 3 -- ----- ----------------- --------- --------- 4 1. ONLINE 30f8194c62ee4f94bf0da8c5cdd174b6 (ORCL:OCR1) [DATA] 5 2. ONLINE 866e0b01fabc4f29bf3935f9c02bfaea (ORCL:OCR2) [DATA] 6 3. ONLINE 78a869e1fa844f65bf5b2b05cc93bb27 (ORCL:OCR3) [DATA] 7 Located 3 voting disk(s). 8 [root@myrac1 ~]# 9 [root@myrac1 ~]# 10 [root@myrac1 ~]# crsctl replace votedisk +NOCR 11 Successful addition of voting disk 89681e4b76bf4f0fbf09e8d5879af2d4. 12 Successful deletion of voting disk 30f8194c62ee4f94bf0da8c5cdd174b6. 13 Successful deletion of voting disk 866e0b01fabc4f29bf3935f9c02bfaea. 14 Successful deletion of voting disk 78a869e1fa844f65bf5b2b05cc93bb27. 15 Successfully replaced voting disk group with +NOCR. 16 CRS-4266: Voting file(s) successfully replaced 17 [root@myrac1 ~]# crsctl query css votedisk 18 ## STATE File Universal Id File Name Disk group 19 -- ----- ----------------- --------- --------- 20 1. ONLINE 89681e4b76bf4f0fbf09e8d5879af2d4 (ORCL:NOCR1) [NOCR] 21 Located 1 voting disk(s). 22 [root@myrac1 ~]#
0x07--Moving server side ASM SPfile to new ASM diskgroup
1 [grid@myrac1 ~]$ sqlplus / as sysasm 2 3 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 06:51:27 2017 4 5 Copyright (c) 1982, 2013, Oracle. All rights reserved. 6 7 8 Connected to: 9 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 10 With the Real Application Clusters and Automatic Storage Management options 11 12 SQL> show parameter spfile 13 14 NAME TYPE VALUE 15 ------------------------------------ ----------- ------------------------------ 16 spfile string +ORADATA1/myrac-cluster/asmpar 17 ameterfile/asmspfile.ora 18 SQL> exit 19 Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 20 With the Real Application Clusters and Automatic Storage Management options 21 [grid@myrac1 ~]$ asmcmd 22 ASMCMD> spget 23 +ORADATA1/myrac-cluster/asmparameterfile/asmspfile.ora 24 ASMCMD> exit 25 [grid@myrac1 ~]$ sqlplus / as sysasm 26 27 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 06:52:24 2017 28 29 Copyright (c) 1982, 2013, Oracle. All rights reserved. 30 31 32 Connected to: 33 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 34 With the Real Application Clusters and Automatic Storage Management options 35 SQL> create pfile='/tmp/asm_pfile.ora' from spfile; 36 37 File created. 38 39 SQL> create spfile='+NOCR' from pfile='/tmp/asm_pfile.ora'; 40 41 File created. 42 43 SQL>
View ASM log information
1 Thu Feb 09 06:54:35 2017 2 NOTE: updated gpnp profile ASM diskstring: 3 NOTE: updated gpnp profile ASM SPFILE to +NOCR/myrac-cluster/asmparameterfile/registry.253.935477673 4 [grid@myrac1 ~]$ asmcmd 5 ASMCMD> spget 6 +NOCR/myrac-cluster/asmparameterfile/registry.253.935477673 7 ASMCMD>
0x08--Moving database related files to new ASM diskgroup
Migration control file
1 [oracle@myrac1 ~]$ sqlplus / as sysdba 2 3 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 07:00:06 2017 4 5 Copyright (c) 1982, 2013, Oracle. All rights reserved. 6 7 8 Connected to: 9 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 10 With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, 11 Data Mining and Real Application Testing options 12 13 SQL> show parameter control 14 15 NAME TYPE VALUE 16 ------------------------------------ ----------- ------------------------------ 17 control_file_record_keep_time integer 7 18 control_files string +DATA/myrac/controlfile/curren 19 t.256.935374197 20 control_management_pack_access string DIAGNOSTIC+TUNING 21 SQL> alter system set control_files='+NDATA' scope=spfile sid='*'; 22 23 System altered. 24 25 SQL> show parameter control 26 27 NAME TYPE VALUE 28 ------------------------------------ ----------- ------------------------------ 29 control_file_record_keep_time integer 7 30 control_files string +DATA/myrac/controlfile/curren 31 t.256.935374197 32 control_management_pack_access string DIAGNOSTIC+TUNING 33 SQL>
close database
1 [oracle@myrac1 ~]$ srvctl stop database -d myrac 2 [oracle@myrac1 ~]$
Start instance 1 to nomount state
1 [oracle@myrac1 ~]$ srvctl start instance -d myrac -i myrac1 -o nomount 2 [oracle@myrac1 ~]$
RMAN Restore
1 [oracle@myrac1 ~]$ rman target / 2 3 Recovery Manager: Release 11.2.0.4.0 - Production on Thu Feb 9 07:20:16 2017 4 5 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. 6 7 connected to target database: MYRAC (not mounted) 8 9 RMAN> restore controlfile from '+DATA/myrac/controlfile/current.256.935374197'; 10 Starting restore at 09-FEB-17 11 using target database control file instead of recovery catalog 12 allocated channel: ORA_DISK_1 13 channel ORA_DISK_1: SID=34 instance=myrac1 device type=DISK 14 15 channel ORA_DISK_1: copied control file copy 16 output file name=+NDATA/myrac/controlfile/current.257.935479241 17 Finished restore at 09-FEB-17 18 19 RMAN>
Complete migration
1 [oracle@myrac1 ~]$ sqlplus / as sysdba 2 3 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 07:22:11 2017 4 5 Copyright (c) 1982, 2013, Oracle. All rights reserved. 6 7 8 Connected to: 9 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 10 With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, 11 Data Mining and Real Application Testing options 12 13 SQL> alter database mount; 14 15 Database altered. 16 17 SQL> alter database open; 18 19 Database altered. 20 SQL> show parameter control 21 22 NAME TYPE VALUE 23 ------------------------------------ ----------- ------------------------------ 24 control_file_record_keep_time integer 7 25 control_files string +NDATA/myrac/controlfile/curre 26 nt.257.935479241 27 control_management_pack_access string DIAGNOSTIC+TUNING 28 SQL>
0x09--Moving SPfile to new ASM diskgroup
View parameter files
1 SQL> show parameter spfile 2 3 NAME TYPE VALUE 4 ------------------------------------ ----------- ------------------------------ 5 spfile string +ORADATA1/myrac/spfilemyrac.or 6 a 7 SQL> create pfile='/tmp/pfile_db.ora' from spfile; 8 9 File created. 10 11 SQL> create spfile='+NDATA' from pfile='/tmp/pfile_db.ora'; 12 13 File created. 14 15 SQL>
ASMCMD Mobile SPFILE File Location
1 [grid@myrac1 trace]$ asmcmd 2 ASMCMD> spget 3 +NOCR/myrac-cluster/asmparameterfile/registry.253.935477673 4 ASMCMD> ls 5 DATA/ 6 NDATA/ 7 NOCR/ 8 ORADATA1/ 9 ASMCMD> cd ndata 10 ASMCMD> ls 11 MYRAC/ 12 ASMCMD> cd myrac 13 ASMCMD> ls 14 CONTROLFILE/ 15 PARAMETERFILE/ 16 ASMCMD> cd parameterfile 17 ASMCMD> ls 18 spfile.258.935480051 19 ASMCMD> mkalias +NDATA/myrac/parameterfile/spfile.258.935480051 +NDATA/myrac/spfilemyrac.ora 20 ASMCMD> ls -l 21 Type Redund Striped Time Sys Name 22 Y CONTROLFILE/ 23 Y PARAMETERFILE/ 24 N spfilemyrac.ora => +NDATA/MYRAC/PARAMETERFILE/spfile.258.935480051 25 ASMCMD>
Edit spfile
1 [oracle@myrac1 dbs]$ cat initmyrac1.ora 2 SPFILE='+ORADATA1/myrac/spfilemyrac.ora' # line added by Agent 3 [oracle@myrac1 dbs]$ vim initmyrac1.ora 4 [oracle@myrac1 dbs]$ cat initmyrac1.ora 5 SPFILE='+NDATA/myrac/spfilemyrac.ora' # line added by Agent 6 [oracle@myrac1 dbs]$ 7 8 [oracle@myrac2 dbs]$ cat initmyrac2.ora 9 SPFILE='+ORADATA1/myrac/spfilemyrac.ora' # line added by Agent 10 [oracle@myrac2 dbs]$ vim initmyrac2.ora 11 [oracle@myrac2 dbs]$ cat initmyrac2.ora 12 SPFILE='+NDATA/myrac/spfilemyrac.ora' # line added by Agent 13 [oracle@myrac2 dbs]$
srvctl modifies the location of database parameter files
1 [oracle@myrac1 dbs]$ srvctl modify database -d myrac -p +NDATA/MYRAC/spfilemyrac.ora 2 [oracle@myrac1 dbs]$ srvctl config database -d myrac 3 Database unique name: myrac 4 Database name: myrac 5 Oracle home: /u01/app/oracle/product/11.2/db_1 6 Oracle user: oracle 7 Spfile: +NDATA/MYRAC/spfilemyrac.ora 8 Domain: weidong.zhang 9 Start options: open 10 Stop options: immediate 11 Database role: PRIMARY 12 Management policy: AUTOMATIC 13 Server pools: myrac 14 Database instances: myrac1,myrac2 15 Disk Groups: ORADATA1,DATA,NDATA 16 Mount point paths: 17 Services: 18 Type: RAC 19 Database is administrator managed
Start with new spfile and control file to verify correctness
1 [oracle@myrac1 ~]$ srvctl start database -d myrac 2 [oracle@myrac1 dbs]$ sqlplus / as sysdba 3 4 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 08:36:24 2017 5 6 Copyright (c) 1982, 2013, Oracle. All rights reserved. 7 8 9 Connected to: 10 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 11 With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, 12 Data Mining and Real Application Testing options 13 14 SQL> show parameter spfile 15 16 NAME TYPE VALUE 17 ------------------------------------ ----------- ------------------------------ 18 spfile string +NDATA/myrac/spfilemyrac.ora 19 SQL> 20 SQL> show parameter control 21 22 NAME TYPE VALUE 23 ------------------------------------ ----------- ------------------------------ 24 control_file_record_keep_time integer 7 25 control_files string +NDATA/myrac/controlfile/curre 26 nt.257.935479241 27 control_management_pack_access string DIAGNOSTIC+TUNING 28 SQL>
0x0A--Moving data files to new ASM diskgroup
1 SQL> archive log list; 2 Database log mode Archive Mode 3 Automatic archival Enabled 4 Archive destination +DATA 5 Oldest online log sequence 35 6 Next log sequence to archive 36 7 Current log sequence 36 8 9 [oracle@myrac1 dbs]$ rman target / 10 11 Recovery Manager: Release 11.2.0.4.0 - Production on Thu Feb 9 08:41:47 2017 12 13 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. 14 15 connected to target database: MYRAC (DBID=42893065) 16 17 RMAN> backup as copy database format '+NDATA'; 18 19 Starting backup at 09-FEB-17 20 using target database control file instead of recovery catalog 21 allocated channel: ORA_DISK_1 22 channel ORA_DISK_1: SID=56 instance=myrac1 device type=DISK 23 channel ORA_DISK_1: starting datafile copy 24 input datafile file number=00001 name=+DATA/myrac/datafile/system.261.935388681 25 output file name=+NDATA/myrac/datafile/system.259.935484205 tag=TAG20170209T084324 RECID=16 STAMP=935484210 26 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07 27 channel ORA_DISK_1: starting datafile copy 28 input datafile file number=00002 name=+DATA/myrac/datafile/sysaux.264.935388699 29 output file name=+NDATA/myrac/datafile/sysaux.260.935484213 tag=TAG20170209T084324 RECID=17 STAMP=935484218 30 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07 31 channel ORA_DISK_1: starting datafile copy 32 input datafile file number=00006 name=+DATA/myrac/datafile/test_temp_tablespace.268.935388711 33 output file name=+NDATA/myrac/datafile/test_temp_tablespace.261.935484219 tag=TAG20170209T084324 RECID=18 STAMP=935484222 34 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 35 channel ORA_DISK_1: starting datafile copy 36 input datafile file number=00003 name=+DATA/myrac/datafile/undotbs1.265.935388707 37 output file name=+NDATA/myrac/datafile/undotbs1.262.935484223 tag=TAG20170209T084324 RECID=19 STAMP=935484223 38 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 39 channel ORA_DISK_1: starting datafile copy 40 input datafile file number=00005 name=+DATA/myrac/datafile/undotbs2.267.935388709 41 output file name=+NDATA/myrac/datafile/undotbs2.263.935484225 tag=TAG20170209T084324 RECID=20 STAMP=935484224 42 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 43 channel ORA_DISK_1: starting datafile copy 44 copying current control file 45 output file name=+NDATA/myrac/controlfile/backup.264.935484227 tag=TAG20170209T084324 RECID=21 STAMP=935484229 46 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 47 channel ORA_DISK_1: starting datafile copy 48 input datafile file number=00004 name=+DATA/myrac/datafile/users.266.935388709 49 output file name=+NDATA/myrac/datafile/users.265.935484231 tag=TAG20170209T084324 RECID=22 STAMP=935484231 50 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:04 51 channel ORA_DISK_1: starting full datafile backup set 52 channel ORA_DISK_1: specifying datafile(s) in backup set 53 including current SPFILE in backup set 54 channel ORA_DISK_1: starting piece 1 at 09-FEB-17 55 channel ORA_DISK_1: finished piece 1 at 09-FEB-17 56 piece handle=+NDATA/myrac/backupset/2017_02_09/nnsnf0_tag20170209t084324_0.266.935484233 tag=TAG20170209T084324 comment=NONE 57 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03 58 Finished backup at 09-FEB-17 59 60 ==================================
1 [oracle@myrac1 ~]$ srvctl stop database -d myrac -o immediate 2 [oracle@myrac1 ~]$ sqlplus / as sysdba 3 4 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 08:47:32 2017 5 6 Copyright (c) 1982, 2013, Oracle. All rights reserved. 7 8 Connected to an idle instance. 9 10 SQL> startup mount 11 ORACLE instance started. 12 13 Total System Global Area 1653518336 bytes 14 Fixed Size 2253784 bytes 15 Variable Size 1493175336 bytes 16 Database Buffers 150994944 bytes 17 Redo Buffers 7094272 bytes 18 Database mounted. 19 SQL> 20 =============================================== 21 [oracle@myrac1 dbs]$ rman target / 22 23 Recovery Manager: Release 11.2.0.4.0 - Production on Thu Feb 9 08:48:39 2017 24 25 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. 26 27 connected to target database: MYRAC (DBID=42893065, not open) 28 29 RMAN> switch database to copy; 30 31 using target database control file instead of recovery catalog 32 datafile 1 switched to datafile copy "+NDATA/myrac/datafile/system.259.935484205" 33 datafile 2 switched to datafile copy "+NDATA/myrac/datafile/sysaux.260.935484213" 34 datafile 3 switched to datafile copy "+NDATA/myrac/datafile/undotbs1.262.935484223" 35 datafile 4 switched to datafile copy "+NDATA/myrac/datafile/users.265.935484231" 36 datafile 5 switched to datafile copy "+NDATA/myrac/datafile/undotbs2.263.935484225" 37 datafile 6 switched to datafile copy "+NDATA/myrac/datafile/test_temp_tablespace.261.935484219" 38 39 RMAN> recover database; 40 41 Starting recover at 09-FEB-17 42 allocated channel: ORA_DISK_1 43 channel ORA_DISK_1: SID=37 instance=myrac1 device type=DISK 44 45 starting media recovery 46 media recovery complete, elapsed time: 00:00:01 47 48 Finished recover at 09-FEB-17 49 50 RMAN>
Start the database
1 [oracle@myrac1 ~]$ srvctl stop database -d myrac 2 [oracle@myrac1 ~]$ srvctl start database -d myrac 3 [oracle@myrac1 dbs]$ sqlplus / as sysdba 4 5 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 08:57:56 2017 6 7 Copyright (c) 1982, 2013, Oracle. All rights reserved. 8 9 10 Connected to: 11 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 12 With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, 13 Data Mining and Real Application Testing options 14 15 SQL> 16 SQL> SQL> select file_name from dba_data_files; 17 18 FILE_NAME 19 -------------------------------------------------------------------------------- 20 +NDATA/myrac/datafile/users.265.935484231 21 +NDATA/myrac/datafile/undotbs1.262.935484223 22 +NDATA/myrac/datafile/sysaux.260.935484213 23 +NDATA/myrac/datafile/system.259.935484205 24 +NDATA/myrac/datafile/undotbs2.263.935484225 25 +NDATA/myrac/datafile/test_temp_tablespace.261.935484219 26 27 6 rows selected. 28 29 SQL>
0x0B--Moving temp files to new ASM diskgroup
1 SQL> select file_name from dba_temp_files; 2 3 FILE_NAME 4 -------------------------------------------------------------------------------- 5 +DATA/myrac/tempfile/temp.258.935389865 6 7 SQL>
Modify the db_create_file_dest parameter
1 SQL> show parameter db_c 2 3 NAME TYPE VALUE 4 ------------------------------------ ----------- ------------------------------ 5 db_cache_advice string ON 6 db_cache_size big integer 0 7 db_create_file_dest string +DATA 8 db_create_online_log_dest_1 string 9 db_create_online_log_dest_2 string 10 db_create_online_log_dest_3 string 11 db_create_online_log_dest_4 string 12 db_create_online_log_dest_5 string 13 SQL> alter system set db_create_file_dest = '+NDATA'; 14 15 System altered. 16 17 SQL> show parameter db_c 18 19 NAME TYPE VALUE 20 ------------------------------------ ----------- ------------------------------ 21 db_cache_advice string ON 22 db_cache_size big integer 0 23 db_create_file_dest string +NDATA 24 db_create_online_log_dest_1 string 25 db_create_online_log_dest_2 string 26 db_create_online_log_dest_3 string 27 db_create_online_log_dest_4 string 28 db_create_online_log_dest_5 string 29 SQL>
Adding temporary documents
1 ##Since the db_create_file_dest parameter has been set, it will be created directly on NDATA 2 SQL> select file_name from dba_temp_files; 3 4 FILE_NAME 5 -------------------------------------------------------------------------------- 6 +DATA/myrac/tempfile/temp.258.935389865 7 8 SQL> alter tablespace temp add tempfile; 9 10 Tablespace altered. 11 12 SQL> select file_name from dba_temp_files; 13 14 FILE_NAME 15 -------------------------------------------------------------------------------- 16 +NDATA/myrac/tempfile/temp.267.935485927 17 +DATA/myrac/tempfile/temp.258.935389865
Delete the original temporary file
1 SQL> alter tablespace temp drop tempfile '+DATA/myrac/tempfile/temp.258.935389865'; 2 3 Tablespace altered. 4 5 SQL> select file_name from dba_temp_files; 6 7 FILE_NAME 8 -------------------------------------------------------------------------------- 9 +NDATA/myrac/tempfile/temp.267.935485927 10 11 SQL>
0x0C--Moving online redo log files to new ASM diskgroup
SQL> select group#,member from v$logfile; GROUP# MEMBER ---------- --------------------------------------------- 1 +DATA/myrac/onlinelog/group_1.269.935390433 2 +DATA/myrac/onlinelog/group_2.270.935390443 3 +DATA/myrac/onlinelog/group_3.271.935390447 4 +DATA/myrac/onlinelog/group_4.272.935390453 1 +DATA/myrac/onlinelog/group_1.273.935390965 2 +DATA/myrac/onlinelog/group_2.274.935390973 3 +DATA/myrac/onlinelog/group_3.275.935390977 4 +DATA/myrac/onlinelog/group_4.276.935390983 8 rows selected.
Add a new disk group to the logfile log group
1 SQL> alter database add logfile member '+NDATA' ,'+NDATA' to group 1; 2 3 Database altered. 4 5 SQL> alter database add logfile member '+NDATA' ,'+NDATA' to group 2; 6 7 Database altered. 8 9 SQL> alter database add logfile member '+NDATA' ,'+NDATA' to group 3; 10 11 Database altered. 12 13 SQL> alter database add logfile member '+NDATA' ,'+NDATA' to group 4; 14 15 Database altered. 16 17 SQL> alter database add logfile member '+NDATA' ,'+NDATA' to group 5; 18 19 Database altered.
Delete the original log member (Note: Switch to a non-current log for deletion)
Delete the original log group members in turn
1 SQL>alter database drop logfile member '+DATA/myrac/onlinelog/group_3.275.935390977';
If it cannot be deleted, manual log switching can be performed
1 alter system switch logfile; 2 alter system checkpoint;
1 SQL> select log.group#,log.status,logfile.member from v$log log, v$logfile logfile where log.group#=logfile.group# order by group#; 2 3 GROUP# STATUS MEMBER 4 ---------- ---------------- --------------------------------------------- 5 1 INACTIVE +NDATA/myrac/onlinelog/group_1.277.935488433 6 1 INACTIVE +NDATA/myrac/onlinelog/group_1.278.935489653 7 2 CURRENT +NDATA/myrac/onlinelog/group_2.269.935487101 8 2 CURRENT +NDATA/myrac/onlinelog/group_2.273.935487191 9 3 INACTIVE +NDATA/myrac/onlinelog/group_3.270.935487107 10 3 INACTIVE +NDATA/myrac/onlinelog/group_3.274.935487197 11 4 CURRENT +NDATA/myrac/onlinelog/group_4.271.935487115 12 4 CURRENT +NDATA/myrac/onlinelog/group_4.275.935487203 13 5 INACTIVE +NDATA/myrac/onlinelog/group_5.276.935487665 14 5 INACTIVE +NDATA/myrac/onlinelog/group_5.272.935490035
0x0D - Modify Flash Back Zone, File Path
1 SQL> show parameter recover 2 3 NAME TYPE VALUE 4 ------------------------------------ ----------- ------------------------------ 5 db_recovery_file_dest string +DATA 6 db_recovery_file_dest_size big integer 4407M 7 db_unrecoverable_scn_tracking boolean TRUE 8 recovery_parallelism integer 0 9 SQL>
1 SQL> 2 SQL> alter system set db_recovery_file_dest='+NDATA'; 3 System altered. 4
1 SQL> show parameter recover 2 3 NAME TYPE VALUE 4 ------------------------------------ ----------- ------------------------------ 5 db_recovery_file_dest string +NDATA 6 db_recovery_file_dest_size big integer 4407M 7 db_unrecoverable_scn_tracking boolean TRUE 8 recovery_parallelism integer 0 9 SQL> archive log list 10 Database log mode Archive Mode 11 Automatic archival Enabled 12 Archive destination +DATA 13 Oldest online log sequence 50 14 Next log sequence to archive 51 15 Current log sequence 51
1 SQL> alter system set log_archive_dest_1='location=+NDATA'; 2 3 System altered.
1 SQL> archive log list 2 Database log mode Archive Mode 3 Automatic archival Enabled 4 Archive destination +NDATA 5 Oldest online log sequence 50 6 Next log sequence to archive 51 7 Current log sequence 51 8 SQL>
0x0E--Dropping old disk groups, delete old disk groups
1 [grid@myrac1 ~]$ sqlplus / as sysasm 2 3 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 10:45:50 2017 4 5 Copyright (c) 1982, 2013, Oracle. All rights reserved. 6 7 8 Connected to: 9 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 10 With the Real Application Clusters and Automatic Storage Management options 11 12 SQL> alter diskgroup data dismount; 13 14 Diskgroup altered. 15 16 SQL> alter diskgroup oradata1 dismount; 17 18 Diskgroup altered. 19 20 [grid@myrac2 ~]$ sqlplus / as sysasm 21 22 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 10:51:39 2017 23 24 Copyright (c) 1982, 2013, Oracle. All rights reserved. 25 26 27 Connected to: 28 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 29 With the Real Application Clusters and Automatic Storage Management options 30 31 SQL> alter diskgroup data dismount; 32 33 Diskgroup altered. 34 35 SQL> alter diskgroup oradata1 dismount; 36 37 Diskgroup altered. 38 39 SQL> 40 41 SQL> drop diskgroup data including contents; 42 drop diskgroup data including contents 43 * 44 ERROR at line 1: 45 ORA-15039: diskgroup not dropped 46 ORA-15001: diskgroup "DATA" does not exist or is not mounted 47 SQL> drop diskgroup data force including contents; 48 drop diskgroup data force including contents 49 * 50 ERROR at line 1: 51 ORA-15039: diskgroup not dropped 52 ORA-15073: diskgroup DATA is mounted by another ASM instance 53 54 55 SQL> drop diskgroup data force including contents; 56 57 Diskgroup dropped. 58 59 SQL> drop diskgroup oradata1 force including contents; 60 61 Diskgroup dropped. 62 63 SQL>
Remove the disks from OCR
1 [root@myrac1 ~]# srvctl remove diskgroup -g DATA 2 PRCA-1002 : Failed to remove CRS resource ora.DATA.dg for ASM Disk Group DATA 3 PRCR-1028 : Failed to remove resource ora.DATA.dg 4 PRCR-1072 : Failed to unregister resource ora.DATA.dg 5 CRS-0222: Resource 'ora.DATA.dg' has dependency error. 6 [root@myrac1 ~]# srvctl modify database -d myrac -a "NDATA,NOCR" 7 [root@myrac1 ~]# srvctl remove diskgroup -g DATA 8 [root@myrac1 ~]# srvctl remove diskgroup -g ORADATA1
So far, the storage migration has been completed. The database needs to be restarted many times, there is a small amount of downtime, do a good job of data backup.
This article was first published by myself. Yunqi Community Blog