程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> Oracle 數據庫異機恢復(歸檔模式),oracle歸檔

Oracle 數據庫異機恢復(歸檔模式),oracle歸檔

編輯:Oracle教程

Oracle 數據庫異機恢復(歸檔模式),oracle歸檔


操作必須在服務器上進行(在192.168.12.71上執行)

0、按需要恢復的日期,把距恢復日期最近的全部備份和全部備份日期後的日志備份一同拷貝到需要恢復的機器上;

1、用RMAN登陸

C:\Users\Administrator>rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Sep 23 20:48:42 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1252729974)

2、關閉以前的數據庫

RMAN> shutdown immediate;

using target database control file instead of recovery catalog database closed database dismounted Oracle instance shut down

3、啟動數據庫到非安裝狀態

RMAN> startup nomount;

connected to target database (not started) Oracle instance started

Total System Global Area   16535285760 bytes

Fixed Size                     2192176 bytes Variable Size               7113542864 bytes Database Buffers            9395240960 bytes Redo Buffers                  24309760 bytes

4、用最新的controlfile備份文件恢復(注意日期)

RMAN> restore controlfile  from  'f:\C-1252729974-20140923-00';

Starting restore at 23-SEP-14 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=958 device type=DISK

channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 output file name=D:\APP\ORADATA\ORCL\CONTROL01.CTL output file name=D:\APP\FLASH_RECOVERY_AREA\ORCL\CONTROL02.CTL Finished restore at 23-SEP-14

5、安裝數據庫 RMAN>

alter database mount;

database mounted released channel: ORA_DISK_1

6、刪除以前的備份集

RMAN> delete backup;

Starting implicit crosscheck backup at 23-SEP-14 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=958 device type=DISK Crosschecked 101 objects Finished implicit crosscheck backup at 23-SEP-14

Starting implicit crosscheck copy at 23-SEP-14 using channel ORA_DISK_1 Finished implicit crosscheck copy at 23-SEP-14

searching for all files in the recovery area cataloging files... no files cataloged

using channel ORA_DISK_1

List of Backup Pieces BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name ------- ------- --- --- ----------- ----------- ---------- 2       2       1   1   EXPIRED     DISK        E:\ORG_FULLBACK\03PFIO5N_1_1.BAK

.......................................

Do you really want to delete the above objects (enter YES or NO)? YES

