[20180202]備庫資料檔案offline.txt
--//今天測試,不小心導緻日志無法應用.我想把主庫檔案拷貝過去,做了備庫資料檔案offline.
--//恢複遇到問題,做一個記錄.
1.環境:
SYS@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
2.測試:
--//備庫:
SYS@bookdg> alter database datafile 6 offline;
alter database datafile 6 offline
*
ERROR at line 1:
ORA-01156: recovery or flashback in progress may need access to files
---//日志應用時無法offline.
SYS@bookdg> alter database recover managed standby database cancel ;
Database altered.
SYS@bookdg> alter database datafile 6 offline;
ORA-01668: standby database requires DROP option for offline of data file
SYS@bookdg> alter database datafile 6 offline drop ;
--//噩夢開始.....
SYS@bookdg> alter database datafile 6 online ;
alter database datafile 6 online
ORA-01113: file 6 needs media recovery
ORA-01110: data file 6: '/mnt/ramdisk/book/tea01.dbf'
SYS@bookdg> recover automatic standby datafile 6;
ORA-19966: ALTER DATABASE RECOVER STANDBY DATAFILE has been deprecated
--//指令已經廢除..
--//啟動到mount狀态.
RMAN> recover datafile 4 ;
Starting recover at 2018-02-02 11:07:03
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/02/2018 11:07:03
RMAN-06067: RECOVER DATABASE required with a backup or created control file
SYS@bookdg> recover databfile 4 using backup controlfile until cancel;
ORA-00905: missing keyword
SYS@bookdg> recover database using backup controlfile until cancel;
ORA-00283: recovery session canceled due to errors
ORA-01666: control file is for a standby database
--//不行..
3.必須建立新的standby控制檔案:
SYS@book> alter database create standby controlfile as '/tmp/aa.ctl4';
$ scp /tmp/aa.ctl4 [email protected]:/mnt/ramdisk/book/control01.ctl
$ scp /tmp/aa.ctl4 [email protected]:/mnt/ramdisk/book/control02.ctl
SYS@bookdg> startup
ORACLE instance started.
Total System Global Area 634732544 bytes
Fixed Size 2255792 bytes
Variable Size 197133392 bytes
Database Buffers 427819008 bytes
Redo Buffers 7524352 bytes
Database mounted.
Database opened.
SYS@bookdg> alter database recover managed standby database using current logfile disconnect ;
SYS@bookdg> @ &r/dg/dg
PROCESS PID STATUS CLIENT_P GROUP# THREAD# SEQUENCE# BLOCK# BLOCKS DELAY_MINS
--------- ------- ------------ -------- ------ ------- ---------- ---------- ---------- ----------
ARCH 15430 CONNECTED ARCH N/A 0 0 0 0 0
ARCH 15432 CONNECTED ARCH N/A 0 0 0 0 0
ARCH 15434 CONNECTED ARCH N/A 0 0 0 0 0
RFS 15443 IDLE ARCH N/A 0 0 0 0 0
RFS 15447 IDLE UNKNOWN N/A 0 0 0 0 0
RFS 15445 IDLE UNKNOWN N/A 0 0 0 0 0
RFS 15449 IDLE LGWR 2 1 903 19 1 0
ARCH 15436 CLOSING ARCH 6 1 902 1 393 0
MRP0 15453 APPLYING_LOG N/A N/A 1 903 19 102400 0
9 rows selected.
--//實際上操作前看看出錯提示就知道了:
$ oerr ora 01668
01668, 00000, "standby database requires DROP option for offline of data file"
// *Cause: Attempting to take a datafile offline in a standby database without
// specifying the DROP option. Files that are offline in a standby
// database are not recovered, and are likely to be unusable if
// the standby is activated. Note that specifying DROP does not
// prevent bringing the file online later.
// *Action: Specify the DROP option or leave the file online.