Saturday, August 24, 2024

RMAN Restoration to New Server with Same Database Name using Backup

 


RMAN Restoration to New Server with Same Database Name Using Backup 

Environment:

Source Details:

DB Version            : Oracle 19.0.0.0.0
File system                : Normal
Database Name : DEV
        DB_UNIQUE_NAME  : DEV 
Oracle Home Path: /u02/app/oracle1/product/19.3/db/

Target Details:


DB Version          : Oracle 19.0.0.0.0
File system               : Normal
Database Name : DEV
        DB_UNIQUE_NAME  : DEV
Oracle Home Path: /u03/app/oracle/product/19c/db_1/


Backup the Source Database:

Here, cold backup is taken by having the database in mount state.


[oracle@dev RMAN]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Sat Aug 24 08:40:26 2024
Version 19.23.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DEV (DBID=4255322729, not open)

RMAN> run {
        ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT '/u01/BACKUP/RMAN/dev_%U_%T.%p';
        ALLOCATE CHANNEL disk2 DEVICE TYPE DISK FORMAT '/u01/BACKUP/RMAN/dev_%U_%T.%p';
        crosscheck archivelog all;
         delete noprompt expired archivelog all;
         backup as compressed backupset incremental level 0 database plus archivelog ;
          backup current controlfile format '/u01/BACKUP/RMAN/dev_controlfile_%U_%T.%p';
          release channel disk1;
         release channel disk2;
    }
 exit;
using target database control file instead of recovery catalog
allocated channel: disk1
channel disk1: SID=258 device type=DISK

allocated channel: disk2
channel disk2: SID=25 device type=DISK

validation succeeded for archived log
archived log file name=/u02/app/oracle1/fast_recovery_area/DEV/archivelog/2024_08_14/o1_mf_1_13_mctnpbmf_.arc RECID=2 STAMP=1177016330
validation succeeded for archived log
archived log file name=/u02/app/oracle1/fast_recovery_area/DEV/archivelog/2024_08_14/o1_mf_1_12_mctnp9st_.arc RECID=1 STAMP=1177016330
validation succeeded for archived log
archived log file name=/u02/app/oracle1/fast_recovery_area/DEV/archivelog/2024_08_14/o1_mf_1_14_mctrbqlp_.arc RECID=3 STAMP=1177020056
validation succeeded for archived log
archived log file name=/u02/app/oracle1/fast_recovery_area/DEV/archivelog/2024_08_15/o1_mf_1_15_mcvbrv0n_.arc RECID=4 STAMP=1177038939
validation succeeded for archived log
archived log file name=/u02/app/oracle1/fast_recovery_area/DEV/archivelog/2024_08_18/o1_mf_1_16_md545h1q_.arc RECID=5 STAMP=1177359855
validation succeeded for archived log
archived log file name=/u02/app/oracle1/fast_recovery_area/DEV/archivelog/2024_08_20/o1_mf_1_17_md86jxof_.arc RECID=6 STAMP=1177460573
validation succeeded for archived log
archived log file name=/u02/app/oracle1/fast_recovery_area/DEV/archivelog/2024_08_21/o1_mf_1_18_mddkkvr6_.arc RECID=7 STAMP=1177602940
validation succeeded for archived log
archived log file name=/u02/app/oracle1/fast_recovery_area/DEV/archivelog/2024_08_21/o1_mf_1_19_mddkwm2v_.arc RECID=8 STAMP=1177603283
validation succeeded for archived log
archived log file name=/u02/app/oracle1/fast_recovery_area/DEV/archivelog/2024_08_21/o1_mf_1_20_mddkwo6z_.arc RECID=9 STAMP=1177603285
Crosschecked 5 objects

validation succeeded for archived log
archived log file name=/u02/app/oracle1/fast_recovery_area/DEV/archivelog/2024_08_21/o1_mf_1_21_mddkwrgo_.arc RECID=10 STAMP=1177603288
Crosschecked 5 objects


specification does not match any archived log in the repository