deleted backup piece backup piece handle=E:\ORG_FULLBACK\03PFIO5N_1_1.BAK RECID=2 STAMP=855204024 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140810-00 RECID=4 STAMP=855 219576 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140810-01 RECID=5 STAMP=855 239758 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140810-02 RECID=6 STAMP=855 243672 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140811-00 RECID=9 STAMP=855 295326 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140812-00 RECID=12 STAMP=85 5381808 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140813-00 RECID=15 STAMP=85 5468188 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140814-00 RECID=18 STAMP=85 5554586 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140815-00 RECID=21 STAMP=85 5640982 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140816-00 RECID=24 STAMP=85 5727449 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140817-00 RECID=27 STAMP=85 5814046 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140817-01 RECID=30 STAMP=85 5816707 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140818-00 RECID=33 STAMP=85 5900156 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140819-00 RECID=36 STAMP=85 5986586 deleted backup piece backup piece handle=E:\ORACLE_FULL_BK\3VPI5N6S_1_1 RECID=123 STAMP=857922794 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\48PICHU2_1_1 RECID=132 STAMP=858146759 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\4BPIF601_1_1 RECID=134 STAMP=858232880 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\4CPIF67P_1_1 RECID=135 STAMP=858233122 deleted backup piece backup piece handle=E:\ORACLE_FULL_BK\4APIF2EP_1_1 RECID=137 STAMP=858229223 deleted backup piece backup piece handle=E:\ORACLE_FULL_BK\4EPIF91H_1_1 RECID=138 STAMP=858235955 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140914-01 RECID=139 STAMP=8 58235963 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\4GPIHQBF_1_1 RECID=140 STAMP=858319218 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\4HPIHQDV_1_1 RECID=141 STAMP=858319299 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140915-00 RECID=142 STAMP=8 58319370 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\4JPIKEND_1_1 RECID=143 STAMP=858405617 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\4KPIKEPU_1_1 RECID=144 STAMP=858405709 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140916-00 RECID=145 STAMP=8 58405789 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\4MPIN33K_1_1 RECID=146 STAMP=858492043 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\4NPIN36P_1_1 RECID=147 STAMP=858492132 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140917-00 RECID=148 STAMP=8 58492218 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\4PPIPNFC_1_1 RECID=149 STAMP=858578417 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\4QPIPNIB_1_1 RECID=150 STAMP=858578511 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140918-00 RECID=151 STAMP=8 58578581 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140918-01 RECID=153 STAMP=8 58586351 deleted backup piece backup piece handle=E:\0918\4UPIPVCT_1_1 RECID=154 STAMP=858586535 deleted backup piece backup piece handle=E:\0918\4VPIQ83P_1_1 RECID=155 STAMP=858595450 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140918-02 RECID=156 STAMP=8 58595469 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\51PISBSN_1_1 RECID=157 STAMP=858664861 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\52PISBVS_1_1 RECID=158 STAMP=858664970 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140919-00 RECID=159 STAMP=8 58665048 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\54PIV07G_1_1 RECID=160 STAMP=858751260 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\55PIV0D2_1_1 RECID=161 STAMP=858751400 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140920-00 RECID=162 STAMP=8 58751478 deleted backup piece backup piece handle=E:\ORACLE_FULL_BK\57PJ1H2R_1_1 RECID=163 STAMP=858834025 deleted backup piece backup piece handle=E:\ORACLE_FULL_BK\58PJ1NLQ_1_1 RECID=164 STAMP=858840791 deleted backup piece backup piece handle=E:\ORACLE_FULL_BK\59PJ1NP9_1_1 RECID=165 STAMP=858840878 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140921-00 RECID=166 STAMP=8 58840961 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\5BPJ48VA_1_1 RECID=167 STAMP=858924013 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\5CPJ491U_1_1 RECID=168 STAMP=858924098 deleted backup piece backup piece handle=E:\CONTRL_FILE_BK\C-1252729974-20140922-00 RECID=169 STAMP=8 58924163 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\5EPJ6TBC_1_1 RECID=170 STAMP=859010427 deleted backup piece backup piece handle=E:\ORACLE_INC_BK\5FPJ6TES_1_1 RECID=171 STAMP=859010529 Deleted 52 objects

7、注冊新的備份集(按日期依次注冊,第一個是距恢復日期前的最近的一次全備份)

RMAN> catalog backuppiece 'f:\57PJ1H2R_1_1';

cataloged backup piece backup piece handle=F:\57PJ1H2R_1_1 RECID=172 STAMP=859064129

RMAN> catalog backuppiece 'f:\58PJ1NLQ_1_1';

cataloged backup piece backup piece handle=F:\58PJ1NLQ_1_1 RECID=173 STAMP=859064143

RMAN> catalog backuppiece 'f:\59PJ1NP9_1_1';

cataloged backup piece backup piece handle=F:\59PJ1NP9_1_1 RECID=174 STAMP=859064162

RMAN> catalog backuppiece 'f:\5BPJ48VA_1_1';

cataloged backup piece backup piece handle=F:\5BPJ48VA_1_1 RECID=175 STAMP=859064178

RMAN> catalog backuppiece 'f:\5CPJ491U_1_1';

cataloged backup piece backup piece handle=F:\5CPJ491U_1_1 RECID=176 STAMP=859064195

RMAN> catalog backuppiece 'f:\5EPJ6TBC_1_1';

cataloged backup piece backup piece handle=F:\5EPJ6TBC_1_1 RECID=177 STAMP=859064226

RMAN> catalog backuppiece 'f:\5FPJ6TES_1_1';

cataloged backup piece backup piece handle=F:\5FPJ6TES_1_1 RECID=178 STAMP=859064245

8、恢復數據庫(更改文件路徑)    命令發出後,是漫長的等待,大概2個小時.......

