[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;
alter database datafile 6 offline
*
ERROR at line 1:
ORA-01668: standby database requires DROP option for offline of data file
SYS@bookdg> alter database datafile 6 offline drop ;
Database altered.
--//噩梦开始.....
SYS@bookdg> alter database datafile 6 online ;
alter database datafile 6 online
*
ERROR at line 1:
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';
Database altered.
$ scp /tmp/aa.ctl4 oracle@192.168.100.40:/mnt/ramdisk/book/control01.ctl
$ scp /tmp/aa.ctl4 oracle@192.168.100.40:/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 ;
Database altered.
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.