Oracle RMAN異機恢復
實驗場景:
資料庫伺服器本機磁碟損壞,資料庫無法實現本機恢復;
存在完整的RMAN全備及歸檔備份,透過RMAN進行異機恢復;
實驗環境:
源庫:IP(192.0.2.12),HOSTNAME(edbj2p2),DB(PROD3)
目標庫:IP(192.0.2.11),HOSTNAME(edbj2p1)
實驗過程如下:
一:源庫,建立測試資料:
SQL> create user chen identified by a;
SQL> grant connect,resource to chen;
SQL> conn chen/a
SQL> create table test as select level as id from dual connect by level<=5;
SQL> select * from test;
ID
----------
1
2
3
4
5
二:源庫,進行RMAN全備
[oracle@edbjr2p2 bin]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jul 19 21:48:16 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD3 (
DBID=1562953461)
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name PROD3 are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_PROD3.f'; # default
RMAN> run{
2> allocate channel c1 type disk;
3> backup full database format '/home/oracle/rmanbak/db_full_%T_%u.bak' tag='FULL' include current controlfile;
4> sql 'alter system archive log current';
5> backup archivelog all format '/home/oracle/rmanbak/arc_%T_%u.bak' delete all input;
6> release channel c1;
7> }
allocated channel: c1
channel c1: SID=139 device type=DISK
Starting backup at 19-JUL-17
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD3/users01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD3/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD3/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD3/undotbs01.dbf
channel c1: starting piece 1 at 19-JUL-17
channel c1: finished piece 1 at 19-JUL-17
piece handle=
/home/oracle/rmanbak/db_full_20170719_01s9p6s1.bak tag=FULL comment=NONE
channel c1: backup set complete, elapsed time: 00:00:35
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including
current control file in backup set
including
current SPFILE in backup set
channel c1: starting piece 1 at 19-JUL-17
channel c1: finished piece 1 at 19-JUL-17
piece handle=
/home/oracle/rmanbak/db_full_20170719_02s9p6t4.bak tag=FULL comment=NONE
channel c1: backup set complete, elapsed time: 00:00:03
Finished backup at 19-JUL-17
sql statement:
alter system archive log current
Starting backup at 19-JUL-17
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=7 RECID=1 STAMP=949787112
input archived log thread=1 sequence=8 RECID=2 STAMP=949787564
input archived log thread=1 sequence=9 RECID=3 STAMP=949787564
channel c1: starting piece 1 at 19-JUL-17
channel c1: finished piece 1 at 19-JUL-17
piece handle=
/home/oracle/rmanbak/arc_20170719_03s9p6tc.bak tag=TAG20170719T215244 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:03
channel c1: deleting archived log(s)
archived log file name=/u01/app/oracle/fast_recovery_area/PROD3/archivelog/2017_07_19/o1_mf_1_7_dpyrm5bd_.arc RECID=1 STAMP=949787112
archived log file name=/u01/app/oracle/fast_recovery_area/PROD3/archivelog/2017_07_19/o1_mf_1_8_dpys1d88_.arc RECID=2 STAMP=949787564
archived log file name=
/u01/app/oracle/fast_recovery_area/PROD3/archivelog/2017_07_19/o1_mf_1_9_dpys1dd4_.arc RECID=3 STAMP=949787564
Finished backup at 19-JUL-17
released channel: c1
三:打包備份檔案,並傳到目標資料庫
源庫:
[oracle@edbjr2p2 rmanbak]$ pwd
/home/oracle/rmanbak
[oracle@edbjr2p2 rmanbak]$
tar -zcvf rmanbak.tar.gz *
arc_20170719_03s9p6tc.bak
db_full_20170719_01s9p6s1.bak
db_full_20170719_02s9p6t4.bak
[oracle@edbjr2p2 rmanbak]$ ll -rth
total 361M
-rw-r----- 1 oracle oinstall 239M Jul 19 21:52 db_full_20170719_01s9p6s1.bak
-rw-r----- 1 oracle oinstall 9.2M Jul 19 21:52 db_full_20170719_02s9p6t4.bak
-rw-r----- 1 oracle oinstall 51M Jul 19 21:52 arc_20170719_03s9p6tc.bak
-rw-r--r-- 1 oracle oinstall 61M Jul 19 21:56 rmanbak.tar.gz
[oracle@edbjr2p2 rmanbak]$ scp rmanbak.tar.gz 192.0.2.11:/home/oracle/rmanbak
The authenticity of host '192.0.2.11 (192.0.2.11)' can't be established.
RSA key fingerprint is 4a:08:1a:c4:c8:bb:3b:01:49:b5:2f:58:af:9e:06:af.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.0.2.11' (RSA) to the list of known hosts.
oracle@192.0.2.11's password:
rmanbak.tar.gz 100% 61MB 30.3MB/s 00:02
目標庫:
[oracle@edbjr2p1 rmanbak]$ pwd
/home/oracle/rmanbak
[oracle@edbjr2p1 rmanbak]$ tar -zxvf rmanbak.tar.gz
arc_20170719_03s9p6tc.bak
db_full_20170719_01s9p6s1.bak
db_full_20170719_02s9p6t4.bak
[oracle@edbjr2p1 rmanbak]$ ll -rth
total 361M
-rw-r----- 1 oracle oinstall 239M Jul 19 21:52 db_full_20170719_01s9p6s1.bak
-rw-r----- 1 oracle oinstall 9.2M Jul 19 21:52 db_full_20170719_02s9p6t4.bak
-rw-r----- 1 oracle oinstall 51M Jul 19 21:52 arc_20170719_03s9p6tc.bak
-rw-r--r-- 1 oracle oinstall 61M Jul 19 21:58 rmanbak.tar.gz
三:目標庫,建立對應目錄
[oracle@edbjr2p1 rmanbak]$ mkdir -p /u01/app/oracle/oradata/PROD3
[oracle@edbjr2p1 ~]$ mkdir -p /u01/app/oracle/admin/PROD3/adump
[oracle@edbjr2p1 rmanbak]$ mkdir -p /u01/app/oracle/fast_recovery_area/PROD3/archivelog/2017_07_19
四:目標庫,執行RMAN執行資料恢復
(1)恢復引數檔案
(2)恢復控制檔案
(3)
恢復資料庫
[oracle@edbjr2p1 rmanbak]$ export ORACLE_SID=PROD3
[oracle@edbjr2p1 rmanbak]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jul 19 22:05:46 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN>
set dbid 1562953461
executing command: SET DBID
RMAN>
startup nomount
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initPROD3.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area 159019008 bytes
Fixed Size 1343612 bytes
Variable Size 79695748 bytes
Database Buffers 71303168 bytes
Redo Buffers 6676480 bytes
RMAN> restore spfile from '/home/oracle/rmanbak/db_full_20170719_02s9p6t4.bak';
Starting restore at 19-JUL-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=111 device type=DISK
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /home/oracle/rmanbak/db_full_20170719_02s9p6t4.bak
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 19-JUL-17
RMAN> startup nomount force
Oracle instance started
Total System Global Area 209235968 bytes
Fixed Size 1343948 bytes
Variable Size 180358708 bytes
Database Buffers 20971520 bytes
Redo Buffers 6561792 bytes
RMAN> restore controlfile from '/home/oracle/rmanbak/db_full_20170719_02s9p6t4.bak';
Starting restore at 19-JUL-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 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/PROD3/control01.ctl
output file name=/u01/app/oracle/oradata/PROD3/control02.ctl
Finished restore at 19-JUL-17
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> restore database;
Starting restore at 19-JUL-17
Starting implicit crosscheck backup at 19-JUL-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 19-JUL-17
Starting implicit crosscheck copy at 19-JUL-17
using channel ORA_DISK_1
Finished implicit crosscheck copy at 19-JUL-17
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/PROD3/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/PROD3/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/PROD3/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/PROD3/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/rmanbak/db_full_20170719_01s9p6s1.bak
channel ORA_DISK_1: piece handle=/home/oracle/rmanbak/db_full_20170719_01s9p6s1.bak tag=FULL
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:39
Finished restore at 19-JUL-17
RMAN> recover database;
Starting recover at 19-JUL-17
using channel ORA_DISK_1
starting media recovery
unable to find archived log
archived log thread=1 sequence=8
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/19/2017 22:20:27
RMAN-06054: media recovery requesting unknown archived log for thread
1 with sequence
8 and starting SCN of
241384
---報錯原因:RMAN備份不會備份當前的redo logfile檔案,異機恢復時找不到redo logfile,所以報錯rman-06054
---解決方案:基於SCN的不完全恢復
RMAN> run {
2> set until scn 241384;
3> recover database;
4> }
executing command: SET until clause
Starting recover at 19-JUL-17
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 19-JUL-17
RMAN> alter database open resetlogs;
database opened
五:目標庫,驗證資料
[oracle@edbjr2p1 rmanbak]$ export ORACLE_SID=PROD3
[oracle@edbjr2p1 rmanbak]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 19 22:41:57 2017
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from chen.test;
ID
----------
1
2
3
4
5
歡迎關注我的微信公眾號"IT小Chen",共同學習,共同成長!!!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29785807/viewspace-2142317/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- RMAN備份異機恢復
- ORACLE 11.2.0.4 RAC RMAN異機恢復之ORA-15001Oracle
- oracle 異機恢復Oracle
- RMAN備份恢復典型案例——異機恢復未知DBID
- rman備份異機恢復(原創)
- Oracle RMAN恢復測試Oracle
- G017-ORACLE-MIGRATION-01 RMAN備份異機不完全恢復Oracle
- Oracle RMAN 表空間恢復Oracle
- 兩篇oracle異機恢復文章Oracle
- Oracle 備份恢復篇之RMAN catalogOracle
- ORACLE DG從庫 Rman備份恢復Oracle
- Oracle 12C新特性-RMAN恢復表Oracle
- 【資料遷移1】Oracle 10gR2 rman異機恢復實驗(FS->RAW)(1)Oracle 10g
- 【資料遷移1】Oracle 10gR2 rman異機恢復實驗(FS->RAW)(2)Oracle 10g
- RMAN增量恢復
- 透過搭建恢復目錄實現RMAN異地備份和恢復
- 【RMAN】Oracle12c以後rman 備份恢復命令參考Oracle
- RMAN恢復實踐
- 通過rman為客戶實現linux下oracle11.2.0.4到windows下oracle同版本資料庫的異機恢復。LinuxOracleWindows資料庫
- oracle ORA-01180 ORA-01110(rman恢復問題)Oracle
- NBU恢復Oracle通道完成後RMAN沒有進度Oracle
- RMAN資料庫恢復異常報錯ORA-01180資料庫
- RMAN恢復之RMAN-06555處理
- Oracle asm磁碟損壞異常恢復OracleASM
- rman 增量備份恢復
- RMAN備份恢復技巧
- Oracle9i RMAN 的優缺點及RMAN 備份及恢復步驟Oracle
- 7_Oracle truncate異常恢復之plsql修復OracleSQL
- 6_Oracle truncate異常恢復之bbed修復Oracle
- Windows oracle 11g rman備份恢復到linux系統WindowsOracleLinux
- 查詢RMAN恢復進度
- Rman_異地、跨平臺、跨版本的恢復總結及案例
- Networker恢復oracle rac到單機Oracle
- RMAN備份恢復效能優化優化
- 在rman恢復中incarnation的概念
- RMAN備份與恢復測試
- 【RMAN】Oracle12c之後,rman備份Dataguard備端恢復可能出現邏輯錯誤Oracle
- NBU恢復oracleOracle
- 【北亞資料恢復】異常斷電導致Oracle資料庫報錯的oracle資料恢復資料恢復Oracle資料庫