RMAN>run{    

set newname for datafile 1  to 'D:\APP\ORADATA\ORCL\SYSTEM01.DBF';     set newname for datafile 2       to 'D:\APP\ORADATA\ORCL\SYSAUX01.DBF';     set newname for datafile 3       to 'D:\APP\ORADATA\ORCL\UNDOTBS01.DBF';     set newname for datafile 4       to 'D:\APP\ORADATA\ORCL\USERS01.DBF';     set newname for datafile 5       to 'D:\JDEDWARDS\ORCL\SY900T01.DBF';     set newname for datafile 6       to 'D:\JDEDWARDS\ORCL\SY900I01.DBF';     set newname for datafile 7       to 'D:\JDEDWARDS\ORCL\SVM900T01.DBF';     set newname for datafile 8       to 'D:\JDEDWARDS\ORCL\SVM900I01.DBF';     set newname for datafile 9       to 'D:\JDEDWARDS\ORCL\OL900T01.DBF';     set newname for datafile 10      to 'D:\JDEDWARDS\ORCL\OL900I01.DBF';     set newname for datafile 11      to 'D:\JDEDWARDS\ORCL\DD900T01.DBF';     set newname for datafile 12      to 'D:\JDEDWARDS\ORCL\DD900I01.DBF';     set newname for datafile 13      to 'D:\JDEDWARDS\ORCL\PD900T01.DBF';     set newname for datafile 14      to 'D:\JDEDWARDS\ORCL\PD900T02.DBF';     set newname for datafile 15      to 'D:\JDEDWARDS\ORCL\PD900I01.DBF';     set newname for datafile 16      to 'D:\JDEDWARDS\ORCL\PRODCTLI01.DBF';     set newname for datafile 17      to 'D:\JDEDWARDS\ORCL\PRODCTLT01.DBF';     set newname for datafile 18      to 'D:\JDEDWARDS\ORCL\PRODDTAI01.DBF';     set newname for datafile 19      to 'D:\JDEDWARDS\ORCL\PRODDTAT01.DBF';     set newname for datafile 20      to 'D:\JDEDWARDS\ORCL\PY900T01.DBF';     set newname for datafile 21      to 'D:\JDEDWARDS\ORCL\PY900T02.DBF';     set newname for datafile 22      to 'D:\JDEDWARDS\ORCL\PY900I01.DBF';     set newname for datafile 23      to 'D:\JDEDWARDS\ORCL\CRPCTLI01.DBF';     set newname for datafile 24      to 'D:\JDEDWARDS\ORCL\CRPCTLT01.DBF';     set newname for datafile 25      to 'D:\JDEDWARDS\ORCL\CRPDTAI01.DBF';     set newname for datafile 26      to 'D:\JDEDWARDS\ORCL\CRPDTAT01.DBF';     set newname for datafile 27      to 'D:\JDEDWARDS\ORCL\DV900T01.DBF';     set newname for datafile 28      to 'D:\JDEDWARDS\ORCL\DV900T02.DBF';     set newname for datafile 29      to 'D:\JDEDWARDS\ORCL\DV900I01.DBF';     set newname for datafile 30      to 'D:\JDEDWARDS\ORCL\TESTCTLI01.DBF';     set newname for datafile 31      to 'D:\JDEDWARDS\ORCL\TESTCTLT01.DBF';     set newname for datafile 32      to 'D:\JDEDWARDS\ORCL\TESTDTAI01.DBF';     set newname for datafile 33      to 'D:\JDEDWARDS\ORCL\TESTDTAT01.DBF';     set newname for datafile 34      to 'D:\JDEDWARDS\ORCL\PS900T01.DBF';     set newname for datafile 35      to 'D:\JDEDWARDS\ORCL\PS900T02.DBF';     set newname for datafile 36      to 'D:\JDEDWARDS\ORCL\PS900I01.DBF';     set newname for datafile 37      to 'D:\JDEDWARDS\ORCL\PS900CTLI01.DBF';     set newname for datafile 38      to 'D:\JDEDWARDS\ORCL\PS900CTLT01.DBF';     set newname for datafile 39      to 'D:\JDEDWARDS\ORCL\PS900DTAI01.DBF';     set newname for datafile 40      to 'D:\JDEDWARDS\ORCL\PS900DTAT01.DBF';     set newname for datafile 41      to 'D:\JDEDWARDS\ORCL\SVM900BT01.DBF';     set newname for datafile 42      to 'D:\JDEDWARDS\ORCL\SVM900BI01.DBF';     set newname for datafile 43      to 'D:\JDEDWARDS\ORCL\CRPDTAT02.DBF';     set newname for datafile 44      to 'D:\JDEDWARDS\ORCL\CRPDTAT03.DBF';     set newname for datafile 45      to 'D:\JDEDWARDS\ORCL\PRODDTAT02.DBF';     set newname for datafile 46      to 'D:\JDEDWARDS\ORCL\PRODDTAT03.DBF';     set newname for datafile 47      to 'D:\APP\ORADATA\ORCL\TESTDTAT02.DBF';     set newname for datafile 48      to 'D:\JDEDWARDS\ORCL\PRODDTAT04.DBF';     set newname for datafile 49      to 'D:\JDEDWARDS\ORCL\CRPDTAT04.DBF';     set newname for datafile 50      to 'D:\JDEDWARDS\ORCL\CRPDTAT05.DBF';     set newname for datafile 51      to 'D:\JDEDWARDS\ORCL\CRPDTAI02.DBF';     set newname for datafile 52      to 'D:\JDEDWARDS\ORCL\CRPDTAT06.DBF';     set newname for datafile 53      to 'D:\JDEDWARDS\ORCL\PRODDTAT06.DBF';     set newname for datafile 54      to 'D:\JDEDWARDS\ORCL\PRODDTAT05.DBF';     set newname for datafile 55      to 'D:\JDEDWARDS\ORCL\SVM900BT02.DBF';     set newname for datafile 56      to 'D:\APP\ORADATA\ORCL\SYSTEM02.DBF';     set newname for datafile 57      to 'D:\JDEDWARDS\ORCL\PRODDTAI02.DBF';     set newname for datafile 58      to 'D:\JDEDWARDS\ORCL\PRODDTAT07.DBF';     set newname for datafile 59      to 'D:\JDEDWARDS\ORCL\PRODDTAT08.DBF';     set newname for datafile 60      to 'D:\JDEDWARDS\ORCL\PRODDTAT09.DBF';     set newname for datafile 61      to 'D:\JDEDWARDS\ORCL\PRODDTAT10.DBF';     set newname for datafile 62      to 'D:\APP\ORADATA\ORCL\SVM900T02.DBF';      restore database;  }

