Oracle Technology Blog

OraTech Blog provides tips,tricks,scripts and how-to type answers for Oracle related technologies. I use these commands very often, so I thought it would be useful to share with everybody. Please feel free to include your comments/corrections/questions.

Tuesday, January 23, 2007

Rebuild Standby Database

How to rebuild standby database from Primary?

Rebuild or Recover Standby Database

Backup Primary DB using RMAN or use the existing RMAN backup if the backup copy is relatively new.

Copy RMAN backup pieces to Standby DB host. Make sure directory structure is same as Primary DB host.


Shutdown standby database;

Create backup controlfile and standby control from primary.

ALTER DATABASE BACKUP CONTROLFILE TO '/tmp/dbname.ctl’;

ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/tmp/s_dbname.ctl';


Copy both control file to Standby DB server.

Replace the existing control file on Standby DB with Primary DB control file that we copied(dbname.ctl, not s_dbname.ctl)

On Standby DB side

$ rman

Recovery Manager: Release 9.2.0.6.0 - 64bit Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

RMAN> connect target

connected to target database (not started)

RMAN>startup mount;

In Standby host, run the following RMAN command.
RMAN>run {
allocate channel c1 type disk;
allocate channel c2 type disk;
restore database;
}

SQL>shutdown immediate;

Copy archive logs that are generated after RMAN backup from Primary to standby DB server.

scp oracle@primat_machine:/u05/archive/DBNAME/0002S000000079*.ARC oracle@standby_machine:/u05/archive/DBNAME/

Replace the existing controlfile with STANDBY controlfile (s_dbname.ctl);


SQL> STARTUP NOMOUNT;
SQL> ALTER DATABASE MOUNT STANDBY DATABASE;


SQL> recover automatic standby database;

check the alert log while the above command is running

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;




standby_machine oracle DBNAME /opt/oracle/admin/DBNAME/bdump
$ sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.6.0 - Production on Tue Jan 23 15:48:43 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 252709304 bytes
Fixed Size 731576 bytes
Variable Size 218103808 bytes
Database Buffers 33554432 bytes
Redo Buffers 319488 bytes
SQL> alter database mount standby database;

Database altered.

SQL> recover automatic standby database;
ORA-00279: change 105230635 generated at 01/23/2007 12:28:59 needed for thread
1
ORA-00289: suggestion : /u05/archive/DBNAME/0001S0000001248.ARC
ORA-00280: change 105230635 for thread 1 is in sequence #1248
ORA-00278: log file '/u05/archive/DBNAME/0001S0000001248.ARC' no longer needed
for this recovery
ORA-16145: archival for thread# 1 sequence# 1248 in progress


Specify log: {=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00279: change 105270320 generated at 01/23/2007 12:57:47 needed for thread
1
ORA-00289: suggestion : /u05/archive/DBNAME/0001S0000001249.ARC
ORA-00280: change 105270320 for thread 1 is in sequence #1249
ORA-00278: log file '/u05/archive/DBNAME/0001S0000001248.ARC' no longer needed
for this recovery


ORA-00279: change 105270379 generated at 01/23/2007 12:57:50 needed for thread
2
ORA-00289: suggestion : /u05/archive/DBNAME/0002S0000000799.ARC
ORA-00280: change 105270379 for thread 2 is in sequence #799
ORA-00278: log file '/u05/archive/DBNAME/0002S0000000798.ARC' no longer needed
for this recovery


ORA-00279: change 105344106 generated at 01/23/2007 13:26:49 needed for thread
1
ORA-00289: suggestion : /u05/archive/DBNAME/0001S0000001250.ARC
ORA-00280: change 105344106 for thread 1 is in sequence #1250
ORA-00278: log file '/u05/archive/DBNAME/0001S0000001249.ARC' no longer needed
for this recovery


ORA-00279: change 105395671 generated at 01/23/2007 13:49:06 needed for thread
1
ORA-00289: suggestion : /u05/archive/DBNAME/0001S0000001251.ARC
ORA-00280: change 105395671 for thread 1 is in sequence #1251
ORA-00278: log file '/u05/archive/DBNAME/0001S0000001250.ARC' no longer needed
for this recovery


ORA-00332: archived log is too small - may be incompletely archived
ORA-00334: archived log: '/u05/archive/DBNAME/0001S0000001251.ARC'


SQL> alter database recover managed standby database disconnect from session;

Database altered.

SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production

standby_machine oracle DBNAME /opt/oracle/admin/DBNAME/bdump
$ ps -ef|grep -i mrp
oracle 6350 1 1 16:26:59 ? 0:11 ora_mrp0_DBNAME1
oracle 7092 22916 0 16:28:35 pts/3 0:00 grep -i mrp

1 Comments:

Anonymous Anonymous said...

Good for people to know.

9:01 AM  

Post a Comment

<< Home