Monday, April 20, 2020

Non ASM to ASM migration by RMAN

Non ASM to ASM migration by RMAN.

Datafiles, Redo groups and Archive logs are to be moved to ASM. Optional components are controlfile and spfile.
In this doc SID of the db is taken as TEST.
   
Migration of Datafiles, Redo groups and Tempfiles.
Pre steps.
1.    ASM instance should be up and running.
2.    Mount the db using spfile and create a pfile.
3.    Create required Disk groups on ASM instance.
4.                       i. Take full backup of db by RMAN.   – To minimize the downtime go with image copy method.
RMAN> allocate channel c1 device type disk format '+TEST_DATA';
RMAN> backup as copy database tag  'ASM_migration';                              -- Image copy
                                                      RMAN> backup database tag 'ASM_migration';                                           -- Backup set method

ii.    Take incremental backup if you have full backup and strategy of incremental backup.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Conversion steps.
1.    Take a backup of controlfile and redo to a backup location using cp command.
2.    Update spfile with new value of parameters given below to respective ASM disk group.
Sql> alter system set db_create_file_dest='+TEST_DATA' scope=both;
Sql> alter system set db_create_online_log_dest_1='+TEST_REDO' scope=both;
Sql> alter system set log_archive_dest_1='Location=+TEST_ARCH' scope=both;
3.    Restart the db in mount stage.
4.    Connect db through RMAN.
Below 5, 6, 7 steps are to be performed if the backup is taken as backupset method. Then don’t go with step 8.
5.    Set new location of data files.
RMAN> set newname for datafile 1 to '';   -- do this for all datafiles with their id.
6.    Restore database.
          RMAN> restore database;
7.    Update the control file about the new location of data files.
RMAN> switch datafile all;
Below step is to be performed if the backup is as Image copy method.
8.    Switch database to copy.
         RMAN> switch database to copy;
9.    Recover database.
RMAN> recover database;
10.    Move the temp files to ASM disk group by RMAN.
RMAN> connect target /
RMAN> set newname for tempfile 1 to '+TEST_DATA'; ---- do this for all tempfiles with their id.
RMAN> switch tempfile all;
11.    Open the database.
12.    Move the redo logs to ASM devices by log switch and recreate new log groups with location of ASM disks.

     Migration of Control file.
1.    Restart the db in nomount stage.
2.    Update SPfile to move controlfile to ASM Devices.
     Sql> alter spfile set control_files='+TEST_DATA', scope=spfile;
3.    Restart db in nomount stage.
Sql> shutdown immediate
Sql> startup nomount
4.    Restore control file to ASM disks by RMAN.
                rman target /
RMAN> restore controlfile from <non ASM control file location>; 


Migration of spfile.
1.    Shutdown immediate
2.    Startup mount
3.    Create pfile from spfile;
4.    create spfile='+TEST_DATA' from pfile '$ORACLE_HOME/dbs/inittest.ora';
5.    Login and check the spfile using asmcmd command where ASM instance is running. Location should be something like given below.
+<SID>_DATA/<SID>/PARAMETERFILE/spfile.*****
6.    Make sure we should not have spfile in $ORACLE_HOME/dbs or %ORACLE_HOME%/database location.
7.    Shutdown the database take backup of initfile and remove the contents of initfile and put spfile’s location in pfile.
SPFILE=’+<SID>_DATA/<SID>/PARAMETERFILE/spfile.*****’  in init file.
8.     Startup the db.
9.    Re-link oracle binaries.
10.    Manually verify database parameters,datafiles,redologs,controlfile and spfile location.




This doc is created as per our needs and for my tutorial, If anything goes wrong I am not responsible for the same, before implementing on production or staging be sure to test it on test instance.

No comments:

Post a Comment