Starting backup at 24-AUG-24
channel disk1: starting compressed archived log backup set
channel disk1: specifying archived log(s) in backup set
input archived log thread=1 sequence=12 RECID=1 STAMP=1177016330
input archived log thread=1 sequence=13 RECID=2 STAMP=1177016330
input archived log thread=1 sequence=14 RECID=3 STAMP=1177020056
input archived log thread=1 sequence=15 RECID=4 STAMP=1177038939
channel disk1: starting piece 1 at 24-AUG-24
channel disk2: starting compressed archived log backup set
channel disk2: specifying archived log(s) in backup set
input archived log thread=1 sequence=16 RECID=5 STAMP=1177359855
input archived log thread=1 sequence=17 RECID=6 STAMP=1177460573
input archived log thread=1 sequence=18 RECID=7 STAMP=1177602940
input archived log thread=1 sequence=19 RECID=8 STAMP=1177603283
input archived log thread=1 sequence=20 RECID=9 STAMP=1177603285
channel disk2: starting piece 1 at 24-AUG-24
channel disk2: finished piece 1 at 24-AUG-24
piece handle=/u01/BACKUP/RMAN/dev_0a338mfu_10_1_1_20240824.1 tag=TAG20240824T084030 comment=NONE
channel disk2: backup set complete, elapsed time: 00:00:07
channel disk2: starting compressed archived log backup set
channel disk2: specifying archived log(s) in backup set
input archived log thread=1 sequence=21 RECID=10 STAMP=1177603288
channel disk2: starting piece 1 at 24-AUG-24
channel disk2: finished piece 1 at 24-AUG-24
piece handle=/u01/BACKUP/RMAN/dev_0b338mg6_11_1_1_20240824.1 tag=TAG20240824T084030 comment=NONE
channel disk2: backup set complete, elapsed time: 00:00:01
channel disk1: finished piece 1 at 24-AUG-24
piece handle=/u01/BACKUP/RMAN/dev_09338mfu_9_1_1_20240824.1 tag=TAG20240824T084030 comment=NONE
channel disk1: backup set complete, elapsed time: 00:00:11
Finished backup at 24-AUG-24

Starting backup at 24-AUG-24
channel disk1: starting compressed incremental level 0 datafile backup set
channel disk1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u02/app/oracle1/oradata/DEV/datafile/o1_mf_system_mcsnymx3_.dbf
input datafile file number=00003 name=/u02/app/oracle1/oradata/DEV/datafile/o1_mf_sysaux_mcsnzq7l_.dbf
channel disk1: starting piece 1 at 24-AUG-24
channel disk2: starting compressed incremental level 0 datafile backup set
channel disk2: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/app/oracle1/oradata/DEV/datafile/o1_mf_undotbs1_mcso06c4_.dbf
input datafile file number=00005 name=/u02/app/oracle1/oradata/DEV/datafile/o1_mf_ram_mcvbxyy4_.dbf
input datafile file number=00007 name=/u02/app/oracle1/oradata/DEV/datafile/o1_mf_users_mcso07fl_.dbf
channel disk2: starting piece 1 at 24-AUG-24
channel disk2: finished piece 1 at 24-AUG-24
piece handle=/u01/BACKUP/RMAN/dev_0d338mg9_13_1_1_20240824.1 tag=TAG20240824T084041 comment=NONE
channel disk2: backup set complete, elapsed time: 00:00:03
channel disk1: finished piece 1 at 24-AUG-24
piece handle=/u01/BACKUP/RMAN/dev_0c338mg9_12_1_1_20240824.1 tag=TAG20240824T084041 comment=NONE
channel disk1: backup set complete, elapsed time: 00:00:45
Finished backup at 24-AUG-24

Starting backup at 24-AUG-24
specification does not match any archived log in the repository
backup cancelled because there are no files to backup
Finished backup at 24-AUG-24

