How to Restore RAC database from Tape backup

 

Introduction

In this article, We shall see a step by step Restore of  a RAC database from tape backup using RMAN tool. Oracle Secure Backup (OSB) supplies reliable data protection through file system backup to tape.

The Oracle Secure Backup SBT interface enables you to use Recovery Manager (RMAN) to back up Oracle databases. All major tape drives and tape libraries in SAN, Gigabit Ethernet, and SCSI environments are supported.

Import and backup catalog

  First enter the tape that holds the backup data to be restored from into the OSB  tape server machine.

Then log in to the OSB client ,in our case, 10.50.11.33 using named user credential and then Go to Manage menu section and    Navigate to Manage → Libraries → select Libraries → select inventory from library commands →click Apply 

How to Restore RAC database from Tape backup

And then click OK as shown below.

restore database in oracle

Check  the available volumes

Select List Volumes → Check if the volume is available in the main slot or not. (Magazine).

How to Restore RAC database from Tape backup

If the volume is not available → Move volume from mail slot to any vacant main slot (Magazine).

Navigate to Manage → Libraries → select Libraries → select Move Volume → enter Element spec (element_spec) number and Element spec (element_spec) for main slot → Apply

restore database in oracle

And then click OK as shown below.

restore database in oracle

If the volume id is not visible or barcode not shown choose the identify volume command from library commands and choose the drive that contain the volume →click Apply → click Ok.

restore database in oracle

If the volume id is not visible or barcode not shown choose the Inventory(Library |Drive)command from library commands and choose the drive that contain the volume →click Apply → click Ok.

restore database in oracle

Catalog import

After the volume is available and the volume id is visible we can proceed to Manage → Catalog Imports

and then Enter the Barcode or the Volume ID of the tape.

OSB catalog import

And then click Go.

Monitor ‘Catalog Import’ progress

To monitor the catalog import progress Go to Manage → jobs → select the required from view option and click Apply.

Below it shows the catalog import job after completed.

After catalog import is completed, you may start the file system restore (copy backup file from tape to disk).

Backup Catalog

                Go to Restore → Backup Catalog  from Data Selector, tick on Latest or choose the date

How to Restore RAC database from Tape backup

Under Browse Options:

Enter Host name where the backup to tape copy (through osb) is taken from.

Under ‘Browse Host’ click on the _ link on the top.

OSB Backup catalog

