1、登錄主庫備份控制檔到資料檔案所在的目錄。
1.1先查詢資料檔案所在的目錄:select name from v$datafile
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/ora/oracle/oradata/tsing/system01.dbf
/ora/oracle/oradata/tsing/undotbs01.dbf
/ora/oracle/oradata/tsing/sysaux01.dbf
/ora/oracle/oradata/tsing/users01.dbf
/ora/oracle/oradata/tsing/mast.dbf
/ora/oracle/oradata/tsing/mas.dbf
6 rows selected.



1.2 備份控制檔到資料檔案所在的目錄
SQL> alter database create standby controlfile as '/ora/oracle/oradata/tsing/node1.ctl';
Database altered.



2、登錄備庫刪除資料檔案
2.1關閉備庫實例
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.



2.2進入資料檔案所在的目錄,然後刪除
cd /ora/oracle/oradata/tsing/
[oracle@TAIXIN-HR1 tsing]$ ls
control01.ctl mast.dbf redo03.log stdREDO04.LOG undotbs01.dbf
control02.ctl orapwtsing stdREDO01.LOG sysaux01.dbf users01.dbf
control03.ctl redo01.log stdREDO02.LOG system01.dbf
mas.dbf redo02.log stdREDO03.LOG temp01.dbf
[oracle@TAIXIN-HR1 tsing]$ rm -f *



3、從主庫用SCP命令將資料檔案及控制檔傳到備庫
scp -r /ora/oracle/oradata/tsing/* oracle@TAIXIN-HR1:/ora/oracle/oradata/tsing/
oracle@taixin-hr1's password:
control01.ctl 100% 7088KB 6.9MB/s 00:00
control02.ctl 100% 7088KB 6.9MB/s 00:00
control03.ctl 100% 7088KB 6.9MB/s 00:01
inittsing.ora 100% 1407 1.4KB/s 00:00
mas.dbf 100% 16GB 25.5MB/s 10:30
mast.dbf 100% 136MB 22.7MB/s 00:06
node1.ctl 100% 7088KB 6.9MB/s 00:00
orapwtsing 100% 1536 1.5KB/s 00:00
redo01.log 100% 50MB 25.0MB/s 00:02
redo02.log 100% 50MB 25.0MB/s 00:02
redo03.log 100% 50MB 25.0MB/s 00:02
sqlnet.log 100% 668 0.7KB/s 00:00
stdREDO01.LOG 100% 50MB 16.7MB/s 00:03
stdREDO02.LOG 100% 50MB 50.0MB/s 00:01
stdREDO03.LOG 100% 50MB 50.0MB/s 00:01
stdREDO04.LOG 100% 50MB 25.0MB/s 00:02
sysaux01.dbf 100% 490MB 18.9MB/s 00:26
system01.dbf 100% 520MB 21.7MB/s 00:24
temp01.dbf 100% 20MB 20.0MB/s 00:01
tsing1.ctl 100% 6928KB 6.8MB/s 00:01
undotbs01.dbf 100% 115MB 23.0MB/s 00:05
users01.dbf 100% 5128KB 5.0MB/s 00:00
[oracle@TAIXIN-HR tsing]$



4、重命名剛傳到備庫的控制檔
4.1先刪除目錄下原有的三個控制檔
[oracle@TAIXIN-HR1 tsing]$ ls
control01.ctl mast.dbf redo03.log stdREDO04.LOG undotbs01.dbf
control02.ctl node1.ctl sqlnet.log sysaux01.dbf users01.dbf
control03.ctl orapwtsing stdREDO01.LOG system01.dbf
inittsing.ora redo01.log stdREDO02.LOG temp01.dbf
mas.dbf redo02.log stdREDO03.LOG tsing1.ctl
[oracle@TAIXIN-HR1 tsing]$ rm contro*
[oracle@TAIXIN-HR1 tsing]$ ls
inittsing.ora orapwtsing sqlnet.log stdREDO04.LOG tsing1.ctl
mas.dbf redo01.log stdREDO01.LOG sysaux01.dbf undotbs01.dbf
mast.dbf redo02.log stdREDO02.LOG system01.dbf users01.dbf
node1.ctl redo03.log stdREDO03.LOG temp01.dbf



4.2 將node1.ctl的控制檔重命名成三個控制檔
[oracle@TAIXIN-HR1 tsing]$ mv node1.ctl control01.ctl
[oracle@TAIXIN-HR1 tsing]$ cp control01.ctl control02.ctl
[oracle@TAIXIN-HR1 tsing]$ cp control02.ctl control03.ctl
[oracle@TAIXIN-HR1 tsing]$ ls
control01.ctl mast.dbf sqlnet.log sysaux01.dbf users01.dbf
control02.ctl orapwtsing stdREDO01.LOG system01.dbf
control03.ctl redo01.log stdREDO02.LOG temp01.dbf
inittsing.ora redo02.log stdREDO03.LOG tsing1.ctl
mas.dbf redo03.log stdREDO04.LOG undotbs01.dbf





5、連接備庫,並按如下操作
sqlplus / as sysdba
SQL>startup nomount
SQL>alter database mount standby database;
SQL>alter database recover managed standby database disconnect from session;



6、測試重建是否成功(主庫切換日誌後查看備庫是否應用日誌)
在主庫上執行
SQL>alter system switch logfile;
在從庫上
SQL>select sequence#,applied from v$archived_log;
創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()