Prepare Source for migration

Oracle

Audience
Public
Technology Integrations
Oracle
Source Type
Documentation

One of the primary benefits of container databases is that it can contain multiple pluggable databases. As we are going to mount the Source volumes on the Target host, we need to make sure that there are no naming conflicts with objects already in the Target database. To avoid conflicts, we'll rename volume labels, disks, disk groups/mount points, etc. as a preparatory step on the Source itself. In our demonstration, we will be renaming the disk groups DATA and FRA to DATA_99 and FRA_99 respectively.

Create file rename scripts

Create scripts on dbtest39 to rename data, temp and log files for use later on in the process.


SQL> select 'ALTER DATABASE RENAME FILE '''||member||'''to'''||replace(replace(member,'+DATA/','+DATA_39/'),'+FRA/','+FRA_39/') ||''';' 
     from v$logfile;

ALTER DATABASE RENAME FILE '+DATA/DBTEST39/ONLINELOG/group_3.264.1038414809' to '+DATA_39/DBTEST39/ONLINELOG/group_3.264.1038414809';
ALTER DATABASE RENAME FILE '+FRA/DBTEST39/ONLINELOG/group_3.283.1038414811' to '+FRA_39/DBTEST39/ONLINELOG/group_3.283.1038414811';
ALTER DATABASE RENAME FILE '+DATA/DBTEST39/ONLINELOG/group_2.263.1038414809' to '+DATA_39/DBTEST39/ONLINELOG/group_2.263.1038414809';
ALTER DATABASE RENAME FILE '+FRA/DBTEST39/ONLINELOG/group_2.261.1038414811' to '+FRA_39/DBTEST39/ONLINELOG/group_2.261.1038414811';
ALTER DATABASE RENAME FILE '+DATA/DBTEST39/ONLINELOG/group_1.262.1038414809' to '+DATA_39/DBTEST39/ONLINELOG/group_1.262.1038414809';
ALTER DATABASE RENAME FILE '+FRA/DBTEST39/ONLINELOG/group_1.260.1038414811' to '+FRA_39/DBTEST39/ONLINELOG/group_1.260.1038414811';


SQL> select 'ALTER DATABASE RENAME FILE ''' || file_name ||''' to '''|| replace(replace(file_name,'+DATA/','+DATA_39/'),'+FRA/','+FRA_39/') 
      || ''';' from dba_data_files;
      
ALTER DATABASE RENAME FILE '+DATA/DBTEST39/DATAFILE/users.260.1038414745' to '+DATA_39/DBTEST39/DATAFILE/users.260.1038414745';
ALTER DATABASE RENAME FILE '+DATA/DBTEST39/DATAFILE/undotbs1.259.1038414745' to '+DATA_39/DBTEST39/DATAFILE/undotbs1.259.1038414745';
ALTER DATABASE RENAME FILE '+DATA/DBTEST39/DATAFILE/system.257.1038414695' to '+DATA_39/DBTEST39/DATAFILE/system.257.1038414695';
ALTER DATABASE RENAME FILE '+DATA/DBTEST39/DATAFILE/sysaux.258.1038414729' to '+DATA_39/DBTEST39/DATAFILE/sysaux.258.1038414729';


SQL> select 'ALTER DATABASE RENAME FILE ''' || file_name ||''' to '''|| replace(replace(file_name,'+DATA/','+DATA_39/'),'+FRA/','+FRA_39/') 
  || ''';' from dba_temp_files;
  
ALTER DATABASE RENAME FILE '+DATA/DBTEST39/TEMPFILE/temp.265.1038414815' to '+DATA_39/DBTEST39/TEMPFILE/temp.265.1038414815';

Create a plain text format pfile from spfile.


SQL> show parameter spfile
+DATA/DBTEST39/PARAMETERFILE/spfile.266.1038415035 

SQL> create pfile from spfile;

Rename Disk Groups

Dismount the diskgroups. Use the force option if needed.


SQL> alter diskgroup FRA dismount;
Diskgroup altered.
SQL> alter diskgroup DATA dismount;
alter diskgroup DATA dismount
*
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15027: active use of diskgroup "DATA" precludes its dismount

SQL> alter diskgroup DATA dismount force;
Diskgroup altered.

Run the renamedg command with check=true. This will only run a check to identify any potential issues and will not make any changes.


[grid@sn1-r720-e03-17 ~]$ renamedg dgname=data newdgname=data_39 verbose=true check=true asm_diskstring='/dev/oracleasm/disks/*'

Parameters in effect:

         Old DG name       : DATA 
         New DG name          : DATA_39 
         Phases               :
                 Phase 1
                 Phase 2
         Discovery str        : /dev/oracleasm/disks/* 
         Check              : TRUE
         Clean              : TRUE
         Raw only           : TRUE
renamedg operation: dgname=data newdgname=data_39 verbose=true check=true asm_diskstring=/dev/oracleasm/disks/*
Executing phase 1
Discovering the group
Performing discovery with string:/dev/oracleasm/disks/*
Identified disk UFS:/dev/oracleasm/disks/DATA01 with disk number:0 and timestamp (33100352 346500096)
Checking for hearbeat...
Re-discovering the group
Performing discovery with string:/dev/oracleasm/disks/*
Identified disk UFS:/dev/oracleasm/disks/DATA01 with disk number:0 and timestamp (33100352 346500096)
Checking if the diskgroup is mounted or used by CSS 
Checking disk number:0
Generating configuration file..
Completed phase 1
Executing phase 2
Looking for /dev/oracleasm/disks/DATA01
Leaving the header unchanged
Completed phase 2

Now that the check ran fine, we run the command without check parameter


[grid@sn1-r720-e03-17 ~]$ renamedg dgname=data newdgname=data_39 verbose=true asm_diskstring='/dev/oracleasm/disks/*'

Parameters in effect:

         Old DG name       : DATA 
         New DG name          : DATA_39 
         Phases               :
                 Phase 1
                 Phase 2
         Discovery str        : /dev/oracleasm/disks/* 
         Clean              : TRUE
         Raw only           : TRUE
renamedg operation: dgname=data newdgname=data_39 verbose=true asm_diskstring=/dev/oracleasm/disks/*
Executing phase 1
Discovering the group
Performing discovery with string:/dev/oracleasm/disks/*
Identified disk UFS:/dev/oracleasm/disks/DATA01 with disk number:0 and timestamp (33100352 346500096)
Checking for hearbeat...
Re-discovering the group
Performing discovery with string:/dev/oracleasm/disks/*
Identified disk UFS:/dev/oracleasm/disks/DATA01 with disk number:0 and timestamp (33100352 346500096)
Checking if the diskgroup is mounted or used by CSS 
Checking disk number:0
Generating configuration file..
Completed phase 1
Executing phase 2
Looking for /dev/oracleasm/disks/DATA01
Modifying the header
Completed phase 2

Repeat the renamedg command for all other disk groups.

Start the database with renamed diskgroups

The disk groups have been renamed. Let's mount the disk groups so that we can start the database.


SQL> alter diskgroup DATA_39 mount;
Diskgroup altered.

SQL> alter diskgroup FRA_39 mount; 
Diskgroup altered.

ASMCMD should show the disk groups to be in MOUNTED state.


ASMCMD> lsdg
State    Type    Rebal  Sector  L. Sector  Block       AU  Total_MB  Free_MB  Req_mir_fr_MB  Usable_file_MB  OffL_disks  Vtg_files  Name
MOUNTED  EXTERN  N         512        512   4096  1048576   2097152  2094615              0         2094615           0          N  DATA_39/
MOUNTED  EXTERN  N         512        512   4096  1048576   2097152  2096433              0         2096433           0          N  FRA_39/

Before we can start the database, we need to modify the diskgroup dependency.


[grid@sn1-r720-e03-17 ~]$ srvctl modify database -d dbtest39 -diskgroup "DATA_39,FRA_39"

We need to startup the database in mount state so that we can rename the database files to reference the new disk groups DATA_39 and FRA_39 instead of DATA and FRA.

Modify the pfile created earlier and replace references to the old disk groups with the new ones. Specifically, the following parameters will need changes.


*.control_files='+DATA_39/DBTEST39/CONTROLFILE/current.261.1038414807','+FRA_39/DBTEST39/CONTROLFILE/current.273.1038414807'
*.db_create_file_dest='+DATA_39'
*.db_recovery_file_dest='+FRA_39'

Startup mount the database


[oracle@sn1-r720-e03-17 dbs]$ sqlplus / as sysdba

SQL> startup mount pfile='initdbtest39.ora';
ORACLE instance started.
Database mounted.

Run the previously created rename scripts to change the data, temp, and log file paths to reference the new disk groups.


SQL> alter database open;
Database altered.

This is a good logical point to take a snapshot of the protection group on the Source that includes volumes for the Source database. In case something goes wrong in the subsequent steps, you can restore volumes from this snapshot and resume from here.


$ SUFFIX=after-renamedg
$ ssh -l ${FA_USER} ${FA_IP} purepgroup snap --suffix $SUFFIX oracle-dbtest39-pg

Rename ASMLib label

As we will be mounting the Source ASM disks in the Target ASM instance, we need to make sure that the ASMLib disk names are unique.

Shutdown the database and ASM. Then run oracleasm renamedisk with the force option to rename the disks.


[root@sn1-r720-e03-17 ~]# oracleasm renamedisk -f /dev/mapper/oracle-rt-dbtest39-data DATA_39_01
Writing disk header: done
Instantiating disk "DATA_39_01": done
[root@sn1-r720-e03-17 ~]# oracleasm renamedisk -f /dev/mapper/oracle-rt-dbtest39-fra FRA_39_01
Writing disk header: done
Instantiating disk "FRA_39_01": done

If we list the disks, it shows both old and new ones.


[root@sn1-r720-e03-17 ~]# oracleasm listdisks
DATA01
DATA_39_01
FRA01
FRA_39_01

Run oracleasm scandisks to clear the old ones.


[root@sn1-r720-e03-17 ~]# oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Cleaning disk "DATA01"
Cleaning disk "FRA01"

Rename ASM Disk name

We will also rename the ASM disk names.


SQL> alter diskgroup  data_39 dismount;
Diskgroup altered.

SQL> alter diskgroup  data_39 mount restricted;

Diskgroup altered.

SQL> alter diskgroup  fra_39 dismount;

Diskgroup altered.

SQL> alter diskgroup fra_39 mount restricted;

Diskgroup altered.

 
SQL> alter diskgroup  data_39 rename disk 'DATA_0000' to 'DATA_0000_39';

Diskgroup altered.

SQL> alter diskgroup fra_39 rename disk 'FRA_0000' to 'FRA_0000_39';

Diskgroup altered.