久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Oracle RMAN異機恢復的示例分析

151次閱讀
沒有評論

共計 9767 個字符,預計需要花費 25 分鐘才能閱讀完成。

這篇文章給大家分享的是有關 Oracle RMAN 異機恢復的示例分析的內容。丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,一起跟隨丸趣 TV 小編過來看看吧。

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
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

感謝各位的閱讀!關于“Oracle RMAN 異機恢復的示例分析”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-20發表,共計9767字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 灌阳县| 泸州市| 仲巴县| 克拉玛依市| 肇东市| 霍林郭勒市| 德清县| 南安市| 阳泉市| 湟中县| 台东市| 阳东县| 九龙县| 准格尔旗| 昌乐县| 庆阳市| 周宁县| 镇远县| 天津市| 武冈市| 峨山| 聊城市| 普安县| 明星| 赤峰市| 汤阴县| 正安县| 蓝田县| 开鲁县| 离岛区| 观塘区| 石渠县| 渑池县| 金溪县| 奉化市| 富锦市| 华宁县| 新兴县| 盖州市| 汶上县| 洛浦县|