ORACLE_DATAGUARD_Rebuild standby database using dd command
Rebuildstandby database using ddcommand:
-- Create the standby database: -- 1. rcp the orapw<ORACLE_SID> to the standby $ rcp $ORACLE_HOME/dbs/orapworahw sun880-2:$ORACLE_HOME/dbs/orapworahw
-- 2. On the primary, create standby controlfile and rcp to the standby rman nocatalog target / RMAN>backupcurrentcontrolfileforstandby format '/opt/oracle/test/controlforstandby.bak'; $ rcp /opt/oracle/test/controlforstandby.bak sun880-2:/opt/oracle/test/controlforstandby.bak
-- 3. On the standby, create standby controlfile rman nocatalog target / RMAN>restorestandbycontrolfilefrom'/opt/oracle/test/controlforstandby.bak';
-- 4. On the standby, Create standby logfile group SQL> ALTERDATABASEMOUNTSTANDBYDATABASE; SQL> select * from v$log; SQL> select * from v$logfile; SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 ('/opt/oracle/db/oradata/orahw/srl01.log') SIZE 50M; SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/opt/oracle/db/oradata/orahw/srl02.log') SIZE 50M; SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/opt/oracle/db/oradata/orahw/srl03.log') SIZE 50M;
-- 5. On the primary database, copy the datafile to the standby using “dd” SQL> select 'alter tablespace '||name||' begin backup;'from v$tablespace where name!='TEMP'; SQL> select '!dd if='||name||' ibs=4194304 | rsh sun880-2 dd of='||name||' obs=4194304' from v$datafile; SQL> select 'alter tablespace '||name||' end backup;'from v$tablespace where name!='TEMP'; Like this: $ touch OnlineCopyDatafile.sh $ chmod 775 OnlineCopyDatafile.sh $ vi OnlineCopyDatafile.sh <======= The content come from the SQL results. alter tablespace SYSTEM begin backup; alter tablespace SYSAUX begin backup; alter tablespace UNDOTBS1 begin backup; alter tablespace USERS begin backup; alter tablespace TEST begin backup; alter tablespace UNDO_SMALL begin backup; !dd if=/opt/oracle/db/oradata/orahw/system01.dbf ibs=4194304 | rsh sun880-2 dd of=/opt/oracle/db/oradata/orahw/system01.dbf obs=4194304 !dd if=/opt/oracle/db/oradata/orahw/sysaux01.dbf ibs=4194304 | rsh sun880-2 dd of=/opt/oracle/db/oradata/orahw/sysaux01.dbf obs=4194304 !dd if=/opt/oracle/db/oradata/orahw/undotbs01.dbf ibs=4194304 | rsh sun880-2 dd of=/opt/oracle/db/oradata/orahw/undotbs01.dbf obs=4194304 !dd if=/opt/oracle/db/oradata/orahw/users01.dbf ibs=4194304 | rsh sun880-2 dd of=/opt/oracle/db/oradata/orahw/users01.dbf obs=4194304 !dd if=/opt/oracle/db/oradata/orahw/test01.dbf ibs=4194304 | rsh sun880-2 dd of=/opt/oracle/db/oradata/orahw/test01.dbf obs=4194304 !dd if=/opt/oracle/db/oradata/orahw/users2.dbf ibs=4194304 | rsh sun880-2 dd of=/opt/oracle/db/oradata/orahw/users2.dbf obs=4194304 !dd if=/opt/oracle/db/oradata/orahw/users3.dbf ibs=4194304 | rsh sun880-2 dd of=/opt/oracle/db/oradata/orahw/users3.dbf obs=4194304 !dd if=/opt/oracle/db/oradata/orahw/undo_small.dbf ibs=4194304 | rsh sun880-2 dd of=/opt/oracle/db/oradata/orahw/undo_small.dbf obs=4194304 alter tablespace SYSTEM end backup; alter tablespace SYSAUX end backup; alter tablespace UNDOTBS1 end backup; alter tablespace USERS end backup; alter tablespace TEST end backup; alter tablespace UNDO_SMALL end backup;
$ sqlplus / as sysdba SQL> @ OnlineCopyDatafile.sh
-- 6. On the standby, add tempfile, and recover managed standby database $sqlplus / as sysdba SQL> alter database open read only; SQL> alter database tempfile '/opt/oracle/db/oradata/orahw/temp01.dbf' drop; SQL> alter tablespace temp add tempfile '/opt/oracle/db/oradata/orahw/temp01.dbf' size 2000M REUSE; SQL> alter database recover managed standby database disconnect; SQL> select process,status,thread#,sequence#,block#,blocks from v$managed_standby; |