ORACLE RMAN異機異目錄恢復
1. 環境: 原機: 192.168.102.156
目標機: 192.168.102.157
2. 需求: 將原機所在的控制檔案,資料檔案, REDOLOG恢復到/home/oracle/oradata/datafile下
3. 引數檔案準備
3.1 在原庫生成PFILE檔案。
- SQL> create pfile= '/home/oracle/initgg1.ora' from spfile;
- File created.
3.2 獎引數檔案移至目標庫。
- [oracle@GOLDENGATE1 ~]$ scp initgg1.ora oracle@192.168.102.157:/home/oracle
- oracle@192.168.102.157's password :
- initgg1.ora 100% 1051 1.0KB/s 00:00
4. 將目標庫啟動至NOMOUN狀態。
4.1 修改引數檔案:
- *.control_files= '/home/oracle/oradata/datafile/control01.ctl' , '/home/oracle/oradata/datafile/control02.ctl' , '/home/oracle/oradata/datafile/control03.ctl'
- *.core_dump_dest= '/home/oracle/admin/gg1/cdump'
4.2 建立PFILE所需要的目錄。
- [oracle@GOLDENGATE2 ~]$ mkdir -p admin/gg1/adump
- [oracle@GOLDENGATE2 ~]$ mkdir -p admin/gg1/cdump
- [oracle@GOLDENGATE2 ~]$ mkdir -p admin/gg1/bdump
- [oracle@GOLDENGATE2 ~]$ mkdir -p admin/gg1/udump
- [oracle@GOLDENGATE2 ~]$ mkdir oradata/datafile
4.3 將目標庫啟動到NOMOUNT狀態。
- [oracle@GOLDENGATE2 ~]$ export ORACLE_SID=gg1
- [oracle@GOLDENGATE2 ~]$ sqlplus / as sysdba
- SQL*Plus: Release 10.2.0.1.0 - Production on Fri Sep 21 03 : 48 : 06 2012
- Copyright (c) 1982 , 2005 , Oracle. All rights reserved.
- Connected to an idle instance.
- SQL> startup nomount pfile= '/home/oracle/initgg1.ora' ;
- ORACLE instance started.
- Total System Global Area 167772160 bytes
- Fixed Size 1218292 bytes
- Variable Size 83888396 bytes
- Database Buffers 75497472 bytes
- Redo Buffers 7168000 bytes
5. 備份檔案準備。
5.1 備份原庫。
- [oracle@GOLDENGATE1 ~]$ rman target /
- Recovery Manager: Release 10.2.0.1.0 - Production on Fri Sep 21 02:08:38 2012
- Copyright (c) 1982, 2005, Oracle. All rights reserved.
- connected to target database : GG1 (DBID=1620494887)
- RMAN> backup format= '/home/oracle/rman/full_%d_%T_%s' database include current controlfile plus archivelog;
- Starting backup at 21-SEP-12
- current log archived
- using target database control file instead of recovery catalog
- allocated channel: ORA_DISK_1
- channel ORA_DISK_1: sid=141 devtype=DISK
- channel ORA_DISK_1: starting archive log backupset
- channel ORA_DISK_1: specifying archive log(s) in backup set
- input archive log thread=1 sequence =4 recid=1 stamp=794527523
- input archive log thread=1 sequence =5 recid=2 stamp=794538401
- input archive log thread=1 sequence =6 recid=3 stamp=794539337
- input archive log thread=1 sequence =7 recid=4 stamp=794539385
- input archive log thread=1 sequence =8 recid=5 stamp=794539992
- input archive log thread=1 sequence =9 recid=6 stamp=794542152
- channel ORA_DISK_1: starting piece 1 at 21-SEP-12
- channel ORA_DISK_1: finished piece 1 at 21-SEP-12
- piece handle=/home/oracle/rman/full_GG1_20120921_17 tag=TAG20120921T020913 comment=NONE
- channel ORA_DISK_1: backup set complete, elapsed time : 00:00:04
- Finished backup at 21-SEP-12
- Starting backup at 21-SEP-12
- using channel ORA_DISK_1
- channel ORA_DISK_1: starting full datafile backupset
- channel ORA_DISK_1: specifying datafile(s) in backupset
- input datafile fno=00006 name =/home/oracle/oradata/gg1/gg01.dbf
- input datafile fno=00001 name =/home/oracle/oradata/gg1/system01.dbf
- input datafile fno=00003 name =/home/oracle/oradata/gg1/sysaux01.dbf
- input datafile fno=00005 name =/home/oracle/oradata/gg1/example01.dbf
- input datafile fno=00002 name =/home/oracle/oradata/gg1/undotbs01.dbf
- input datafile fno=00004 name =/home/oracle/oradata/gg1/users01.dbf
- channel ORA_DISK_1: starting piece 1 at 21-SEP-12
- channel ORA_DISK_1: finished piece 1 at 21-SEP-12
- piece handle=/home/oracle/rman/full_GG1_20120921_18 tag=TAG20120921T020917 comment=NONE
- channel ORA_DISK_1: backup set complete, elapsed time : 00:00:56
- channel ORA_DISK_1: starting full datafile backupset
- channel ORA_DISK_1: specifying datafile(s) in backupset
- including current control file in backupset
- including current SPFILE in backupset
- channel ORA_DISK_1: starting piece 1 at 21-SEP-12
- channel ORA_DISK_1: finished piece 1 at 21-SEP-12
- piece handle=/home/oracle/rman/full_GG1_20120921_19 tag=TAG20120921T020917 comment=NONE
- channel ORA_DISK_1: backup set complete, elapsed time : 00:00:02
- Finished backup at 21-SEP-12
- Starting backup at 21-SEP-12
- current log archived
- using channel ORA_DISK_1
- channel ORA_DISK_1: starting archive log backupset
- channel ORA_DISK_1: specifying archive log(s) in backup set
- input archive log thread=1 sequence =10 recid=7 stamp=794542215
- channel ORA_DISK_1: starting piece 1 at 21-SEP-12
- channel ORA_DISK_1: finished piece 1 at 21-SEP-12
- piece handle=/home/oracle/rman/full_GG1_20120921_20 tag=TAG20120921T021016 comment=NONE
- channel ORA_DISK_1: backup set complete, elapsed time : 00:00:02
- Finished backup at 21-SEP-12
- RMAN>
5.2 將備份移至目標機:
- [oracle@GOLDENGATE1 rman]$ scp * 192.168.102.157 :/home/oracle/rman
- oracle@ 192.168.102.157 's password:
- full_GG1_20120921_17 100 % 40MB 19. 9MB/s 00 : 02
- full_GG1_20120921_18 100 % 594MB 10. 4MB/s 00 : 57
- full_GG1_20120921_19 100 % 6976KB 6. 8MB/s 00 : 01
- full_GG1_20120921_20 100 % 12KB 12. 0KB/s 00 : 00
- [oracle@GOLDENGATE1 rman]$
6. 在目標機上面恢復控制檔案, 並將資料庫啟動到MOUNT狀態。
- [oracle@GOLDENGATE2 ~]$ rman target /
- Recovery Manager: Release 10.2.0.1.0 - Production on Fri Sep 21 03 : 50 : 44 2012
- Copyright (c) 1982 , 2005 , Oracle. All rights reserved.
- connected to target database: gg1 ( not mounted)
- RMAN> restore controlfile from '/home/oracle/rman/full_GG1_20120921_19' ;
- Starting restore at 21 -SEP- 12
- using target database control file instead of recovery catalog
- allocated channel: ORA_DISK_1
- channel ORA_DISK_1: sid= 156 devtype=DISK
- channel ORA_DISK_1: restoring control file
- channel ORA_DISK_1: restore complete, elapsed time: 00 : 00 : 02
- output filename=/home/oracle/oradata/datafile/control01 . ctl
- output filename=/home/oracle/oradata/datafile/control02 . ctl
- output filename=/home/oracle/oradata/datafile/control03 . ctl
- Finished restore at 21 -SEP- 12
- RMAN> alter database mount;
- database mounted
- released channel: ORA_DISK_1
7. 恢復資料檔案。
- RMAN> run{
- set newname for datafile 1 to '/home/oracle/oradata/datafile/system01.dbf' ;
- set newname for datafile 2 to '/home/oracle/oradata/datafile/undotbs01.dbf' ;
- set newname for datafile 3 to '/home/oracle/oradata/datafile/sysaux01.dbf' ;
- set newname for datafile 4 to '/home/oracle/oradata/datafile/users01.dbf' ;
- set newname for datafile 5 to '/home/oracle/oradata/datafile/example01.dbf' ;
- set newname for datafile 6 to '/home/oracle/oradata/datafile/gg01.dbf' ;
- restore database ;
- switch datafile all ;
- }2> 3> 4> 5> 6> 7> 8> 9> 10>
- executing command: SET NEWNAME
- executing command: SET NEWNAME
- executing command: SET NEWNAME
- executing command: SET NEWNAME
- executing command: SET NEWNAME
- executing command: SET NEWNAME
- Starting restore at 21-SEP-12
- Starting implicit crosscheck backup at 21-SEP-12
- allocated channel: ORA_DISK_1
- channel ORA_DISK_1: sid=156 devtype=DISK
- Crosschecked 2 objects
- Finished implicit crosscheck backup at 21-SEP-12
- Starting implicit crosscheck copy at 21-SEP-12
- using channel ORA_DISK_1
- Finished implicit crosscheck copy at 21-SEP-12
- searching for all files in the recovery area
- cataloging files...
- no files cataloged
- using channel ORA_DISK_1
- channel ORA_DISK_1: starting datafile backupset restore
- channel ORA_DISK_1: specifying datafile(s) to restore from backup set
- restoring datafile 00001 to /home/oracle/oradata/datafile/system01.dbf
- restoring datafile 00002 to /home/oracle/oradata/datafile/undotbs01.dbf
- restoring datafile 00003 to /home/oracle/oradata/datafile/sysaux01.dbf
- restoring datafile 00004 to /home/oracle/oradata/datafile/users01.dbf
- restoring datafile 00005 to /home/oracle/oradata/datafile/example01.dbf
- restoring datafile 00006 to /home/oracle/oradata/datafile/gg01.dbf
- channel ORA_DISK_1: reading from backup piece /home/oracle/rman/full_GG1_20120921_18
- channel ORA_DISK_1: restored backup piece 1
- piece handle=/home/oracle/rman/full_GG1_20120921_18 tag=TAG20120921T020917
- channel ORA_DISK_1: restore complete, elapsed time : 00:00:46
- Finished restore at 21-SEP-12
- datafile 1 switched to datafile copy
- input datafile copy recid=8 stamp=794548607 filename=/home/oracle/oradata/datafile/system01.dbf
- datafile 2 switched to datafile copy
- input datafile copy recid=9 stamp=794548607 filename=/home/oracle/oradata/datafile/undotbs01.dbf
- datafile 3 switched to datafile copy
- input datafile copy recid=10 stamp=794548607 filename=/home/oracle/oradata/datafile/sysaux01.dbf
- datafile 4 switched to datafile copy
- input datafile copy recid=11 stamp=794548607 filename=/home/oracle/oradata/datafile/users01.dbf
- datafile 5 switched to datafile copy
- input datafile copy recid=12 stamp=794548607 filename=/home/oracle/oradata/datafile/example01.dbf
- datafile 6 switched to datafile copy
- input datafile copy recid=13 stamp=794548607 filename=/home/oracle/oradata/datafile/gg01.dbf
- RMAN>
8. 恢復資料庫應用日誌。
- SQL> recover adtabase using backup controlfile until cancel;
- ORA-00905: missing keyword
- SQL> recover database using backup controlfile until cancel;
- ORA-00279: change 531086 generated at 09/21/2012 02:09:18 needed for thread 1
- ORA-00289: suggestion : /home/oracle/archivelog/1_10_794474474.dbf
- ORA-00280: change 531086 for thread 1 is in sequence #10
-
Specify log: {
=suggested | filename | AUTO | CANCEL} - cancel
- Media recovery cancelled.
- SQL> alter database open resetlogs;
- alter database open resetlogs
- *
- ERROR at line 1:
- ORA-00344: unable to re- create online log '/home/oracle/oradata/gg1/redo01.log'
- ORA-27040: file create error, unable to create file
- Linux Error: 2: No such file or directory
這裡在開啟資料庫時出現錯誤, 原因是因為在開啟資料庫時, ORACLE 會根據控制檔案來建立,這裡控制檔案記錄的位置,目標機上並沒有, 所以我們在開啟資料庫時建立這個目錄。
- [oracle@GOLDENGATE2 oradata]$ mkdir gg1
- [oracle@GOLDENGATE2 oradata]$ sqlplus / as sysdba
- SQL*Plus: Release 10.2.0.1.0 - Production on Fri Sep 21 04:03:20 2012
- Copyright (c) 1982, 2005, Oracle. All rights reserved.
- Connected to :
- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
- With the Partitioning, OLAP and Data Mining options
- SQL> alter database open resetlogs;
- Database altered.
在這裡會自動建立REDO和臨時表空間資料檔案。
9. 將日誌檔案重建立到/home/oracle/oradata/datafile下。
- SQL> select group #,bytes/1024/1024|| 'M' ,status from v$log;
- GROUP # BYTES/1024/1024|| 'M' STATUS
- ---------- ----------------------------------------- ----------------
- 1 50M UNUSED
- 2 50M UNUSED
- 3 50M CURRENT
- SQL> alter database drop logfile group 1;
- Database altered.
- SQL> alter database add logfile group 1( '/home/oracle/oradata/datafile/redo01.log' ) size 50m;
- Database altered.
- SQL> alter database drop logfile group 2;
- Database altered.
- SQL> alter database add logfile group 2( '/home/oracle/oradata/datafile/redo02.log' ) size 50m;
- Database altered.
- SQL> alter system switch logfile;
- System altered.
- SQL> alter system switch logfile;
- System altered.
- SQL> select group #,bytes/1024/1024|| 'M' ,status from v$log;
- GROUP # BYTES/1024/1024|| 'M' STATUS
- ---------- ----------------------------------------- ----------------
- 1 50M ACTIVE
- 2 50M CURRENT
- 3 50M INACTIVE
- SQL> alter database drop logfile group 3;
- Database altered.
- SQL> alter database add logfile group 3( '/home/oracle/oradata/datafile/redo03.log' ) size 50m;
- Database altered.
- SQL> select member from v$logfile;
- MEMBER
- --------------------------------------------------------------------------------
- /home/oracle/oradata/datafile/redo03.log
- /home/oracle/oradata/datafile/redo02.log
- /home/oracle/oradata/datafile/redo01.log
10. 處理臨時表空間檔案。
查詢臨時檔案:
- SQL> select name from v$tempfile;
- NAME
- --------------------------------------------------------------------------------
- /home/oracle/oradata/gg1/temp01.dbf
將臨時表空間置為OFFLINE狀態:
- SQL> alter database tempfile '/home/oracle/oradata/gg1/temp01.dbf' offline;
- Database altered.
主機移動檔案位置:
- SQL> !mv /home/oracle/oradata/gg1/temp01.dbf /home/oracle/oradata/datafile/temp01.dbf
在控制檔案中修改臨時檔案位置:
- SQL> alter database rename file '/home/oracle/oradata/gg1/temp01.dbf' to '/home/oracle/oradata/datafile/temp01.dbf' ;
- Database altered.
置臨時表空間為ONLINE:
- SQL> alter database tempfile '/home/oracle/oradata/datafile/temp01.dbf' online;
- Database altered.
查詢臨時表空間檔案:
- SQL> select name from v$tempfile;
- NAME
- --------------------------------------------------------------------------------
- /home/oracle/oradata/datafile/temp01.dbf
11. 關閉資料庫,建立SPFILE檔案,啟動資料庫
- SQL> shutdown immediate;
- Database closed.
- Database dismounted.
- ORACLE instance shut down.
- SQL> create spfile from pfile= '/home/oracle/initgg1.ora' ;
- File created.
- SQL> startup
- ORACLE instance started.
- Total System Global Area 167772160 bytes
- Fixed Size 1218292 bytes
- Variable Size 83888396 bytes
- Database Buffers 75497472 bytes
- Redo Buffers 7168000 bytes
- Database mounted.
- Database opened.
- SQL>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29863023/viewspace-1331061/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle RMAN異機恢復Oracle
- oracle的RMAN異機恢復Oracle
- rman恢復方案和oracle異機恢復Oracle
- Oracle 12c RMAN 異機恢復Oracle
- Oracle 11g RMAN 異機恢復Oracle
- RMAN異機恢復總結
- oracle 異機恢復Oracle
- 透過搭建恢復目錄實現RMAN異地備份和恢復
- oracle10gR2之RMAN異機恢復案例Oracle
- oracle 10.2.0.1 win 32 rman 備份異機恢復Oracle
- rman之同平臺異機恢復
- 初試Oracle的RMAN異地異系統恢復…………失敗…………Oracle
- RMAN異機恢復異作業系統(Linux到Windows)作業系統LinuxWindows
- RMAN異機恢復:RAC到單例項單例
- 異機恢復RMAN-05517解決方法
- RMAN備份異機恢復流程總結
- oracle冷備份、恢復和異機恢復Oracle
- RMAN異地恢復實戰
- 兩篇oracle異機恢復文章Oracle
- Oracle 11.2.0.4 從單例項,使用RMAN 異機恢復到RACOracle單例
- 用 RMAN 備份異機恢復 遷移資料
- 再來Oracle的RMAN異地異系統恢復,總算能open了Oracle
- Oracle備份恢復之熱備份恢復及異機恢復Oracle
- ORACLE 11.2.0.4 RAC RMAN異機恢復之ORA-15001Oracle
- Netbackup+oracle db 異機恢復案例Oracle
- Oracle 10g使用RMAN恢復目錄筆記Oracle 10g筆記
- 使用RMAN實現異機備份恢復(WIN平臺)
- standby全庫rman備份檔案恢復到異機
- oracle實驗記錄 (恢復-rman恢復)Oracle
- oracle11gR2_64之rman異機恢復(FS->FS)完整案例Oracle
- rman之建立恢復目錄筆記筆記
- 使用RMAN恢復目錄(catalog)解析
- oracle 11G r2 異機恢復Oracle
- rman 異機恢復指令碼(路徑不一致)指令碼
- RMAN Catalog環境下異機全庫恢復例項
- Oracle 11g RMAN 異機恢復報錯 RMAN-06172、ORA-07202Oracle
- G017-ORACLE-MIGRATION-01 RMAN備份異機不完全恢復Oracle
- ORACLE中採用rman備份異機恢復資料庫詳細過程Oracle資料庫