Just a sample case about rebuilding standby database using dd command

本文介绍使用dd命令在Oracle Data Guard环境中重建备用数据库的过程。包括复制密码文件、创建和恢复控制文件、建立日志文件组、复制数据文件及临时文件,并最终恢复管理型备用数据库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值