9、轉換文件路徑

RMAN>  run{     set newname for datafile 1  to 'D:\APP\ORADATA\ORCL\SYSTEM01.DBF';     set newname for datafile 2       to 'D:\APP\ORADATA\ORCL\SYSAUX01.DBF';     set newname for datafile 3       to 'D:\APP\ORADATA\ORCL\UNDOTBS01.DBF';     set newname for datafile 4       to 'D:\APP\ORADATA\ORCL\USERS01.DBF';     set newname for datafile 5       to 'D:\JDEDWARDS\ORCL\SY900T01.DBF';     set newname for datafile 6       to 'D:\JDEDWARDS\ORCL\SY900I01.DBF';     set newname for datafile 7       to 'D:\JDEDWARDS\ORCL\SVM900T01.DBF';     set newname for datafile 8       to 'D:\JDEDWARDS\ORCL\SVM900I01.DBF';     set newname for datafile 9       to 'D:\JDEDWARDS\ORCL\OL900T01.DBF';     set newname for datafile 10      to 'D:\JDEDWARDS\ORCL\OL900I01.DBF';     set newname for datafile 11      to 'D:\JDEDWARDS\ORCL\DD900T01.DBF';     set newname for datafile 12      to 'D:\JDEDWARDS\ORCL\DD900I01.DBF';     set newname for datafile 13      to 'D:\JDEDWARDS\ORCL\PD900T01.DBF';     set newname for datafile 14      to 'D:\JDEDWARDS\ORCL\PD900T02.DBF';     set newname for datafile 15      to 'D:\JDEDWARDS\ORCL\PD900I01.DBF';     set newname for datafile 16      to 'D:\JDEDWARDS\ORCL\PRODCTLI01.DBF';     set newname for datafile 17      to 'D:\JDEDWARDS\ORCL\PRODCTLT01.DBF';     set newname for datafile 18      to 'D:\JDEDWARDS\ORCL\PRODDTAI01.DBF';     set newname for datafile 19      to 'D:\JDEDWARDS\ORCL\PRODDTAT01.DBF';     set newname for datafile 20      to 'D:\JDEDWARDS\ORCL\PY900T01.DBF';     set newname for datafile 21      to 'D:\JDEDWARDS\ORCL\PY900T02.DBF';     set newname for datafile 22      to 'D:\JDEDWARDS\ORCL\PY900I01.DBF';     set newname for datafile 23      to 'D:\JDEDWARDS\ORCL\CRPCTLI01.DBF';     set newname for datafile 24      to 'D:\JDEDWARDS\ORCL\CRPCTLT01.DBF';     set newname for datafile 25      to 'D:\JDEDWARDS\ORCL\CRPDTAI01.DBF';     set newname for datafile 26      to 'D:\JDEDWARDS\ORCL\CRPDTAT01.DBF';     set newname for datafile 27      to 'D:\JDEDWARDS\ORCL\DV900T01.DBF';     set newname for datafile 28      to 'D:\JDEDWARDS\ORCL\DV900T02.DBF';     set newname for datafile 29      to 'D:\JDEDWARDS\ORCL\DV900I01.DBF';     set newname for datafile 30      to 'D:\JDEDWARDS\ORCL\TESTCTLI01.DBF';     set newname for datafile 31      to 'D:\JDEDWARDS\ORCL\TESTCTLT01.DBF';     set newname for datafile 32      to 'D:\JDEDWARDS\ORCL\TESTDTAI01.DBF';     set newname for datafile 33      to 'D:\JDEDWARDS\ORCL\TESTDTAT01.DBF';     set newname for datafile 34      to 'D:\JDEDWARDS\ORCL\PS900T01.DBF';     set newname for datafile 35      to 'D:\JDEDWARDS\ORCL\PS900T02.DBF';     set newname for datafile 36      to 'D:\JDEDWARDS\ORCL\PS900I01.DBF';     set newname for datafile 37      to 'D:\JDEDWARDS\ORCL\PS900CTLI01.DBF';     set newname for datafile 38      to 'D:\JDEDWARDS\ORCL\PS900CTLT01.DBF';     set newname for datafile 39      to 'D:\JDEDWARDS\ORCL\PS900DTAI01.DBF';     set newname for datafile 40      to 'D:\JDEDWARDS\ORCL\PS900DTAT01.DBF';     set newname for datafile 41      to 'D:\JDEDWARDS\ORCL\SVM900BT01.DBF';     set newname for datafile 42      to 'D:\JDEDWARDS\ORCL\SVM900BI01.DBF';     set newname for datafile 43      to 'D:\JDEDWARDS\ORCL\CRPDTAT02.DBF';     set newname for datafile 44      to 'D:\JDEDWARDS\ORCL\CRPDTAT03.DBF';     set newname for datafile 45      to 'D:\JDEDWARDS\ORCL\PRODDTAT02.DBF';     set newname for datafile 46      to 'D:\JDEDWARDS\ORCL\PRODDTAT03.DBF';     set newname for datafile 47      to 'D:\APP\ORADATA\ORCL\TESTDTAT02.DBF';     set newname for datafile 48      to 'D:\JDEDWARDS\ORCL\PRODDTAT04.DBF';     set newname for datafile 49      to 'D:\JDEDWARDS\ORCL\CRPDTAT04.DBF';     set newname for datafile 50      to 'D:\JDEDWARDS\ORCL\CRPDTAT05.DBF';     set newname for datafile 51      to 'D:\JDEDWARDS\ORCL\CRPDTAI02.DBF';     set newname for datafile 52      to 'D:\JDEDWARDS\ORCL\CRPDTAT06.DBF';     set newname for datafile 53      to 'D:\JDEDWARDS\ORCL\PRODDTAT06.DBF';     set newname for datafile 54      to 'D:\JDEDWARDS\ORCL\PRODDTAT05.DBF';     set newname for datafile 55      to 'D:\JDEDWARDS\ORCL\SVM900BT02.DBF';     set newname for datafile 56      to 'D:\APP\ORADATA\ORCL\SYSTEM02.DBF';     set newname for datafile 57      to 'D:\JDEDWARDS\ORCL\PRODDTAI02.DBF';     set newname for datafile 58      to 'D:\JDEDWARDS\ORCL\PRODDTAT07.DBF';     set newname for datafile 59      to 'D:\JDEDWARDS\ORCL\PRODDTAT08.DBF';     set newname for datafile 60      to 'D:\JDEDWARDS\ORCL\PRODDTAT09.DBF';     set newname for datafile 61      to 'D:\JDEDWARDS\ORCL\PRODDTAT10.DBF';     set newname for datafile 62      to 'D:\APP\ORADATA\ORCL\SVM900T02.DBF';      switch datafile all;  }