From the links on the top, check the one containing the link of the backup’s directory (In our case: Backup_SSD/

How to Restore RAC database from Tape backup

Choose the day containing the backup (Example:Monday):

How to Restore RAC database from Tape backup

Choose the date of the backup (Example: 22082022) and choose the host and then click on ‘Add’ button.

How to Restore RAC database from Tape backup

 Enter the directory of the backup under the Alternate path: /mnt/Monday/22082022  and under the host enter the destination of the server which the backup is getting copied to .

How to Restore RAC database from Tape backup

Stop the database and edit pfile

Stop the  RAC database with the following command:

[oracle@uatserver$] srvctl stop database –d UATDB

Edit the pfile parameter file:

[oracle@uatserver$] nano pfile.ora

Edit the following lines in the pfile  and comment all lines referring to the second instance, instance 2. And also set cluster_database initialization parameter to False.

#*.cluster_database_instances=2

*.cluster_database=false

#wfcprod2.undo_tablespace='UNDOTBS2'

#wfcprod2.thread=2

 

Startup database in restrict mode

SQL>startup mount exclusive restrict pfile='/export/home/oracle/pfile.ora';

We need to add the ‘exclusive’ keyword for RAC. If it is not started due to memory problem (out of memory), edit the pfile to lower the sga max and sga target.

Drop the database

SQL> drop database;    //if you want to restore the database from scratch (and if you don’t have enough space) 

Startup nomount

SQL>startup nomount pfile='/export/home/oracle/pfile.ora';

Then Copy the path of the full backup’s directory, in our case , /mnt/Thursday/11082022. And check the size of the +DATA and +FRA to know if there is enough space for backup.

oracle@uatserver:~$ su - grid
Password:
Oracle Corporation      SunOS 5.11      11.3    September 2015
grid@uatserver:~$ asmcmd
ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576   6289446  1205146                0         1205146              0             N  DATA/
MOUNTED  EXTERN  N         512   4096  1048576    511591   184953                0          184953              0             Y  FRA/
ASMCMD>

And Give permission to the backup folder which contains the backup:

login as: sol
Using keyboard-interactive authentication.
Password:
Last login: Wed Dec  7 14:44:17 2022 from 10.195.45.17
Oracle Corporation      SunOS 5.11      11.3    September 2015
sol@uatserver:~$ su - root
Password:
Oracle Corporation      SunOS 5.11      11.3    September 2015
You have new mail.
root@uatserver:/# cd /mnt/Monday/22082022
root@uatserver:/mnt/Monday/22082022# chmod 777 *

 

Restore the controlfile

oracle@uatserver:~$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Dec 7 15:11:53 2022

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

connected to target database: UATDB (DBID=98255031)

RMAN> restore controlfile from '/mnt/Monday/22082022/22_CTLFILE';
Starting restore at 07-DEC-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 instance=primdb1 device type=DISK

channel ORA_DISK_1: copied control file copy
output file name=+DATA/UATDB/CONTROLFILE/current.256.1108026843
Finished restore at 07-DEC-12

Then open the pfile and edit the line of the control file with the current one you copied and save it.

*.control_files='+DATA/UATDB/CONTROLFILE/current.256.1108026843’

And then run the following commands sequentially:

RMAN> alter database mount; 
RMAN> catalog start with '/mnt/Monday/22082022';
RMAN> crosscheck backup;
RMAN>delete expired backup; 
RMAN>crosscheck archivelog all;
RMAN> delete expired archivelog all;  	
RMAN>list backup summary;

 

Restore the database

We can restore the database either using the ‘restore database’ command or using the restore shell script:

RMAN> restore database; 

OR use restore shell script(restore.sh) and the restore.sh file contains the following lines of code:

  export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1/
  export ORACLE_SID=UATDB
  /u01/app/oracle/product/12.1.0/dbhome_1/bin/rman@'/export/home/oracle/restore.cmd;’

And the restore.cmd contains the following lines of code:

connect target /
       run
          {
          restore database;
         }

And finally we will run restore.sh script command:

[oracle@UATserver~]  nohup ./restore.sh &

 

Recover the database

RMAN> recover database;

Starting recover at 05-DEC-22
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6
using channel ORA_DISK_7
using channel ORA_DISK_8

starting media recovery

archived log for thread 1 with sequence 4531 is already on disk as file +FRA/WFCPROD/ARCHIVELOG/2022_12_05/thread_1_seq_4531.540.1122626343
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=4530
channel ORA_DISK_1: reading from backup piece /mnt/Monday/22082022/22_FULL_BACKUP_pe1dr1r4_1_1_112181437_22082022
channel ORA_DISK_1: piece handle=/mnt/Monday/22082022/22_FULL_BACKUP_pe1dr1r4_1_1_1121814372_22082022 tag=TAG20221126T230246
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:11:55
archived log file name=+FRA/UATDB/ARCHIVELOG/2022_12_05/thread_1_seq_4530.408.1122626555 thread=1 sequence=4530
channel default: deleting archived log(s)
archived log file name=+FRA/UATDB/ARCHIVELOG/2022_12_07/thread_1_seq_4530.408.1122626555 RECID=127915 STAMP=1122627260
archived log file name=+FRA/UATDB/ARCHIVELOG/2022_12_07/thread_1_seq_4531.540.1122626343 thread=1 sequence=4531
unable to find archived log
archived log thread=1 sequence=4532
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/07/2022 08:55:19
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 4532 and starting SCN of 135221823820

RMAN> alter database open resetlogs;

Statement processed

RMAN> select status from v$instance;

STATUS
------------
OPEN

RMAN>

If the listener is started and instance is not ready (unknown) then 

         SQL> alter system register 

And then Edit the pfile and uncomment the previously commented lines and also set the value of ‘cluster_database ‘ parameter to True.

*.cluster_database_instances=2
*.cluster_database=true
  UATDB2.undo_tablespace='UNDOTBS2'
  UATDB2.thread=2
  UATDB2.instance_number=2

Create spfile from pfile

oracle@UATserver:~$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Dec 7 16:19:20 2022

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

SQL> Create spfile from pfile=’/export/home/oracle/pfile.ora’;

created.

Shutdown and startup the database

             SQL>shut immediate;

Start both instances of the database:

[oracle@uatserver~]  srvctl start database –d UATDB

Stop both instances of the database to check if cluster is working;

         [oracle@uatserver~]  srvctl stop database –d UATDB

Check if both database instances are down:

oracle@uatserver:~$ srvctl status database -d UATDB
Instance UATDB1 is not  running on node uatserver1
Instance UATDB2 is not running on node uatserver2).

Start both instances of the database:

  [oracle@uatserver~]  srvctl start database –d UATDB

And finally check the status the database:

oracle@uatserver:~$ srvctl status database -d UATDB
Instance UATDB1 is running on node uatserver1
Instance UATDB2 is running on node uatserver2).
Available for Amazon Prime