Starting backup at 24-AUG-24
channel disk1: starting full datafile backup set
channel disk1: specifying datafile(s) in backup set
including current control file in backup set
channel disk1: starting piece 1 at 24-AUG-24
channel disk1: finished piece 1 at 24-AUG-24
piece handle=/u01/BACKUP/RMAN/dev_controlfile_0e338mhm_14_1_1_20240824.1 tag=TAG20240824T084126 comment=NONE
channel disk1: backup set complete, elapsed time: 00:00:01
Finished backup at 24-AUG-24

Starting Control File and SPFILE Autobackup at 24-AUG-24
piece handle=/u02/app/oracle1/fast_recovery_area/DEV/autobackup/2024_08_24/o1_mf_s_1177835939_mdmo7rkv_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 24-AUG-24

released channel: disk1

released channel: disk2

RMAN> exit

Creating pfile in Source database:
SQL> create pfile from spfile;

File created.
Transfer the Backup and pfile to Target Server using scp:
[oracle@dev db]$ cd /u01/BACKUP/RMAN/
[oracle@dev RMAN]$ ls -lrt
total 772752
-rw-r-----. 1 oracle oinstall  91238912 Aug 24 08:40 dev_0a338mfu_10_1_1_20240824.1
-rw-r-----. 1 oracle oinstall     12800 Aug 24 08:40 dev_0b338mg6_11_1_1_20240824.1
-rw-r-----. 1 oracle oinstall 132897792 Aug 24 08:40 dev_09338mfu_9_1_1_20240824.1
-rw-r-----. 1 oracle oinstall   4857856 Aug 24 08:40 dev_0d338mg9_13_1_1_20240824.1
-rw-r-----. 1 oracle oinstall 551600128 Aug 24 08:41 dev_0c338mg9_12_1_1_20240824.1
-rw-r-----. 1 oracle oinstall  10682368 Aug 24 08:41 dev_controlfile_0e338mhm_14_1_1_20240824.1
[oracle@dev RMAN]$
[oracle@dev RMAN]$
[oracle@dev RMAN]$ scp * oracle:192.168.56.31:/u01/RMAN
ssh: Could not resolve hostname oracle: Name or service not known
lost connection
[oracle@dev RMAN]$ scp * oracle@192.168.56.31:/u01/RMAN
oracle@192.168.56.31's password:
dev_09338mfu_9_1_1_20240824.1                                                               100%  127MB 122.4MB/s   00:01
dev_0a338mfu_10_1_1_20240824.1                                                              100%   87MB 122.5MB/s   00:00
dev_0b338mg6_11_1_1_20240824.1                                                              100%   13KB  14.5MB/s   00:00
dev_0c338mg9_12_1_1_20240824.1                                                              100%  526MB 105.2MB/s   00:05
dev_0d338mg9_13_1_1_20240824.1                                                              100% 4744KB  90.4MB/s   00:00
dev_controlfile_0e338mhm_14_1_1_20240824.1                                                  100%   10MB  93.5MB/s   00:00


[oracle@dev dbs]$ scp initdev.ora oracle@192.168.56.31:/u03/app/oracle/product/19c/db_1/dbs
oracle@192.168.56.31's password:
initdev.ora   


Connect to Target Database:

Add entry in /etc/oratab:
[oracle@dev dbs]$ cat /etc/oratab
#



# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
#   $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third field indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
dev:/u03/app/oracle/product/19c/db_1:N
Restoration Steps:

Check the pfile, modify the directory names and create the required directories:

[oracle@dev dbs]$ pwd /u03/app/oracle/product/19c/db_1/dbs [oracle@dev dbs]$ cat initdev.ora *.audit_file_dest='/u03/app/oracle/admin/dev/adump' *.audit_trail='db' *.compatible='19.0.0' *.control_files='/u03/app/oracle/oradata/DEV/controlfile/o1_mf_mcso19od_.ctl','/u03/app/oracle/fast_recovery_area/DEV/controlfile/o1_mf_mcso19oz_.ctl' *.db_block_size=8192 *.db_create_file_dest='/u03/app/oracle/oradata' *.db_name='dev' *.db_recovery_file_dest='/u03/app/oracle/fast_recovery_area' *.db_recovery_file_dest_size=8256m *.diagnostic_dest='/u03/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=devXDB)' *.enable_goldengate_replication=TRUE *.local_listener='LISTENER_DEV' *.open_cursors=300 *.pga_aggregate_target=996m *.processes=300 *.remote_login_passwordfile='EXCLUSIVE' *.sga_target=2986m *.undo_tablespace='UNDOTBS1'


Create the required directories:

[oracle@dev dbs]$ mkdir -p /u03/app/oracle/admin/dev/adump [oracle@dev dbs]$ mkdir -p /u03/app/oracle/oradata/DEV [oracle@dev dbs]$ [oracle@dev dbs]$ mkdir -p /u03/app/oracle/fast_recovery_area/DEV [oracle@dev dbs]$ [oracle@dev dbs]$ mkdir -p /u03/app/oracle/oradata


Start the database in nomount stage, restore the controlfile and mount the database:

[oracle@dev dbs]$ sqlplus / as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Sat Aug 24 18:30:35 2024 Version 19.3.0.0.0 Copyright (c) 1982, 2019, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount pfile='/u03/app/oracle/product/19c/db_1/dbs/initdev.ora'; ORACLE instance started. Total System Global Area 3137336136 bytes Fixed Size 8901448 bytes Variable Size 637534208 bytes Database Buffers 2483027968 bytes Redo Buffers 7872512 bytes SQL> exit Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.3.0.0.0


[oracle@dev RMAN]$ rman target / Recovery Manager: Release 19.0.0.0.0 - Production on Sat Aug 24 18:31:21 2024 Version 19.3.0.0.0 Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved. connected to target database: DEV (not mounted) RMAN> restore controlfile from '/u01/RMAN/dev_controlfile_0e338mhm_14_1_1_20240824.1'; Starting restore at 24-AUG-24 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=22 device type=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 output file name=/u03/app/oracle/oradata/DEV/controlfile/o1_mf_mcso19od_.ctl output file name=/u03/app/oracle/fast_recovery_area/DEV/controlfile/o1_mf_mcso19oz_.ctl Finished restore at 24-AUG-24 RMAN> alter database mount; released channel: ORA_DISK_1 Statement processed

Catalog the backup location:

RMAN> catalog start with '/u01/RMAN/';
Starting implicit crosscheck backup at 24-AUG-24 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=20 device type=DISK Crosschecked 13 objects Finished implicit crosscheck backup at 24-AUG-24 Starting implicit crosscheck copy at 24-AUG-24 using channel ORA_DISK_1 Finished implicit crosscheck copy at 24-AUG-24 searching for all files in the recovery area cataloging files... no files cataloged searching for all files that match the pattern /u01/RMAN/ List of Files Unknown to the Database ===================================== File Name: /u01/RMAN/dev_09338mfu_9_1_1_20240824.1 File Name: /u01/RMAN/dev_0a338mfu_10_1_1_20240824.1 File Name: /u01/RMAN/dev_0b338mg6_11_1_1_20240824.1 File Name: /u01/RMAN/dev_0c338mg9_12_1_1_20240824.1 File Name: /u01/RMAN/dev_0d338mg9_13_1_1_20240824.1 File Name: /u01/RMAN/dev_controlfile_0e338mhm_14_1_1_20240824.1 Do you really want to catalog the above files (enter YES or NO)? yes cataloging files... cataloging done List of Cataloged Files ======================= File Name: /u01/RMAN/dev_09338mfu_9_1_1_20240824.1 File Name: /u01/RMAN/dev_0a338mfu_10_1_1_20240824.1 File Name: /u01/RMAN/dev_0b338mg6_11_1_1_20240824.1 File Name: /u01/RMAN/dev_0c338mg9_12_1_1_20240824.1 File Name: /u01/RMAN/dev_0d338mg9_13_1_1_20240824.1 File Name: /u01/RMAN/dev_controlfile_0e338mhm_14_1_1_20240824.1