10、更改redo文件位置(用sqlplus,另開窗口)

C:\Users\Administrator>sqlplus sys as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 22 15:18:20 2014

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Enter password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01.LOG' to 'D:\APP\ORADATA\ORCL\REDO01.LOG'; SQL> ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO02.LOG' to 'D:\APP\ORADATA\ORCL\REDO02.LOG'; SQL> ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO03.LOG' to 'D:\APP\ORADATA\ORCL\REDO03.LOG'; SQL> ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO04.LOG' to 'D:\APP\ORADATA\ORCL\REDO04.LOG'; SQL> ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO05.LOG' to 'D:\APP\ORADATA\ORCL\REDO05.LOG'; SQL> ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01B.LOG' to 'D:\APP\ORADATA\ORCL\REDO01B.LOG'; SQL> ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO02B.LOG' to 'D:\APP\ORADATA\ORCL\REDO02B.LOG'; SQL> ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO03B.LOG' to 'D:\APP\ORADATA\ORCL\REDO03B.LOG'; SQL> ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO04B.LOG' to 'D:\APP\ORADATA\ORCL\REDO04B.LOG';

可以一同復制粘貼下邊的到Sqlplus:

 ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01.LOG' to 'D:\APP\ORADATA\ORCL\REDO01.LOG';  

ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO02.LOG' to 'D:\APP\ORADATA\ORCL\REDO02.LOG';  

ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO03.LOG' to 'D:\APP\ORADATA\ORCL\REDO03.LOG';  

ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO04.LOG' to 'D:\APP\ORADATA\ORCL\REDO04.LOG';

 ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO05.LOG' to 'D:\APP\ORADATA\ORCL\REDO05.LOG';

 ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01B.LOG' to 'D:\APP\ORADATA\ORCL\REDO01B.LOG';  

ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO02B.LOG' to 'D:\APP\ORADATA\ORCL\REDO02B.LOG';

 ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO03B.LOG' to 'D:\APP\ORADATA\ORCL\REDO03B.LOG';  

