select * from INFO_FEEDBACK_ORCLE as of timestamp to_timestamp('2016-12-06 12:00:30','YYYY-MM-DD HH24:MI:SS') --提示閃回時間已好久
如今時間是2016年12月8號10點,我立刻用閃回查詢到能查到的最先時間12月6號12:00,發現那時的數據就已經清空了,因此閃回找不到了,放棄。sql
run { allocate channel d1 type disk; backup as COMPRESSED BACKUPSET database format='/backup/oracle/b2bdb/full_%d_%T_%s_%p.bak'; sql 'alter system archive log current'; backup as COMPRESSED BACKUPSET archivelog all format '/backup/oracle/b2bdb/arch_log_%d_%T_%s_%p.bak' delete all input; backup current controlfile format='/backup/oracle/b2bdb/controlfile_%d_%T_%s_%p.bak' spfile format='/backup/oracle/b2bdb/spfile_%d_%T_%s_%p.bak'; release channel d1; } crosscheck backup; delete noprompt expired backup; delete noprompt obsolete;
orapwd file=?/dbs/orapwb2bdb password=oracle
--指定SID export ORACLE_SID=b2bdb --鏈接RMAN測試庫 rman target / --啓動到nomount狀態 startup nomount --restire spfile RMAN> restore spfile to pfile'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initb2bdb.ora' from '/u01/bak/spfile_B2BDB_20161201_959_1.bak';
sqlplus / as sysdba --因爲剛開始啓動過,因此先關閉一下 shutdown immediate --指定咱們恢復的參數文件啓動 startup nomount pfile=?/dbs/initb2bdb.ora
--指定SID [oracle@oratest bak]$ export ORACLE_SID=b2bdb --鏈接RMAN [oracle@oratest bak]$ rman target / Recovery Manager: Release 11.2.0.4.0 - Production on Thu Dec 1 01:42:42 2016 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: B2BDB (not mounted) --恢復控制文件,from指向咱們剛纔拷貝過來的備份文件 RMAN> restore controlfile from '/u01/bak/controlfile_B2BDB_20161201_958_1.bak'; Starting restore at 01-DEC-16 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=19 device type=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 output file name=/u01/app/oracle/oradata/b2bdb/control01.ctl output file name=/u01/app/oracle/oradata/b2bdb/control02.ctl Finished restore at 01-DEC-16
RMAN> alter database mount; database mounted released channel: ORA_DISK_1
restore database;
select file_id,file_name from dba_data_files; 1 /oradata/b2bdb/system01.dbf 2 /oradata/b2bdb/sysaux01.dbf 3 /oradata/b2bdb/undotbs01.dbf 4 /oradata/b2bdb/users01.dbf 5 /oradata/b2bdb/tbs_sso_001.dbf 6 /oradata/b2bdb/tbs_cableex_001.dbf 7 /oradata/b2bdb/tbs_b2b_001.dbf 8 /oradata/b2bdb/tbs_kh_test_001.dbf 9 /oradata/b2bdb/tbs_mmbao2_001.dbf select file_id,file_name from dba_temp_files; 1 /oradata/b2bdb/temp01.dbf
注意,restore 的時候不會對temp 表空間進行restore。因此等restore 以後,咱們須要手工建立temp表空間。數據庫
RMAN> run { set newname for datafile 1 to "/u01/app/oracle/oradata/system01.dbf"; set newname for datafile 2 to "/u01/app/oracle/oradata/sysaux01.dbf"; set newname for datafile 3 to "/u01/app/oracle/oradata/undotbs01.dbf"; set newname for datafile 4 to "/u01/app/oracle/oradata/users01.dbf"; set newname for datafile 5 to "/u01/app/oracle/oradata/tbs_sso_001.dbf"; set newname for datafile 6 to "/u01/app/oracle/oradata/tbs_cableex_001.dbf"; set newname for datafile 7 to "/u01/app/oracle/oradata/tbs_b2b_001.dbf"; set newname for datafile 8 to "/u01/app/oracle/oradata/tbs_kh_test_001.dbf"; set newname for datafile 9 to "/u01/app/oracle/oradata/tbs_mmbao2_001.dbf"; restore database; switch datafile all; }
RMAN> recover database; Starting recover at 01-DEC-16 using channel ORA_DISK_1 starting media recovery channel ORA_DISK_1: starting archived log restore to default destination channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=1814 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=1815 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=1816 channel ORA_DISK_1: reading from backup piece /backup/oracle/b2bdb/arch_log_B2BDB_20161201_957_1.bak channel ORA_DISK_1: errors found reading piece handle=/backup/oracle/b2bdb/arch_log_B2BDB_20161201_957_1.bak channel ORA_DISK_1: failover to piece handle=/u01/bak/arch_log_B2BDB_20161201_957_1.bak tag=TAG20161201T050152 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:25 archived log file name=/u01/app/oracle/oradata/b2bdb_archivelog/archivelog/1_1814_915284737.arch thread=1 sequence=1814 archived log file name=/u01/app/oracle/oradata/b2bdb_archivelog/archivelog/1_1815_915284737.arch thread=1 sequence=1815 archived log file name=/u01/app/oracle/oradata/b2bdb_archivelog/archivelog/1_1816_915284737.arch thread=1 sequence=1816 unable to find archived log archived log thread=1 sequence=1817 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 12/01/2016 02:20:41 RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 1817 and starting SCN of 180140127
若後面報這個錯RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 1817 and starting SCN of 180140127服務器
RMAN> recover database until scn 180140127; Starting recover at 01-DEC-16 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:00 Finished recover at 01-DEC-16
SQL> alter database open resetlogs; Database altered.
到此就夠用了,至於後續一些小問題,如臨時空間,日誌路徑問題等看着錯誤去處理。oracle
exp xxx/xxx file=xxx tables=xx
create table xx_bak as select * from xx; drop table xx;
imp xxx/xxx file=xx fromuser=xxx touser=xxx
insert into xx select * from xx_bak;