Thursday, 26 February 2015

Backup and restore spfile using RMAN

Today we are gonna discuss how to take a backup of your spfile using RMAN and restore the same using RMAN.

Now before we start, I assume you have already configured your RMAN parameters.

Here we will be backing up and restoring the spfile of the target database using catalog database.

I assume your catalog database is up and running as well the listener corresponding to that too.

And in case of the target database, I assume the tns has been configured according to that particular catalog.

Now we are gonna take the backup of the spfile, while the target database is up and running or we can say online. So startup your target database, if it hasn't been.

Now open RMAN on the target environment.

Now follow these steps one after another. Keep that in mind, whatever I am using here are just as examples. rman/rman and catdb, BASE may be different in case of yours. You just have to put you ones. The target database is BASE here. I have mentioned the example names in bold. These bold ones can be different from yours.

RMAN> connect catalog rman/rman@catdb

connected to recovery catalog database

RMAN> connect target/

connected to target database: BASE (DBID=1899780213)

RMAN> backup spfile;

Wait until you see Finished backup.

Then exit from the RMAN prompt.

Now you can check the backup location that you have set up for RMAN. You will find the backup which has just been performed, but of course not in the form of a typical spfile.

Now go to ORACLE_HOME/dbs and delete the spfile corresponding to this target database.

Now shutdown the target database.

And then write startup on the sql prompt and see what happens.

SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initbase.ora'

Now time to recover the spfile

Open RMAN prompt. And perform these steps

RMAN> connect catalog rman/rman@catdb

connected to recovery catalog database

RMAN> connect target/

connected to target database (not started)

RMAN> startup force nomount

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initbase.ora'

starting Oracle instance without parameter file for retrival of spfile
Oracle instance started

Total System Global Area     159383552 bytes

Fixed Size                     2019256 bytes
Variable Size                 67108936 bytes
Database Buffers              88080384 bytes
Redo Buffers                   2174976 bytes

RMAN> restore spfile;

And the spfile is finally restored. Visit ORACLE_HOME/dbs and check, you will find the restored spfile there. 

Now  exit from the RMAN prompt.

Then on sql prompt write

SQL> shut abort
ORACLE instance shut down.

Then again startup the database and see that the database gets opened without any error.

That's all for now. Do not hesitate to correct or include any points or information that I have mentioned wrongly or missed completely. Your feedback is highly appreciated.

Thanks
Subhajit

No comments:

Post a Comment