Restore the Database:

RMAN> run { set newname for database to "/u03/app/oracle/oradata/DEV/%b"; ALLOCATE CHANNEL disk1 DEVICE TYPE DISK; ALLOCATE CHANNEL disk2 DEVICE TYPE DISK; restore database; SWITCH DATAFILE ALL; release channel disk1; release channel disk2; } 2> 3> 4> 5> 6> 7> 8> 9> 10> executing command: SET NEWNAME released channel: ORA_DISK_1 allocated channel: disk1 channel disk1: SID=20 device type=DISK allocated channel: disk2 channel disk2: SID=259 device type=DISK Starting restore at 24-AUG-24 channel disk1: starting datafile backup set restore channel disk1: specifying datafile(s) to restore from backup set channel disk1: restoring datafile 00004 to /u03/app/oracle/oradata/DEV/o1_mf_undotbs1_mcso06c4_.dbf channel disk1: restoring datafile 00005 to /u03/app/oracle/oradata/DEV/o1_mf_ram_mcvbxyy4_.dbf channel disk1: restoring datafile 00007 to /u03/app/oracle/oradata/DEV/o1_mf_users_mcso07fl_.dbf channel disk1: reading from backup piece /u01/RMAN/dev_0d338mg9_13_1_1_20240824.1 channel disk2: starting datafile backup set restore channel disk2: specifying datafile(s) to restore from backup set channel disk2: restoring datafile 00001 to /u03/app/oracle/oradata/DEV/o1_mf_system_mcsnymx3_.dbf channel disk2: restoring datafile 00003 to /u03/app/oracle/oradata/DEV/o1_mf_sysaux_mcsnzq7l_.dbf channel disk2: reading from backup piece /u01/RMAN/dev_0c338mg9_12_1_1_20240824.1 channel disk1: piece handle=/u01/RMAN/dev_0d338mg9_13_1_1_20240824.1 tag=TAG20240824T084041 channel disk1: restored backup piece 1 channel disk1: restore complete, elapsed time: 00:00:07 channel disk2: piece handle=/u01/RMAN/dev_0c338mg9_12_1_1_20240824.1 tag=TAG20240824T084041 channel disk2: restored backup piece 1 channel disk2: restore complete, elapsed time: 00:01:05 Finished restore at 24-AUG-24 datafile 1 switched to datafile copy input datafile copy RECID=6 STAMP=1177872040 file name=/u03/app/oracle/oradata/DEV/datafile/o1_mf_system_mdmpwh55_.dbf datafile 3 switched to datafile copy input datafile copy RECID=7 STAMP=1177872040 file name=/u03/app/oracle/oradata/DEV/datafile/o1_mf_sysaux_mdmpwh6h_.dbf datafile 4 switched to datafile copy input datafile copy RECID=8 STAMP=1177872040 file name=/u03/app/oracle/oradata/DEV/datafile/o1_mf_undotbs1_mdmpwh56_.dbf datafile 5 switched to datafile copy input datafile copy RECID=9 STAMP=1177872040 file name=/u03/app/oracle/oradata/DEV/datafile/o1_mf_ram_mdmpwh7w_.dbf datafile 7 switched to datafile copy input datafile copy RECID=10 STAMP=1177872040 file name=/u03/app/oracle/oradata/DEV/datafile/o1_mf_users_mdmpwh8l_.dbf released channel: disk1 released channel: disk2

In this case, recovery is not required as I have used cold backup.

Now open the Database:

RMAN> alter database open; Statement processed RMAN> RMAN> RMAN> exit


Connect to database and verify datafiles, tempfiles and logfiles:




No comments:

Post a Comment

RMAN Restoration to New Server with Same Database Name using Backup

  RMAN Restoration to New Server with Same Database Name Using Backup  Environment: Source Details: DB Version            : Oracle 19.0...