十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
这篇文章给大家分享的是有关Oracle RMAN异机恢复的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
南浔ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!
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.baktag=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 filein backup set
including current SPFILEin 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.baktag=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.baktag=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 1with sequence
8and 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异机恢复的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!