ALTER DATABASE RENAME FILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO04B.LOG' to 'D:\APP\ORADATA\ORCL\REDO04B.LOG';

 

11、recover database (注冊了幾天的日志,就恢復幾天的,時間視注冊的日志個數)

RMAN>recover database;

........(稍漫長的等待)

 

12、根據上步執行結果 執行 下句(注意Sequence的更改)

RMAN>run{  set until sequence 366246 thread 1;  recover database;  }

executing command: SET until clause

Starting recover at 24-SEP-14 using channel ORA_DISK_1

starting media recovery media recovery complete, elapsed time: 00:00:03

Finished recover at 24-SEP-14

13、重置日志,打開數據庫

RMAN> alter database open resetlogs;

database opened

14、關閉重新打開數據庫,測試

RMAN> shutdown immediate;

database closed database dismounted Oracle instance shut down

RMAN> startup

connected to target database (not started) Oracle instance started database mounted database opened

Total System Global Area   16535285760 bytes

Fixed Size                     2192176 bytes Variable Size               7113542864 bytes Database Buffers            9395240960 bytes Redo Buffers                  24309760 bytes

RMAN>

(成功恢復)


為何Oracle數據庫進行聯機備份與恢復,數據庫必須處於歸檔模式下?

在線備份,數據庫仍處於運行狀態的備份或備份可能會做DML操作和執行這些操作將被記錄到聯機日志文件,聯機日志文件,把這些操作是完整的歸檔日志,備份時,數據庫的問題,你可以使用備份文件和日志文件(歸檔日志文件和聯機日志文件)的恢復,以確保數據不會丟失。
 

oracle 將數據庫改為歸檔模式以前的非歸檔模式下的備份還有效

之前的備份沒有歸檔日志不能進行 完全恢復,修改為歸檔模式後應當對全庫進行一個完整備份!!!
 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved