Navigation Bar

Saturday, July 20, 2024

Restore a full rman backup of a database on another server

For details of connecting 2 linux machines using a ethernet cable you can refer to the link below

Connect two linux machines with ethernet cable or a LAN crossover cable 

To take a full database backup you can refer to 

To restore a database with an RMAN backup after the database has been dropped

Copy all the backups files from source server alpha to target server beta.
scp oracle@192.168.56.101:/home/oracle/backup/BackupALPHA_DB_013004t3_1_1_1_%S_%P oracle@192.168.56.102:/home/oracle/backup/BackupALPHA_DB_013004t3_1_1_1_%S_%P
scp oracle@192.168.56.101:/home/oracle/backup/BackupALPHA_DB_023004v4_2_1_1_%S_%P oracle@192.168.56.102:/home/oracle/backup/BackupALPHA_DB_023004v4_2_1_1_%S_%P
scp oracle@192.168.56.101:/home/oracle/backup/BackupALPHA_DB_0330058n_3_1_1_%S_%P oracle@192.168.56.102:/home/oracle/backup/BackupALPHA_DB_0330058n_3_1_1_%S_%P
scp oracle@192.168.56.101:/home/oracle/backup/BackupALPHA_DB_043005bc_4_1_1_%S_%P oracle@192.168.56.102:/home/oracle/backup/BackupALPHA_DB_043005bc_4_1_1_%S_%P
scp oracle@192.168.56.101:/home/oracle/backup/BackupALPHA_DB_053005cc_5_1_1_%S_%P oracle@192.168.56.102:/home/oracle/backup/BackupALPHA_DB_053005cc_5_1_1_%S_%P
Copy autobackup from source server alpha to target server beta
scp oracle@192.168.56.101:/home/oracle/backup/c-1700090799-20240717-00 oracle@192.168.56.102:/home/oracle/backup/c-1700090799-20240717-00
Copy all the archivelog files from source server alpha to target server beta
scp oracle@192.168.56.101:/home/oracle/backup/arch1_1_1174402480.dbf oracle@192.168.56.102:/home/oracle/backup/arch1_1_1174402480.dbf
scp oracle@192.168.56.101:/home/oracle/backup/arch1_2_1174402480.dbf oracle@192.168.56.102:/home/oracle/backup/arch1_2_1174402480.dbf
scp oracle@192.168.56.101:/home/oracle/backup/arch1_3_1174402480.dbf oracle@192.168.56.102:/home/oracle/backup/arch1_3_1174402480.dbf
scp oracle@192.168.56.101:/home/oracle/backup/arch1_4_1174402480.dbf oracle@192.168.56.102:/home/oracle/backup/arch1_4_1174402480.dbf
For restoration steps can refer the link below
https://theoraclereference.blogspot.com/2024/07/restore-database-with-rman-backup-after.html
after restore, you can open the database with reset logs.
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/app/oracle/oradata/ALPHA/system01.dbf'
If you get error as shown above, from rman you can try to recover the database.
RMAN> recover database;

Starting recover at 22-MAY-24
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=28 device type=DISK

starting media recovery
media recovery failed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 05/22/2024 20:50:08
ORA-00283: recovery session canceled due to errors
RMAN-11003: failure during parse/execution of SQL statement: alter database recover
 if needed start until cancel using backup controlfile
ORA-00283: recovery session canceled due to errors
ORA-19912: cannot recover to target incarnation 3
Then you can do the following
SQL> select fhdbn, fhdbi, hxfil, fhsta, fhscn, fhafs, fhrba_seq, fhtnm tbs_name, substr(hxfnm,1,70) file_name from x$kcvfh
SQL> /

ALPHA	  2901288553	      1       8192 2694445		0		      4
SYSTEM			   /u01/app/oracle/oradata/ALPHA/system01.dbf

ALPHA	  2901288553	      3 	 0 2694445		0		      4
SYSAUX			       /u01/app/oracle/oradata/ALPHA/sysaux01.dbf

ALPHA	  2901288553	      4 	 0 2694445		0		      4
UNDOTBS1		       /u01/app/oracle/oradata/ALPHA/undotbs01.dbf

ALPHA	  2901288553	      5       8192 2648996		0		      3
SYSTEM			       /u01/app/oracle/oradata/ALPHA/pdbseed/system01.dbf

ALPHA	  2901288553	      6 	 0 2648996		0		      3
SYSAUX			       /u01/app/oracle/oradata/ALPHA/pdbseed/sysaux01.dbf

ALPHA	  2901288553	      7 	 0 2694445		0		      4
USERS			       /u01/app/oracle/oradata/ALPHA/users01.dbf

ALPHA	  2901288553	      8 	 0 2648996		0		      3
UNDOTBS1		       /u01/app/oracle/oradata/ALPHA/pdbseed/undotbs01.dbf

ALPHA	  2901288553	      9       8192 2692668		0		      4
SYSTEM			       /u01/app/oracle/oradata/ALPHA/alphapdb1/system01.dbf

