当前位置:文档之家› ORACLE11G RMAN备份恢复到异机数据库

ORACLE11G RMAN备份恢复到异机数据库

ORACLE11G RMAN备份恢复到异机数据库1. 主数据库环境操作系统版本 : Centos6.7 x64数据库版本 : Oracle 11.2.0.4 x64数据库名 : prb数据库SID : prbdb_unique_name : prbinstance_name : prbIP : 10.0.8.1002. 备库环境操作系统版本 : Centos6.7 x64数据库版本 : Oracle 11.2.0.4 x64 (只安装oracle数据库软件,no netca dbca)数据库名 : prb数据库SID : prbdb_unique_name: prbinstance_name : prbIP:10.0.8.101将参数文件备份、控制文件备份、数据文件备份、以及归档备份到目标主机1 此处实验环境为同平台,同字节序,同版本,源机器和目标机器相同的目录结构。

2 目标机器只需要安装oracle只安装oracle数据库软件,no netca dbca3 第一次利用备份恢复测试环境,之后从源机器拷贝备份到目标机器并在控制文件中注册,再见行恢复测试。

备份数据库backup format '/u01/prb/rmanbk/fulldb_%d_%U' database include current controlfile plus archivelog delete input;orapwd file='/u01/app/oracle/product/11.2.0.4/db_1/dbs/orapwprb' password=oracle entries=10 force=y1rman 连接到源数据库prd-db1-> rman target /Recovery Manager: Release 11.2.0.4.0 - Production on Wed Aug 17 19:23:27 2016 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: PRB (DBID=1906641159)RMAN>2 分别列出参数文件备份,控制文件备份,数据文件备份,以及归档备份的名字参数文件备份如下:RMAN> list backup of spfile;using target database control file instead of recovery catalogList of Backup Sets===================BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -------------------3 Full 9.36M DISK 00:00:01 2016/08/17 16:47:34BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20160817T164718 Piece Name: /u01/prb/rmanbk/fulldb_PRB_04rdg8d5_1_1SPFILE Included: Modification time: 2016/08/17 16:30:57SPFILE db_unique_name: PRB控制文件备份如下:RMAN> list backup of controlfile;List of Backup Sets===================BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -------------------3 Full 9.36M DISK 00:00:01 2016/08/17 16:47:34BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20160817T164718 Piece Name: /u01/prb/rmanbk/fulldb_PRB_04rdg8d5_1_1Control File Included: Ckp SCN: 972048 Ckp time: 2016/08/17 16:47:33数据文件备份如下:RMAN> list backup of database;List of Backup Sets===================BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -------------------2 Full 1.08G DISK 00:00:15 2016/08/17 16:47:33BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20160817T164718 Piece Name: /u01/prb/rmanbk/fulldb_PRB_03rdg8cm_1_1List of Datafiles in backup set 2File LV Type Ckp SCN Ckp Time Name---- -- ---- ---------- ------------------- ----1 Full 972030 2016/08/17 16:47:18 /u01/app/oracle/oradata/prb/system01.dbf2 Full 972030 2016/08/17 16:47:18 /u01/app/oracle/oradata/prb/sysaux01.dbf3 Full 972030 2016/08/17 16:47:18 /u01/app/oracle/oradata/prb/undotbs01.dbf4 Full 972030 2016/08/17 16:47:18 /u01/app/oracle/oradata/prb/users01.dbf列出归档备份如下:RMAN> list backup of archivelog all;List of Backup Sets===================BS Key Size Device Type Elapsed Time Completion Time------- ---------- ----------- ------------ -------------------1 68.93M DISK 00:00:01 2016/08/17 16:47:17BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20160817T164716 Piece Name: /u01/prb/rmanbk/fulldb_PRB_02rdg8ck_1_1List of Archived Logs in backup set 1Thrd Seq Low SCN Low Time Next SCN Next Time---- ------- ---------- ------------------- ---------- ---------1 4 955212 2016/08/17 16:26:15 966337 2016/08/17 16:28:09 1 5 966337 2016/08/17 16:28:09 971912 2016/08/17 16:45:39 1 6 971912 2016/08/17 16:45:39 972019 2016/08/17 16:47:16 BS Key Size Device Type Elapsed Time Completion Time------- ---------- ----------- ------------ -------------------4 13.00K DISK 00:00:00 2016/08/17 16:47:35BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20160817T164735 Piece Name: /u01/prb/rmanbk/fulldb_PRB_05rdg8d7_1_1List of Archived Logs in backup set 4Thrd Seq Low SCN Low Time Next SCN Next Time---- ------- ---------- ------------------- ---------- ---------1 7 972019 2016/08/17 16:47:16 972053 2016/08/17 16:47:35 目标主机创建相应的目录mkdir -p /u01/app/oracle/admin/prb/{adump,dpdump,pfile,scripts}mkdir -p /u01/app/oracle/oradata/prbmkdir -p /u01/app/oracle/fast_recovery_area/prbmkdir -p /u01/prb/rmanbkmkdir -p /u01/archivelog3 将备份文件、密码文件copy到目标主机scp /u01/prb/rmanbk/* oracle@prd-db2:/u01/prb/rmanbk/scp /u01/app/oracle/product/11.2.0.4/db_1/dbs/orapwprb oracle@prd-db2:/u01/app/oracle/product/11.2.0.4/db_1/dbs/恢复参数文件及控制文件1 配置新主机上的ORACLE_SIDecho 'db_name=prb' > $ORACLE_HOME/dbs/initprb.oraexport ORACLE_SID=prbsqlplus / as sysdba@prbstartup nomount pfile='/u01/app/oracle/product/11.2.0.4/db_1/dbs/initprb.ora' 目标主机上发起rman连接prd-db2-> rman target /Recovery Manager: Release 11.2.0.4.0 - Production on Wed Aug 17 18:36:34 2016 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database (not started)设置dbid 并启动实例到nomount状态RMAN> set dbid 3601019238executing command: SET DBIDRMAN> startup nomount;Oracle instance startedTotal System Global Area 217157632 bytesFixed Size 2251816 bytesVariable Size 159384536 bytesDatabase Buffers 50331648 bytesRedo Buffers 5189632 bytes恢复spfile文件RMAN> restore spfile to '/u01/app/oracle/product/11.2.0.4/db_1/dbs/spfileprb.ora' from '/u01/prb/rmanbk/fulldb_PRB_04rdg8d5_1_1';Starting restore at 2016/08/17 18:37:40allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=19 device type=DISKchannel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/prb/rmanbk/fulldb_PRB_04rdg8d5_1_1channel ORA_DISK_1: SPFILE restore from AUTOBACKUP completeFinished restore at 2016/08/17 18:37:41startup force nomountRMAN> startup force nomount;Oracle instance startedTotal System Global Area 584568832 bytesFixed Size 2255432 bytesVariable Size 226493880 bytesDatabase Buffers 352321536 bytesRedo Buffers 3497984 bytes恢复控制文件RMAN> restore controlfile to '/u01/app/oracle/oradata/prb/control01.ctl' from '/u01/prb/rmanbk/fulldb_PRB_04rdg8d5_1_1';Starting restore at 2016/08/17 18:38:26allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=19 device type=DISKchannel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:01Finished restore at 2016/08/17 18:38:27启动数据库到加载状态RMAN> alter database mount;RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of alter db command at 08/17/2016 18:38:39ORA-00205: error in identifying control file, check alert log for more infoprd-db2-> export ORACLE_SID=prbprd-db2-> sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 17 18:42:04 2016Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> shutdown immediate;ORA-01507: database not mountedORACLE instance shut down.SQL> startup mount;ORACLE instance started.Total System Global Area 584568832 bytesFixed Size 2255432 bytesVariable Size 226493880 bytesDatabase Buffers 352321536 bytesRedo Buffers 3497984 bytesORA-00205: error in identifying control file, check alert log for more info 解决办法:scp /u01/app/oracle/oradata/prb/control01.ctl prd-db2:/u01/app/oracle/oradata/prb/ scp /u01/app/oracle/fast_recovery_area/prb/ control02.ctlprd-db2:/u01/app/oracle/fast_recovery_area/prb/启动到mount状态正常SQL> startup mountORACLE instance started.Total System Global Area 584568832 bytesFixed Size 2255432 bytesVariable Size 226493880 bytesDatabase Buffers 352321536 bytesRedo Buffers 3497984 bytesDatabase mounted.三 在新控制文件中注册数据文件备份和归档备份prd-db2-> rman target /Recovery Manager: Release 11.2.0.4.0 - Production on Wed Aug 17 18:52:34 2016 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: PRB (DBID=1906641159, not open)RMAN> catalog start with '/u01/prb/rmanbk/';using target database control file instead of recovery catalogsearching for all files that match the pattern /u01/prb/rmanbk/no files found to be unknown to the database恢复整个库RMAN> restore database;Starting restore at 2016/08/17 18:53:42allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=18 device type=DISKchannel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/prb/system01.dbfchannel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/prb/sysaux01.dbfchannel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/prb/undotbs01.dbfchannel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/prb/users01.dbfchannel ORA_DISK_1: reading from backup piece /u01/prb/rmanbk/fulldb_PRB_03rdg8cm_1_1channel ORA_DISK_1: piece handle=/u01/prb/rmanbk/fulldb_PRB_03rdg8cm_1_1 tag=TAG20160817T164718channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:15Finished restore at 2016/08/17 18:53:57RMAN> recover database;Starting recover at 2016/08/17 18:54:12using channel ORA_DISK_1starting media recoverychannel ORA_DISK_1: starting archived log restore to default destination channel ORA_DISK_1: restoring archived logarchived log thread=1 sequence=7channel ORA_DISK_1: reading from backup piece /u01/prb/rmanbk/fulldb_PRB_05rdg8d7_1_1channel ORA_DISK_1: piece handle=/u01/prb/rmanbk/fulldb_PRB_05rdg8d7_1_1 tag=TAG20160817T164735channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:01archived log file name=/u01/app/oracle/fast_recovery_area/PRB/archivelog/2016_08_17/o1_mf_1_7_cv8 jlo4y_.arc thread=1 sequence=7RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 08/17/2016 18:54:14ORA-00283: recovery session canceled due to errorsRMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile'/u01/app/oracle/fast_recovery_area/PRB/archivelog/2016_08_17/o1_mf_1_7_cv8jlo4 y_.arc'ORA-00283: recovery session canceled due to errorsORA-00313: open failed for members of log group 2 of thread 1ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/prb/redo02.log'ORA-27037: unable to obtain file statusLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3缺失归档日志情况下的恢复prd-db2-> export ORACLE_SID=prbprd-db2-> sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 17 19:03:52 2016Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> shutdown immediate;ORA-01109: database not openDatabase dismounted.ORACLE instance shut down.SQL> startup mount;ORACLE instance started.Total System Global Area 584568832 bytesFixed Size 2255432 bytesVariable Size 226493880 bytesDatabase Buffers 352321536 bytesRedo Buffers 3497984 bytesDatabase mounted.SQL> alter database open ;alter database open*ERROR at line 1:ORA-01589: must use RESETLOGS or NORESETLOGS option for database openSQL> alter database open noresetlogs;alter database open noresetlogs*ERROR at line 1:ORA-01588: must use RESETLOGS option for database openSQL> alter database open resetlogs;Database altered.SQL> select max(sequence#) from v$archived_log;MAX(SEQUENCE#)--------------7数据库正常启动prd-db2-> export ORACLE_SID=prbprd-db2-> sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 17 19:11:49 2016Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 584568832 bytesFixed Size 2255432 bytesVariable Size 226493880 bytesDatabase Buffers 352321536 bytesRedo Buffers 3497984 bytesDatabase mounted.Database opened.。

相关主题