Friday, November 13, 2009

Backup and Recovery (1) -- recover controlfile and spfile (pfile)

1. recover controlfile
Controlfile is vital to an Oracle database. It records structure of the database: datafile name and location, online redo log name and location, characterset, database name, rman settings, rman backup info etc.

It is recommended to have three copies of controlfile on different mounting points.

It is recommended to turn on rman controlfile autobackup.

1.1 rman approach
Rman> startup nomount;
Rman> set dbid ;
Rman> restore controlfile from autobackup;

1.2 rebuild controlfile from saved textfile
SQL> alter database backup controlfile to trace [“a new location”];
Edit the trace file and run from SQL>.

1.3 in case trace is not available and no rman backup of controlfile. Then last resort: rebuild it manually.
Need to collect datafile location and name, characterset, database name and online redolog name and location. Create a trace file from other database and build the new controlfile trace file for the missing controlfile database.

2. recover spfile
need to turn on rman controlfile autobackup.
Rman> startup force nomount; ##use dummy init.ora
Rman> set dbid <>;
Rman> restore spfile from autobackup;

3. recover pfile
3.1 restore from spfile
SQL> create pfile from spfile;

3.2 restore from rman backup of spfile
RMAN> restore spfile to pfile '/tmp/initPROD.ora' from autobackup;

3.3 above approaches failed and no textfile backup, then need to rebuild init.ora from alert.log. When database got startup, the none default settings in init.ora were got written in alert.log. So do not delete alert.log.

4. Experience

We needed to change some memory setting for our OBIEE database. The database was created with spfile and we had not turned on rman backup yet. My fellow DBA set the SGA_TARGET to a huge number. After shutdown the database, he could start it as no enough memory on the node. He got stuck. Fortunately, I had a backup on my desktop. Otherwise, we need to go through the alert.log and rebuild the init.ora.

No comments:

Post a Comment