ALPHA	  2901288553	     10 	 0 2692668		0		      4
SYSAUX			      /u01/app/oracle/oradata/ALPHA/alphapdb1/sysaux01.dbf      

ALPHA	  2901288553	     11 	 0 2692668		0		      4

UNDOTBS1		      /u01/app/oracle/oradata/ALPHA/alphapdb1/undotbs01.dbf 

ALPHA	  2901288553	     12 	 0 2692668		0		      4
USERS			      /u01/app/oracle/oradata/ALPHA/alphapdb1/users01.dbf 

ALPHA	  2901288553	     13 	 0 2692668		0		      4
RMAN_CATALOG		  /u01/app/oracle/oradata/RMANDBALPHA/rmanalpha_catalog.dbf      

12 rows selected.
SQL> alter database backup controlfile to trace;
SQL> shutdown immediate
SQL> startup nomount
With the data selected above can create the controlfile as follows.
SQL>CREATE CONTROLFILE REUSE DATABASE "ALPHA" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 15
MAXLOGHISTORY 292
LOGFILE 
 GROUP 1 (
   '/u01/app/oracle/oradata/ALPHA/redo01.log',
   '/u01/app/oracle/fast_recovery_area/ALPHA/redo01.log'
   ) SIZE 200M BLOCKSIZE 512,
  GROUP 2 (
   '/u01/app/oracle/oradata/ALPHA/redo02.log',
   '/u01/app/oracle/fast_recovery_area/ALPHA/redo02.log'
   ) SIZE 200M BLOCKSIZE 512,
  GROUP 3 (
   '/u01/app/oracle/oradata/ALPHA/redo03.log',
   '/u01/app/oracle/fast_recovery_area/ALPHA/redo03.log'
   ) SIZE 200M BLOCKSIZE 512
DATAFILE
  '/u01/app/oracle/oradata/ALPHA/system01.dbf',
'/u01/app/oracle/oradata/ALPHA/sysaux01.dbf',
'/u01/app/oracle/oradata/ALPHA/undotbs01.dbf',
'/u01/app/oracle/oradata/ALPHA/pdbseed/system01.dbf',
'/u01/app/oracle/oradata/ALPHA/pdbseed/sysaux01.dbf',
'/u01/app/oracle/oradata/ALPHA/users01.dbf',			       
'/u01/app/oracle/oradata/ALPHA/pdbseed/undotbs01.dbf',
'/u01/app/oracle/oradata/ALPHA/alphapdb1/system01.dbf',
'/u01/app/oracle/oradata/ALPHA/alphapdb1/sysaux01.dbf',
'/u01/app/oracle/oradata/ALPHA/alphapdb1/undotbs01.dbf',
'/u01/app/oracle/oradata/ALPHA/alphapdb1/users01.dbf',
'/u01/app/oracle/oradata/RMANDBALPHA/rmanalpha_catalog.dbf'
CHARACTER SET AL32UTF8;

controlfile created.
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00603: ORACLE server session terminated by fatal error
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-65088: database open should be retried
Process ID: 15265
Session ID: 271 Serial number: 59691

SQL> shutdown immediate;
SQL> startup mount;
ORACLE instance started.

Total System Global Area 2717907456 bytes
Fixed Size		    9689600 bytes
Variable Size		  620756992 bytes
Database Buffers	 2080374784 bytes
Redo Buffers		    7086080 bytes
Database mounted.

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01139: RESETLOGS option only valid after an incomplete database recovery

SQL> alter database open;

Database altered.

SQL> alter pluggable database all open;
If you get error, then we need to recover the pluggable database.
ERROR at line 1:

ORA-01190: control file or data file 9 is from before the last RESETLOGS
ORA-01110: data file 1: '/u01/app/oracle/oradata/ALPHA/alphapdb1/system01.dbf'

RMAN> recover pluggable database alphapdb1;
RMAN> recover pluggable database alphapdb1;

Starting recover at 22-MAY-24
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=279 device type=DISK

starting media recovery

archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oracle/homes/OraDB21Home3/dbs/arch1_1_1169673954.dbf
archived log file name=/u01/app/oracle/homes/OraDB21Home3/dbs/arch1_4_1174402480.dbf thread=1 sequence=4
media recovery complete, elapsed time: 00:00:04
Finished recover at 22-MAY-24
SQL> alter pluggable database all open;

PLuggable database altered.

God's Word for the Day 

Do not enter the path of the wicked, and do not walk in the way of evildoers. 
Avoid it; do not go on it; turn away from it and pass on. 
For they cannot sleep unless they have done wrong;
They are robbed of sleep unless they have made someone stumble. 
Proverbs 4: 14-16

Gospel teachings of Jesus

Ture Greatness
An argument arose among his disciples as to which one
  among them was the greatest. But Jesus, aware of their
inner thoughts, took a little child and put it by his side,
  and said to them, "Whoever welcomes this child in my
name welcomes me, and whoever welcomes me welcomes the 
  one who sent me; for the least among all of you is the greatest." 
Mathew 14:13-21

No comments:

Post a Comment