RMAN 备份集在异机异路径下恢复过程详解

合集下载

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

通过RMAN备份Oracle数据库恢复到其他服务器(案例)

通过RMAN备份Oracle数据库恢复到其他服务器(案例)

通过RMAN备份Oracle数据库恢复到其他服务器(案例)通过RMAN备份Oracle数据库恢复到其他服务器(案例)本节演示如何通过RMAN创建的备份集,将数据库恢复到其他服务器。

本小节执行的操作较多,一定要有一个清醒的大脑,因此赶紧把脑袋里那堆乱七八糟的东西清除清除,要不你一定会看晕的。

设定环境如下:源库192.168.100.100,SID:orcdb。

目录库192.168.100.101,已安装与源库相同版本的数据库软件(一定要相同版本哟)。

准备工作如下:记录下源数据库的DBID,DBID的获取方式上节已讲过。

创建完整备份集(含控制文件、数据文件、归档文件),源库为非归档模式也可以,只要确保创建的备份是一致备份,然后将备份集复制到目标服务器的相同路径下。

为简单起见,源端与目标端目录结构保持一致。

如果你在测试或正式操作时由于实际原因无法保持源端与目标端结构一致,在恢复过程中注意修改相关路径。

操作步骤如下:注意,下列操作如非特别注明,均是在目标端服务器上进行的。

1.在源库端创建数据库的完整备份Backup database;备份集创建成功之后,将其复制到目录端的相同路径下,强调一点,必须是相同路径。

复制方式灵活多样,Windows环境可以直接通过共享复制,Linux/UNIX下可以通过FTP。

2.在目标服务器上创建OracleService如果是Linux/UNIX环境,不需要执行本步骤,只要在连接数据库时指定ORACLE_SID环境变量即可。

如果是Windows服务器,需要通过ORADIM命令创建一个OracleService,创建的SID要与源库相同,操作如下:1. C:\Documents and Settings\Administrator>ORADIM -NEW -SID orcdb2. Instance created.上述命令创建了一个名为orcdb的OracleService。

Oracle RMAN异机恢复

Oracle RMAN异机恢复

Oracle RMAN异机恢复By 刘鹏松liups@ 环境:源库的控制文件信息:源库的数据文件信息:源库的在线重做日志信息:说明:由于此次异机恢复的数据文件、控制文件和在线重做日志文件的路径跟源主机的路径都不相同,所以要在恢复的时候进行一些相关操作。

本次异机恢复采用的是源主机上的l0备份,备份的脚本如下:备份文件信息如下:其中yqpt_l0_201107221603_c-755730391-20110722-03是控制文件和参数文件的备份集。

DBID是755730391。

将所有l0的备份文件copy到目标主机上,并放到跟源主机相同的路径下面,如果不一样可以采用软连接的方式实现。

1、创建空实例1.1.在目标主机上安装Oracle软件,不创建数据库1.2.创建相关目录1.3.创建密码文件2、异机恢复以下所有操作在目标主机上操作2.1设置DBID2.2 启动目标数据库到nomount状态这里会提示找不到参数文件,不用管,下一步进行恢复2.3 恢复参数文件如果要修改参数文件,比如sga、文件路径信息,现在要修改。

如果源主机和目标主机配置相同的话,这里的参数文件不需要修改由于我们的控制文件的路径不同,所以要修改,将控制文件修改为目标主机的路径,同时dump的路径也需要修改,修改成我们先前建立的目录。

2.4 用启动的参数文件将数据重新启动到nomount状态2.5 根据修改后的参数文件恢复控制文件这样的话,控制文件就被恢复到/data/yqpt/下面了。

2.6 将数据库启动到mount状态2.7 restore and recover database由于数据文件路径不一样,通过set newname for datafile file# 将数据文件恢复到新的路径下面3、重命名在线重做日志文件由于在目标在线重做日志文件的路径与源库的不相同,所以要重命名在线重做日志,目标库的在线重做日志不需要存在,在open database的时候会自动创建在线重做日志。

Rman 异机恢复流程

Rman 异机恢复流程

Rman 异机恢复流程主机备份备份脚本change archivelog all crosscheck;change archivelog all crosscheck;CONFIGURE DEVICE TYPE DISK PARALLELISM 3;backup database format '/apps/oracle/backup/full_%d_%s_%T.bak' skip inaccessible PLUS ARCHIVELOG format '/apps/oracle/backup/full_%d_%s_%T.log';sql'alter system switch logfile';CONFIGURE DEVICE TYPE DISK PARALLELISM 1;原库的数据文件NAME--------------------------------------------------------------------------------/apps/oracle/oradata/orcldg/system01.dbf/apps/oracle/oradata/orcldg/sysaux01.dbf/apps/oracle/oradata/orcldg/undotbs01.dbf/apps/oracle/oradata/orcldg/users01.dbf将备份集scp目标服务器目标服务器安装ORACLE软件COPY原库的crotrolfile备份到目标库准备rman target /set db_id=原库的db_idStartup nomount;Restore spfile from'crotrolfile备份';Restore controlfile from 'crotrolfile备份';Shutdown abort;Startup nomunt;alter database mount;List backup of database;现实备份集BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------56 Full 419.66M DISK 00:02:29 27-FEB-12BP Key: 56 Status: A V AILABLE Compressed: NO Tag: TAG20120227T140950Piece Name: /apps/oracle/backup/full_ORCL_58_20120227.bakList of Datafiles in backup set 56File LV Type Ckp SCN Ckp Time Name---- -- ---- ---------- --------- ----2 Full 1383913 27-FEB-12 /apps/oracle/oradata/orcldg/sysaux01.dbf3 Full 1383913 27-FEB-12 /apps/oracle/oradata/orcldg/undotbs01.dbfBS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------57 Full 613.02M DISK 00:02:37 27-FEB-12BP Key: 57 Status: A V AILABLE Compressed: NO Tag: TAG20120227T140950Piece Name: /apps/oracle/backup/full_ORCL_59_20120227.bakList of Datafiles in backup set 57File LV Type Ckp SCN Ckp Time Name---- -- ---- ---------- --------- ----1 Full 1383914 27-FEB-12 /apps/oracle/oradata/orcldg/system01.dbf4 Full 1383914 27-FEB-12 /apps/oracle/oradata/orcldg/users01.dbf根据备份集利用dbms_backup_restore包进行恢复DECLAREdevtype varchar2(256);done boolean;BEGINdevtype:=sys.dbms_backup_restore.deviceAllocate (type=>'',ident=>'t1');sys.dbms_backup_restore.restoreSetDatafile;sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>2,toname=>'/apps/oracle/oradata/orcldg/s ysaux01.dbf');sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>3,toname=>'/apps/oracle/oradata/orcldg/u ndotbs01.dbf');sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/mnt/hgfs/sharelinux/oracle backup/full_ORCL_58_20120227.bak', params=>null);sys.dbms_backup_restore.deviceDeallocate;END;DECLAREdevtype varchar2(256);done boolean;BEGINdevtype:=sys.dbms_backup_restore.deviceAllocate (type=>'',ident=>'t1');sys.dbms_backup_restore.restoreSetDatafile;sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>1,toname=>'/apps/oracle/oradata/orcldg/s ystem01.dbf');sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>4,toname=>'/apps/oracle/oradata/orcldg/u sers01.dbf');sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/mnt/hgfs/sharelinux/oracle backup/full_ORCL_59_20120227.bak', params=>null);sys.dbms_backup_restore.deviceDeallocate;END;Shutdown immediate;Startup nomount;CREATE CONTROLFILE REUSE DATABASE "orcl" RESETLOGS FORCE LOGGING ARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 292LOGFILEGROUP 1 '/apps/oracle/oradata/orcldg/redo01.log' SIZE 50M BLOCKSIZE 512,GROUP 2 '/apps/oracle/oradata/orcldg/redo02.log' SIZE 50M BLOCKSIZE 512,GROUP 3 '/apps/oracle/oradata/orcldg/redo03.log' SIZE 50M BLOCKSIZE 512-- STANDBY LOGFILE-- GROUP 4 '/apps/oracle/oradata/orcldg/redo04.log' SIZE 50M BLOCKSIZE 512DA TAFILE'/apps/oracle/oradata/orcldg/system01.dbf','/apps/oracle/oradata/orcldg/sysaux01.dbf','/apps/oracle/oradata/orcldg/undotbs01.dbf','/apps/oracle/oradata/orcldg/users01.dbf'CHARACTER SET AL32UTF8;Shutdown immdiateStartup mount;Alter database open resetlogs;创建临时表空间create temporary tablespace TEMPA TEMPFILE '/data/oradata/cmgpdown/tempA01.dbf' SIZE 4G REUSE AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED;Alter database default tablespace TEMPA;可能会因为数据库的版本问题而照成的ORA-00604 ORA-06544 ORA-06553错误处理办法:原因分析:升级期间软件和db出现不一致手动重新升级数据库处理:重新升级数据库conn / as sysdbashutdown immediatestartup upgrade@?/rdbms/admin/catupgrd.sql @?/rdbms/admin/utlip.sql之后重启数据库恢复正常set archivelog destination to '';。

RMAN异机完全恢复(ASM存储)

RMAN异机完全恢复(ASM存储)

RMAN异机完全恢复(ASM)Author:J arwang(王重东)Date:2009-8-26本例环境:操作系统rhel5.3、数据库10g2,ASM存储+archive模式。

本例在假记原来的机器彻底over的情况,所尝试做的rman恢复。

a)在机器A上做一个ramn完全备份。

这个是前提条件,有点废话。

^_^RMAN>run{configure controlfile autobackup on;backup spfile format‘/opt/backup/spfile.bak;backup full database format'/opt/backup/prodfull%u_%s_%p'tag'prodfullbk' include current controlfile;}b)在机器B上安装数据库软件及配置SID环境,但不用创建数据库。

#mkdir–p$ORACLE_BASE/admin/$ORACLE_SID/adump#mkdir$ORACLE_BASE/admin/$ORACLE_SID/bdump#mkdir$ORACLE_BASE/admin/$ORACLE_SID/cdump#mkdir$ORACLE_BASE/admin/$ORACLE_SID/bpdump#mkdir$ORACLE_BASE/admin/$ORACLE_SID/udump#mkdir$ORACLE_BASE/admin/$ORACLE_SID/pfilec)在机器B上配置好ASM环境c.1oracleasm配置c.2fdisk分区以同样的方式给另一个磁盘分区。

c.3建立ASM磁盘查看是否创建成功:/etc/init.d/oracleasm listdisks c.3启动OCSSDd)在机器B上配置ASM实例。

运行DBCA注:ASM实例、ASM磁盘组保持一致(如不同,请修改后面的参数文件),并重启ASM实例。

Rman 异机恢复步骤

Rman 异机恢复步骤
set newname for datafile 23 to '/oradata_uat6/udb007/oradata_d0/udb007/symbols_part_data04.dbf';
set newname for datafile 24 to '/oradata_uat6/udb007/oradata_d1/udb007/symbols_part_data05.dbf';
set newname for datafile 11 to '/oradata_uat6/udb007/oradata_d0/udb007/symbols_part_data01.dbf';
set newname for datafilat6/udb007/oradata_d1/udb007/symbols_part_data02.dbf';
set newname for datafile 13 to '/oradata_uat6/udb007/oradata_d2/udb007/symbols_part_data03.dbf';
set newname for datafile 14 to '/oradata_uat6/udb007/oradata_d1/udb007/symadm_data01.dbf';
set newname for datafile 7 to '/oradata_uat6/udb007/oradata_d0/udb007/symbols_user.dbf';
set newname for datafile 8 to '/oradata_uat6/udb007/oradata_d0/udb007/symbols_data01.dbf';

RMAN的备份与恢复步骤详解

RMAN的备份与恢复步骤详解

RMAN的备份与恢复步骤详解RMAN(Recovery Manager)是Oracle数据库备份和恢复技术的核心工具,提供了一种集中管理和自动化备份和恢复操作的方式。

下面将详细介绍RMAN的备份与恢复步骤。

备份步骤:1.配置RMAN环境:确定RMAN备份目标、备份库、目标库的连接信息,并设置环境变量。

2.创建RMAN备份目标:使用CREATECATALOG命令创建RMAN备份目标,以存储备份信息和恢复目标的元数据。

3.创建备份策略:确定备份类型(完全备份、增量备份、增量备份级别等),备份周期(每日、每周)、备份级别(全局备份、局部备份)以及备份介质(磁盘、磁带)等。

4.执行备份命令:使用BACKUP命令执行备份操作。

根据备份策略选择相应的备份类型,并指定备份集的存储位置。

可以使用全量备份、增量备份或归档日志备份等方式进行备份。

5.备份验证和测试:使用RESTORE命令验证备份集是否可恢复。

可以恢复到测试库中,检查数据的完整性以及备份恢复的过程和时间。

恢复步骤:1.准备恢复环境:确定系统状态,关闭数据库、归档日志模式,备份控制文件,以备份增量恢复,恢复目标数据库的连接信息,并设置环境变量。

2.恢复控制文件:将备份的控制文件还原到指定位置,以获取数据库的结构信息。

3.恢复数据库文件:使用RESTORE命令恢复需要的数据文件。

可以选择完全恢复(使用全量备份和归档日志进行恢复)、增量恢复(使用增量备份和归档日志进行恢复)或点恢复(使用时间点或SCN号进行恢复)的方式。

4.打开数据库:使用OPENRESETLOGS命令打开数据库,恢复数据库文件到最新的状态。

5.检查恢复结果:验证恢复后数据库的完整性和一致性。

使用相应的SQL语句检查数据的正确性、索引的可用性和对象的有效性。

常见问题处理:1.恢复失败的处理:RMAN提供了很多失败后的处理命令,比如RECOVER命令来恢复损坏的数据文件,CROSSCHECK命令来检查备份文件的完整性等。

rman异机恢复实践全图解析解析

rman异机恢复实践全图解析解析

RMAN异机恢复实践全图解析全库备份(包括数据库,控制文件,归档日志)RMAN> run {2> backup full database format '/orabk/full_%U.bak';3> backup archivelog all format '/orabk/arc_%U.bak' delete input;4> copy current controlfile to '/orabk/control_bak.ctl';5> }Starting backup at 28-MAY-07using channel ORA_DISK_1channel ORA_DISK_1: starting full datafile backupsetchannel ORA_DISK_1: specifying datafile(s) in backupsetincluding current SPFILE in backupsetincluding current controlfile in backupsetinput datafile fno=00011 name=/u01/app/oracle/oradata/orcl9i/rep_test.dbfinput datafile fno=00001 name=/u01/app/oracle/oradata/orcl9i/system01.dbfinput datafile fno=00002 name=/u01/app/oracle/oradata/orcl9i/undotbs01.dbfinput datafile fno=00005 name=/u01/app/oracle/oradata/orcl9i/example01.dbfinput datafile fno=00012 name=/u01/app/oracle/oradata/orcl9i/rman_ts01.dbfinput datafile fno=00010 name=/u01/app/oracle/oradata/orcl9i/xdb01.dbfinput datafile fno=00006 name=/u01/app/oracle/oradata/orcl9i/indx01.dbfinput datafile fno=00009 name=/u01/app/oracle/oradata/orcl9i/users01.dbfinput datafile fno=00003 name=/u01/app/oracle/oradata/orcl9i/cwmlite01.dbfinput datafile fno=00004 name=/u01/app/oracle/oradata/orcl9i/drsys01.dbfinput datafile fno=00007 name=/u01/app/oracle/oradata/orcl9i/odm01.dbfinput datafile fno=00008 name=/u01/app/oracle/oradata/orcl9i/tools01.dbfchannel ORA_DISK_1: starting piece 1 at 28-MAY-07channel ORA_DISK_1: finished piece 1 at 28-MAY-07piece handle=/orabk/full_07iis0oe_1_1.bak comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:24:05Finished backup at 28-MAY-07Starting backup at 28-MAY-07current log archivedusing channel ORA_DISK_1channel ORA_DISK_1: starting archive log backupsetchannel ORA_DISK_1: specifying archive log(s) in backup setinput archive log thread=1 sequence=23 recid=23 stamp=623773878channel ORA_DISK_1: starting piece 1 at 28-MAY-07channel ORA_DISK_1: finished piece 1 at 28-MAY-07piece handle=/orabk/arc_08iis25m_1_1.bak comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:02channel ORA_DISK_1: deleting archive log(s)archive log filename=/u01/app/oracle/oradata/orcl9i/archive/1_23.dbf recid=23 stamp=623773878 Finished backup at 28-MAY-07Starting copy at 28-MAY-07using channel ORA_DISK_1channel ORA_DISK_1: copied current controlfileoutput filename=/orabk/control_bak.ctlFinished copy at 28-MAY-07RMAN>RMAN异机恢复实践。

基于RMAN增量差异备份的恢复步骤

基于RMAN增量差异备份的恢复步骤

基于RMAN增量差异备份的恢复步骤1.恢复背景2.恢复步骤2.1.建立恢复环境1.找一台硬件配置与原数据库服务器相同的服务器,在上面安装相同的操作和Oracle数据库(版本要一致);8.复制备份文件到原备份路径注意:要确保备份文件存放的路径与原数据库中的路径一致。

2.2.恢复过程完成implicit crosscheck backup 于10-10月-09启动implicit crosscheck copy 于10-10月-09使用通道ORA_DISK_1完成implicit crosscheck copy 于10-10月-09搜索恢复区域中的所有文件正在编制文件目录...没有为文件编制目录使用通道ORA_DISK_1通道ORA_DISK_1: 正在开始恢复数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件正将数据文件00001恢复到D:\ORA\SYS\SYSTEM01.DBF正将数据文件00005恢复到D:\ORA\ICITY\DA TA1.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB01HKQLPKP_2097_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB01HKQLPKP_2097_1 标记= DB0通道ORA_DISK_1: 恢复完成, 用时: 00:11:15通道ORA_DISK_1: 正在开始恢复数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件正将数据文件00004恢复到D:\ORA\SYS\USERS01.DBF正将数据文件00007恢复到D:\ORA\ICITY\DA TA3.DBF正将数据文件00008恢复到D:\ORA\RMANFILE\DBACKUPFILE.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB01IKQLPKP_2098_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB01IKQLPKP_2098_1 标记= DB0通道ORA_DISK_1: 恢复完成, 用时: 00:10:56通道ORA_DISK_1: 正在开始恢复数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件正将数据文件00002恢复到D:\ORA\SYS\UNDOTBS01.DBF正将数据文件00003恢复到D:\ORA\SYS\SYSAUX01.DBF正将数据文件00006恢复到D:\ORA\ICITY\DA TA2.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB01GKQLPKP_2096_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB01GKQLPKP_2096_1 标记= DB0通道ORA_DISK_1: 恢复完成, 用时: 00:14:25完成restore 于10-10月-09通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00001 的恢复目标: D:\ORA\SYS\SYSTEM01.DBF数据文件00005 的恢复目标: D:\ORA\ICITY\DA TA1.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB125KR0LMA_2117_1 通道ORA_DISK_1: 已恢复备份段 1段句柄= E:\ORA\RMANBAK\DB125KR0LMA_2117_1 标记= DB1通道ORA_DISK_1: 恢复完成, 用时: 00:00:03通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00004 的恢复目标: D:\ORA\SYS\USERS01.DBF数据文件00007 的恢复目标: D:\ORA\ICITY\DA TA3.DBF数据文件00008 的恢复目标: D:\ORA\RMANFILE\DBACKUPFILE.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB126KR0LMA_2118_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB126KR0LMA_2118_1 标记= DB1通道ORA_DISK_1: 恢复完成, 用时: 00:00:03通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00002 的恢复目标: D:\ORA\SYS\UNDOTBS01.DBF数据文件00003 的恢复目标: D:\ORA\SYS\SYSAUX01.DBF数据文件00006 的恢复目标: D:\ORA\ICITY\DA TA2.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB124KR0LM9_2116_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB124KR0LM9_2116_1 标记= DB1通道ORA_DISK_1: 恢复完成, 用时: 00:00:25通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00001 的恢复目标: D:\ORA\SYS\SYSTEM01.DBF数据文件00005 的恢复目标: D:\ORA\ICITY\DA TA1.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB229KR107N_2121_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB229KR107N_2121_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:01通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00004 的恢复目标: D:\ORA\SYS\USERS01.DBF数据文件00007 的恢复目标: D:\ORA\ICITY\DA TA3.DBF数据文件00008 的恢复目标: D:\ORA\RMANFILE\DBACKUPFILE.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22AKR107N_2122_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22AKR107N_2122_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:01通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00002 的恢复目标: D:\ORA\SYS\UNDOTBS01.DBF数据文件00003 的恢复目标: D:\ORA\SYS\SYSAUX01.DBF数据文件00006 的恢复目标: D:\ORA\ICITY\DA TA2.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB228KR107N_2120_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB228KR107N_2120_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:08通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00001 的恢复目标: D:\ORA\SYS\SYSTEM01.DBF数据文件00005 的恢复目标: D:\ORA\ICITY\DA TA1.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22DKR3KJQ_2125_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22DKR3KJQ_2125_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:03通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00004 的恢复目标: D:\ORA\SYS\USERS01.DBF数据文件00007 的恢复目标: D:\ORA\ICITY\DA TA3.DBF数据文件00008 的恢复目标: D:\ORA\RMANFILE\DBACKUPFILE.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22EKR3KJQ_2126_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22EKR3KJQ_2126_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:01通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00002 的恢复目标: D:\ORA\SYS\UNDOTBS01.DBF数据文件00003 的恢复目标: D:\ORA\SYS\SYSAUX01.DBF数据文件00006 的恢复目标: D:\ORA\ICITY\DA TA2.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22CKR3KJQ_2124_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22CKR3KJQ_2124_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:15通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00001 的恢复目标: D:\ORA\SYS\SYSTEM01.DBF数据文件00005 的恢复目标: D:\ORA\ICITY\DA TA1.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22HKR68VP_2129_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22HKR68VP_2129_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:03通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00007 的恢复目标: D:\ORA\ICITY\DA TA3.DBF数据文件00008 的恢复目标: D:\ORA\RMANFILE\DBACKUPFILE.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22IKR68VQ_2130_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22IKR68VQ_2130_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:01通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00002 的恢复目标: D:\ORA\SYS\UNDOTBS01.DBF数据文件00003 的恢复目标: D:\ORA\SYS\SYSAUX01.DBF数据文件00006 的恢复目标: D:\ORA\ICITY\DA TA2.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22GKR68VP_2128_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22GKR68VP_2128_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:15通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00001 的恢复目标: D:\ORA\SYS\SYSTEM01.DBF数据文件00005 的恢复目标: D:\ORA\ICITY\DA TA1.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22LKR8TBQ_2133_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22LKR8TBQ_2133_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:03通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00004 的恢复目标: D:\ORA\SYS\USERS01.DBF数据文件00007 的恢复目标: D:\ORA\ICITY\DA TA3.DBF数据文件00008 的恢复目标: D:\ORA\RMANFILE\DBACKUPFILE.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22MKR8TBQ_2134_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22MKR8TBQ_2134_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:01通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00002 的恢复目标: D:\ORA\SYS\UNDOTBS01.DBF数据文件00003 的恢复目标: D:\ORA\SYS\SYSAUX01.DBF数据文件00006 的恢复目标: D:\ORA\ICITY\DA TA2.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22KKR8TBQ_2132_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22KKR8TBQ_2132_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:15通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00005 的恢复目标: D:\ORA\ICITY\DA TA1.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22PKRBHNQ_2137_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22PKRBHNQ_2137_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:03通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00004 的恢复目标: D:\ORA\SYS\USERS01.DBF数据文件00007 的恢复目标: D:\ORA\ICITY\DA TA3.DBF数据文件00008 的恢复目标: D:\ORA\RMANFILE\DBACKUPFILE.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22QKRBHNQ_2138_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22QKRBHNQ_2138_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:01通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00002 的恢复目标: D:\ORA\SYS\UNDOTBS01.DBF数据文件00003 的恢复目标: D:\ORA\SYS\SYSAUX01.DBF数据文件00006 的恢复目标: D:\ORA\ICITY\DA TA2.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22OKRBHNQ_2136_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22OKRBHNQ_2136_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:15通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00001 的恢复目标: D:\ORA\SYS\SYSTEM01.DBF数据文件00005 的恢复目标: D:\ORA\ICITY\DA TA1.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22TKRE63Q_2141_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22TKRE63Q_2141_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:03通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00004 的恢复目标: D:\ORA\SYS\USERS01.DBF数据文件00007 的恢复目标: D:\ORA\ICITY\DA TA3.DBF数据文件00008 的恢复目标: D:\ORA\RMANFILE\DBACKUPFILE.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22UKRE63Q_2142_1 通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22UKRE63Q_2142_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:01通道ORA_DISK_1: 正在开始恢复增量数据文件备份集通道ORA_DISK_1: 正在指定从备份集恢复的数据文件数据文件00002 的恢复目标: D:\ORA\SYS\UNDOTBS01.DBF数据文件00006 的恢复目标: D:\ORA\ICITY\DA TA2.DBF通道ORA_DISK_1: 正在读取备份段E:\ORA\RMANBAK\DB22SKRE63Q_2140_1通道ORA_DISK_1: 已恢复备份段1段句柄= E:\ORA\RMANBAK\DB22SKRE63Q_2140_1 标记= DB2通道ORA_DISK_1: 恢复完成, 用时: 00:00:15正在开始介质的恢复无法找到存档日志存档日志线程=1 序列=1169RMAN-03002: recover 命令(在10/12/2009 16:47:26 上) 失败RMAN-06054: 介质恢复正请求未知的日志: 线程1 seq 1169 lowscn 36496613把归档日志D:\ora\archivelog\1169_1_658946615.LOG放到归档目录后RMAN> recover database;启动recover 于12-10月-09使用通道ORA_DISK_1正在开始介质的恢复存档日志文件名=D:\ORA\ARCHIVELOG\1169_1_658946615.LOG 线程=1 序列=1169 存档日志文件名=D:\ORA\ARCHIVELOG\1169_1_658946615.LOG 线程=1 序列=1170 RMAN-03002: recover 命令(在10/12/2009 17:05:38 上) 失败RMAN-11003: 在分析/执行SQL 语句期间失败: alter database recover logfile 'D:\ORA\ARCHIVELOG\1169_1_658946615.LOG'ORA-00310: 归档日志包含序列1169; 要求序列1170ORA-00334: 归档日志: 'D:\ORA\ARCHIVELOG\1169_1_658946615.LOG'RMAN> alter database open resetlogs;数据库已打开3.附加说明在恢复过程中用到rman自动备份的spfile和控制文件,在此给出修改rman自动备份控目前还没有找到用RMAN自动备份归档日志的方法。

RMAN的备份与恢复步骤详解

RMAN的备份与恢复步骤详解

在这里没有讨论多么深入的RMAN技术,也没有告诉大家这样去编写备份脚本,这并不是我的初衷,我只想把我会的写出来,和大家一起学习,一起进步,谢谢。

1、切换服务器归档模式,如果已经是归档模式可跳过此步:%sqlplus /nolog (启动sqlplus)SQL> conn / as sysdba (以DBA身份连接数据库)SQL> shutdown immediate; (立即关闭数据库)SQL> startup mount (启动实例并加载数据库,但不打开) SQL> alter database archivelog; (更改数据库为归档模式) SQL> alter database open; (打开数据库)SQL> alter system archive log start; (启用自动归档) SQL> exit (退出)2、连接:%rman target=rman/rman@mydb (启动恢复管理器)3、基本设置:RMAN> configure default device type to disk; (设置默认的备份设备为磁盘)RMAN> configure device type disk parallelism 2; (设置备份的并行级别,通道数)RMAN> configure channel 1 device type disk fromat '/backup1/backup_%U'; (设置备份的文件格式,只适用于磁盘设备)RMAN> configure channel 2 device type disk fromat '/backup2/backup_%U'; (设置备份的文件格式,只适用于磁盘设备)RMAN> configure control on; (打开控制文件与服务器参数文件的自动备份)RMAN> configure control format for device type disk to '/backup1/ctl_%F'; (设置控制文件与服务器参数文件自动备份的文件格式)4、查看所有设置:RMAN> show all5、查看数据库方案报表:RMAN> report schema;6、备份全库:RMAN> backup database plus archivelog delete input; (备份全库及控制文件、服务器参数文件与所有归档的重做日志,并删除旧的归档日志)7、备份表空间:RMAN> backup tablespace system plus archivelog delete input; (备份指定表空间及归档的重做日志,并删除旧的归档日志)8、备份归档日志:RMAN> backup archivelog all delete input;9、复制数据文件:RMAN> copy datafile 1 to '/oracle/dbs/system.copy';10、查看备份和文件复本:RMAN> list backup;11、验证备份:RMAN> validate backupset 3;12、从自动备份中恢复服务器参数文件:RMAN> shutdown immediate; (立即关闭数据库) RMAN> startup nomount; (启动实例)RMAN> restore sp pfile '/backup1/mydb.ora' from autobackup; (从自动备份中恢复服务器参数文件)13、从自动备份中恢复控制文件:RMAN> shutdown immediate; (立即关闭数据库) RMAN> startup nomount; (启动实例)RMAN> restore control '/backup1' from autobackup; (从自动备份中恢复控制文件)13、恢复和复原全数据库:RMAN> shutdown immediate; (立即关闭数据库) RMAN> exit (退出)%mv /oracle/dbs/tbs_12.f /oracle/dbs/tbs_12.bak (将数据文件重命名)%mv /oracle/dbs/tbs_13.f /oracle/dbs/tbs_13.bak (将数据文件重命名)%mv /oracle/dbs/tbs_14.f /oracle/dbs/tbs_14.bak (将数据文件重命名)%mv /oracle/dbs/tbs_15.f /oracle/dbs/tbs_15.bak (将数据文件重命名)%rman target=rman/rman@mydb (启动恢复管理器) RMAN> startup p (指定初始化参数文件启动数据库) RMAN> restore database; (还原数据库) RMAN> recover database; (恢复数据库)RMAN> alter database open; (打开数据库)14、恢复和复原表空间:RMAN> sql 'alter tablespace users offline immediate'; (将表空间脱机)RMAN> exit (退出恢复管理器)%mv /oracle/dbs/users01.dbf /oracle/dbs/users01.bak (将表空间重命名)%rman target=rman/rman@mydb (启动恢复管理器) RMAN> restore tablespace users; (还原表空间) RMAN> recover tablespace users; (恢复表空间) RMAN> sql 'alter tablespace users online'; (将表空间联机)15、增量备份与恢复:第一天的增量基本备份:RMAN> backup incremental level=0 database plus archivelog delete input;第二天的增量差异备份:RMAN> backup incremental level=2 database plus archivelog delete input;第三天的增量差异备份:RMAN> backup incremental level=2 database plus archivelog delete input;第四天的增量差异备份:RMAN> backup incremental level=1 database plus archivelog delete input;第五天的增量差异备份:RMAN> backup incremental level=2 database plus archivelog delete input;第六天的增量差异备份:RMAN> backup incremental level=2 database plus archivelog delete input;第七天的增量差异备份:RMAN> backup incremental level=0 database plusarchivelog delete input;增量恢复:RMAN> shutdown immediate;RMAN> exit%mv /oracle/dbs/tbs_12.f /oracle/dbs/tbs_12.bak%mv /oracle/dbs/tbs_13.f /oracle/dbs/tbs_13.bak%mv /oracle/dbs/tbs_14.f /oracle/dbs/tbs_14.bak%mv /oracle/dbs/tbs_15.f /oracle/dbs/tbs_15.bak%rman target=rman/rman@mydbRMAN> startup pRMAN> restore database;RMAN> recover database;RMAN> alter database open。

路径不一致单实例Rman恢复步骤

路径不一致单实例Rman恢复步骤

1.讲目标数据库启动到nomount状态,SQL> startup nomount;ORACLE instance started.Total System Global Area 1241513984 bytesFixed Size 2065376 bytesVariable Size 318770208 bytesDatabase Buffers 905969664 bytesRedo Buffers 14708736 bytesSQL>2.恢复控制文件,进入ramn target/restore controlfile from 'E:\RMANBACK\CTL_ORCL_20140729_6'3.讲数据库启动到mount状态RMAN> alter database mount;database mountedreleased channel: ORA_DISK_1RMAN>更改rman路径catalog backuppiece 'E:\RMANBACK\DBFULL_ORCL_01PEK20S_1_1.BAK';catalog backuppiece 'E:\RMANBACK\DBFULL_ORCL_02PEK20S_1_2.BAK';catalog backuppiece 'E:\RMANBACK\DBFULL_ORCL_03PEK20V_1_3.BAK';catalog backuppiece 'E:\RMANBACK\DBFULL_ORCL_04PEK225_1_4.BAK';catalog backuppiece 'E:\RMANBACK\DBFULL_ORCL_05PEK226_1_5.BAK';4.在主库上执行sqlselect 'set newname for datafile '||''||''''||file_Name||''''||''||' to '||''''|| 'E:\oracle\product\10.2.0\oradata\orcl\' ||replace(file_Name,'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\','')||''''||';' from dba_data_files order by file_id--把查询出来的结果替换下面脚本里面的内容,然后再rman target/ 执行run{allocate channel c1 type disk;allocate channel c2 type disk;allocate channel c3 type disk;set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\SYSTEM01.DBF'; set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\UNDOTBS01.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\SYSAUX01.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\USERS01.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZLTOOLSTBS.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZLTOOLSTBS.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9BASEITEM.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9BASEITEM.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9PATIENT.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9PATIENT.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9EXPENSE.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9EXPENSE.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9MEDLST.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9MEDLST.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9DUEREC.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9DUEREC.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9CISREC.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9CISREC.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9EPRLOB.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9EPRLOB.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9EPRDA T.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9EPRDA T.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9CISAUDIT.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9CISAUDIT.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXHIS.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXHIS.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXCIS.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXCIS.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZLBAKZLHIS.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZLBAKZLHIS.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9IFTBASE.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9IFTBASE.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9IFTREC.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9IFTREC.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXIFT.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXIFT.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9DEVBASE.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9DEVBASE.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9DEVREC.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9DEVREC.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9DEVUSE.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9DEVUSE.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXDEV.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXDEV.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9MTLBASE.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9MTLBASE.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9MTLREC.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9MTLREC.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXMTL.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXMTL.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9MEDBASE.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9MEDBASE.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9MEDREC.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9MEDREC.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9MEDDAY.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9MEDDAY.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXMDR.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXMDR.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9PEISDATA.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9PEISDATA.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9WIZARDDATA.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9WIZARDDA TA.DBF'; set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXPSS.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXPSS.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9LISDATA.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9LISDATA.DBF';set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXLIS.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXLIS.DBF'; release channel c1;release channel c2;release channel c3;restore database;switch datafile all;}--5.sql下执行,主库查询select * from V$logfilealter database rename file 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG' to 'E:\oracle\product\10.2.0\oradata\orcl\REDO01.LOG';alter database rename file 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG' to 'E:\oracle\product\10.2.0\oradata\orcl\REDO02.LOG'; alter database rename file 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG' to 'E:\oracle\product\10.2.0\oradata\orcl\REDO03.LOG';--6.重新创建控制文件--sql下执行,生成控制文件脚本alter database backup controlfile to trace as 'd:\cont.trc';--数据库启动到mount状态下执行:CREATE CONTROLFILE REUSE DA TABASE "ORCL" RESETLOGS ARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 292LOGFILEGROUP 1 'E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\REDO01.LOG' SIZE 50M,GROUP 2 'E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\REDO02.LOG' SIZE 50M,GROUP 3 'E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\REDO03.LOG' SIZE 50M-- STANDBY LOGFILEDA TAFILE'E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\SYSTEM01.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\UNDOTBS01.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\SYSAUX01.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\USERS01.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\ZLTOOLSTBS.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\ZL9BASEITEM.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\ZL9PATIENT.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\ZL9EXPENSE.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\ZL9MEDLST.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\ZL9DUEREC.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\ZL9CISREC.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\ZL9EPRLOB.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\ZL9EPRDAT.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\ZL9CISAUDIT.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\ZL9INDEXHIS.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\ZL9INDEXCIS.DBF','E:\ORACLE\PRODUCT\10.2.0\ORADA TA\ORCL\ZLBAKZLHIS.DBF'CHARACTER SET ZHS16GBK;7.注册归档日志文件路径,mount状态下ramn target/catalog start with 'E:\ARCHIVE'8.截止恢复,mount状态下ramn target/recover database9.启动数据库alter database open resetlogs;10.增加临时表空间数据文件alter tablespace temp add tempfile 'E:\oracle\product\10.2.0\oradata\orcl\temp02.dbf' size 2048M;alter tablespace ZLTOOLSTMP add tempfile 'E:\oracle\product\10.2.0\oradata\orcl\zltooltemp01.dbf' size 2048M;来源:网络编辑:联动北方技术论坛。

RMAN 备份异机恢复 并创建新DBID解析

RMAN 备份异机恢复 并创建新DBID解析

RMAN 备份异机恢复并创建新DBID分类:Oracle Backup & Recovery Oracle RMAN 2011-03-11 19:05 5532人阅读评论(1) 收藏举报测试平台信息:Oracle:11gR2操作系统:Redhat 5.5Target DB:dave几点说明:(1)RMAN 异机恢复的时候,db_name必须相同。

如果说要想改成其他的实例名,可以在恢复成功后,用nid 命令修改。

实例名的信息会记录到控制文件里,所以如果在恢复的时候,如果实例名不一致,恢复的时候会报错。

(2)如果恢复的路径和源库不一致,就需要在restore时用set 命令指定新位置。

并且使用switch datafile all将信息更新的到控制文件。

在做duplicate的时候,RMAN 会自动根据pfile中的log_file_name_convert和db_file_name_convert来进行set 的转换。

手工restore时,只能只只能使用set 命令。

(3)异机恢复对相同目录和不同目录都做了说明。

(4)最后测试了NID 修改DBID 和DBNAME.一. Target 库准备工作:1. 查询DBIDSQL> select name,dbid from v$database;NAME DBID--------- ----------DAVE 8082342862. 备份DB关于RMAN 的shell 备份脚本,参考:Nocatalog 下的RMAN 增量备份 shell脚本/tianlesoftware/archive/2011/01/26/6164931.aspx在这里我用0级和1级备份了下DB。

[oracle@qs-dmm-rh1 backup]$ lsarch_0pm6qt8q_1_1_20110309 dave_lev0_0jm6qt77_1_1_20110309dave_lev1_0um6qtcq_1_1_20110309arch_0qm6qt8q_1_1_20110309 dave_lev0_0km6qt77_1_1_20110309dave_lev1_0vm6qtcq_1_1_20110309arch_13m6qtda_1_1_20110309 dave_lev0_0lm6qt77_1_1_20110309dave_lev1_11m6qtd7_1_1_20110309arch_14m6qtda_1_1_20110309 dave_lev0_0nm6qt7c_1_1_20110309dave_spfile_16m6qtde_1_1_20110309ctl_file_15m6qtdc_1_1_20110309 dave_lev1_0tm6qtcq_1_1_20110309二. Auxiliary库准备工作:1. 创建口令文件[oracle@qs-dmm-rh2 trace]$ orapwd file=?/dbs/orapwdave password=oracle2. 创建相关的目录[oracle@qs-dmm-rh2 u01]$ mkdir oradata[oracle@qs-dmm-rh2 oradata]$ pwd/u01/oradata3. 创建初始化参数将Target 库的pfile 文件copy过来。

rman异机恢复

rman异机恢复

rman异机恢复1、了解目标服务器与源服务器的操作系统版本信息如果是正式环境的迁移,那么最好关注一下,避免一些问题。

例如,有些版本的操作系统对不是官方认证的,如果在迁移前不关注这些,那么迁移后,有可能出现一些意想不到的问题。

# uname -aLinux oracle12c2 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux# more /etc/redhat-releaseCentOS Linux release 7.3.1611 (Core)2、在目标服务器上安装数据库在目标服务器上安装与源服务器相同版本的数据库,并且采用相同的安装路径。

(只安装数据库软件,不需创建实例)3、将RMAN备份文件和归档日志文件拷贝的相关目录将RMAN备份文件拷贝到和源服务器路径相同的目标服务器上,路径一般为/home/orabak,并给目录进行授权.chown -R oracle:oinstall /home/orabak/chmod -R 755 /home/orabak4、还原参数文件spfile(1)创建启动文件su - oraclecd /home/app/oracle/product/12.2.0/dbhome_1/dbs/touch init.oravi init.oradb_name='ora' #在文件里面添加参数名,db_name为数据库名称(2)使用下列语句将数据库启动到nomount模式sql > startup nomount force;(3)设置DBIDrman target /RMAN>set DBID=1589493431;dbid可通过在主库中select dbid from v$database查看,当主服务器损坏时无法启动主数据库时,可通过在RMAN备份文件名中找到(前提是文件备份格式带了%F 即一个基于DBID唯一的名称)如下图所示:RMAN>restore spfile from'/home/orabak/ora_lev1_201803212300_rman_c-1589493431 -20180321-06';5、还原控制文件(control file)RMAN>restore controlfile from'/home/orabak/ora_lev1_201803212300_rman_c-1589493431 -20180321-06';6、启动数据库到mount状态RMAN>alter database mount;7、检查数据库备份有效性RMAN>crosscheck backup;8、恢复预览RMAN>restore database preview summary;9、Restore databaserman>restore database;10、recover databaserman>recover database;报错处理:RMAN-03002: failure of recover command at 04/17/2018 16:12:38RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 33 and starting SCN of 3269512还原数据库到某一SCN值rman>recover database until scn 3269512;或还原数据库到某一时间点,时间点需要早于数据库宕机前。

oracle备份如何到异机还原

oracle备份如何到异机还原

oracle备份如何到异机还原作者:ocpyang情景描述:有朋友问,MSSQLSERVER将数据库备份还原到其它机器很方便,基本就是傻瓜式操作,oracle有控制文件、参数文件一堆东西,觉得还原很复杂;其实不然,我抽出了点时间,简单演示下案例,朋友们,参考下!为了简单快速,我才用RMAN备份和还原--说明:(1).RMAN备份到异机恢复的时候,db_name需要相同。

如果说要想改成其他的实例名,可以在恢复成功后,用nid命令修改。

实例名的信息会记录到控制文件里,所以如果在恢复的时候,如果实例名不一致,恢复的时候会报错。

(2).恢复的路径和源库不一致时,就需要在restore命令中使用set 命令指定新位置,并且使用switch datafile all将变更信息更新的到控制文件中。

测试环境:源数据库服务器A,安装在E,备份目录已在E盘;源数据库服务器B,安装在F盘.------------------------------------一、源数据库准备工作--------------------------------------1. 查询DBIDSQL> select name,dbid from v$database;NAME DBID--------- ----------ORCL 1320546556--2. 备份源数据DBrun {configure retention policy to recovery window of 14 days;configure controlfileautobackup on; --自动开启控制文件备份configure controlfileautobackup format for device type disk to'E:\backup\controlfile\bak_%F';allocate channel c1 device type disk format 'E:\backup\data\bak_%u'; allocate channel c2 device type disk format 'E:\backup\data\bak_%u'; sql 'alter system archive log current';backup incremental level=0 database skip inaccessibleplus archivelogfilesperset 20delete all input;release channel c1;release channel c2;}allocate channel for maintenance device type disk;crosscheck backupset;delete noprompt obsolete;--或run {configure retention policy to recovery window of 14 days;allocate channel c1 device type disk format 'E:\backup\data\bak_%u'; allocate channel c2 device type disk format 'E:\backup\data\bak_%u'; sql 'alter system archive log current';backup incremental level=0 database skip inaccessibleplus archivelogfilesperset 20delete all input;--手动直接指明备份文件名和路径backup current controlfile tag='bak_ctrollfile'format='E:\backup\controlfile\bak_ctl_file_%U_%T';backup spfile tag='bak_spfile' format='E:\backup\controlfile\bak_spfile_%U_%T'; release channel c1;release channel c2;}allocate channel for maintenance device type disk;crosscheck backupset;delete noprompt obsolete;--3.手动备份spfilecreatepfile='E:\backup\inittest.ora' from spfile;------------------------------------二、目标库准备工作:---------------------------------------步骤1. 创建口令文件--如果有就不需要新建.orapwd file=F:\app\Administrator\product\11.2.0\dbhome_1\database\PWDorcl.ora password=password--步骤2.恢复参数文件--方法1.源数据库spfile并拷贝到B数据库服务器\\192.168.2.25\e$\backup\inittest.ORA复制到E:\bk\inittest.ORA--步骤3.编辑参数文件中的文件路径如路径和原来一样,则不需修改eg:- *_DUMP_DEST- LOG_ARCHIVE_DEST*- CONTROL_FILES---实例:orcl.__db_cache_size=939524096orcl.__java_pool_size=16777216orcl.__large_pool_size=16777216orcl.__oracle_base='F:\app\Administrator'#修改路径orcl.__pga_aggregate_target=855638016orcl.__sga_target=2550136832orcl.__shared_io_pool_size=0orcl.__shared_pool_size=1526726656orcl.__streams_pool_size=16777216*.audit_file_dest='F:\app\Administrator\admin\orcl\adump' #修改路径*.audit_trail='db'*.compatible='11.2.0.0.0'#修改路径*.control_files='F:\app\Administrator\oradata\orcl\control01.ctl','F:\app\Administrator\orada ta\orcl\control02.ctl','F:\app\Administrator\oradata\orcl\control03.ctl'*.db_block_size=8192*.db_domain=''*.db_name='orcl'*.db_recovery_file_dest='F:\arch' #修改路径*.db_recovery_file_dest_size=6442450944*.diagnostic_dest='F:\app\Administrator' #修改路径*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'*.log_archive_dest_1='location=f:\arch' #修改路径*.nls_date_format='yyyy-mm-ddhh:mi:ss'*.open_cursors=300*.optimizer_capture_sql_plan_baselines=TRUE*.pga_aggregate_target=845152256*.processes=150*.remote_login_passwordfile='EXCLUSIVE'*.sga_target=2536505344*.skip_unusable_indexes=TRUE*.undo_tablespace='UNDOTBS1'--步骤4.重启实例,使用已编辑好的参数文件将用pfile将B数据库服务器启动到nomout状态rman target /startupnomountpfile='e:\bk\inittest.ora'--步骤5.恢复控制文件,装载数据库rman target /setdbid 1320546556restorecontrolfile from 'e:\bk\controlfile\BAK_CTL_FILE_6LO6SON4_1_1_20130412';启动restore 于2013-04-11 13:58:58使用目标数据库控制文件替代恢复目录分配的通道: ORA_DISK_1通道ORA_DISK_1: SID=129 设备类型=DISK通道ORA_DISK_1: 正在还原控制文件通道ORA_DISK_1: 还原完成, 用时: 00:00:01输出文件名=F:\APP\ADMINISTRATOR\ORADATA\ORCL\CONTROL01.CTL输出文件名=F:\APP\ADMINISTRATOR\ORADATA\ORCL\CONTROL02.CTL输出文件名=F:\APP\ADMINISTRATOR\ORADATA\ORCL\CONTROL03.CTL完成restore 于2013-04-11 13:59:00--步骤6.将DB启动到mout状态alter database mount;数据库已装载释放的通道: ORA_DISK_1--加载备份目录CATALOG START WITH 'E:\bk';搜索与样式E:\bk 匹配的所有文件数据库未知文件的列表====================================文件名: E:\bk\controlfile\BAK_C-1320546556-20130411-03文件名: E:\bk\controlfile\BAK_CTL_FILE_65O6QILO_1_1_20130411 文件名: E:\bk\controlfile\BAK_SPFILE_66O6QILQ_1_1_20130411文件名: E:\bk\data\BAK_60O6QIGV文件名: E:\bk\data\BAK_61O6QIGV文件名: E:\bk\data\BAK_62O6QIH1文件名: E:\bk\data\BAK_63O6QIH1文件名: E:\bk\data\BAK_64O6QILM是否确实要将上述文件列入目录(输入YES 或NO)? yes正在编制文件目录...目录编制完毕已列入目录的文件的列表======================文件名: E:\bk\controlfile\BAK_C-1320546556-20130411-03文件名: E:\bk\controlfile\BAK_CTL_FILE_65O6QILO_1_1_20130411 文件名: E:\bk\controlfile\BAK_SPFILE_66O6QILQ_1_1_20130411文件名: E:\bk\data\BAK_60O6QIGV文件名: E:\bk\data\BAK_61O6QIGV文件名: E:\bk\data\BAK_62O6QIH1文件名: E:\bk\data\BAK_63O6QIH1文件名: E:\bk\data\BAK_64O6QILM--步骤7.restore 数据库7.1 恢复目录不同的情况:到Target 库查询一下:SQL> select trim(file_id),trim(file_name) from dba_data_files ORDER BY FILE_ID ASC;1 E:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF2 E:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF3 E:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF4 E:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF6 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY02.DBF7 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY03.DBF8 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY04.DBF9 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY05.DBF11 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY06.DBF12 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY07.DBF13 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY08.DBF14 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY09.DBF15 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY10.DBF16 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY01.DBF17 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY11.DBF18 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY12.DBF19 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY13.DBF20 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY14.DBF21 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY15.DBF22 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY16.DBF23 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY17.DBF24 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY18.DBF25 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY19.DBF26 E:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY20.DBFSQL>select trim(file_id),trim(file_name) from dba_temp_files;1 E:\APP\ADMINISTRATOR\ORADATA\ORCL\TEMP01.DBFselect 'SET NEWNAME FOR DATAFILE'|| ' '||file_id||' '||'TO'|| ' '||''''||trim(file_name)||'''' ||';' from dba_data_files ORDER BY FILE_ID ASC;---如下实例:RUN{# rename the datafilesSET NEWNAME FOR DATAFILE 1 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF'; SET NEWNAME FOR DATAFILE 2 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF'; SET NEWNAME FOR DATAFILE 3 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF'; SET NEWNAME FOR DATAFILE 4 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF'; SET NEWNAME FOR DATAFILE 6 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY02.DBF'; SET NEWNAME FOR DATAFILE 7 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY03.DBF'; SET NEWNAME FOR DATAFILE 8 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY04.DBF'; SET NEWNAME FOR DATAFILE 9 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY05.DBF'; SET NEWNAME FOR DATAFILE 11 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY06.DBF'; SET NEWNAME FOR DATAFILE 12 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY07.DBF'; SET NEWNAME FOR DATAFILE 13 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY08.DBF'; SET NEWNAME FOR DATAFILE 14 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY09.DBF'; SET NEWNAME FOR DATAFILE 15 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY10.DBF'; SET NEWNAME FOR DATAFILE 16 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY01.DBF'; SET NEWNAME FOR DATAFILE 17 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY11.DBF';SET NEWNAME FOR DATAFILE 18 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY12.DBF';SET NEWNAME FOR DATAFILE 19 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY13.DBF';SET NEWNAME FOR DATAFILE 20 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY14.DBF';SET NEWNAME FOR DATAFILE 21 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY15.DBF';SET NEWNAME FOR DATAFILE 22 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY16.DBF';SET NEWNAME FOR DATAFILE 23 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY17.DBF';SET NEWNAME FOR DATAFILE 24 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY18.DBF';SET NEWNAME FOR DATAFILE 25 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY19.DBF';SET NEWNAME FOR DATAFILE 26 TO'F:\APP\ADMINISTRATOR\ORADATA\ORCL\VPAY20.DBF';SQL "ALTER DATABASE RENAME FILE''E:\app\Administrator\oradata\orcl\REDO01.LOG''TO ''F:\app\Administrator\oradata\orcl\REDO01.LOG'' ";SQL "ALTER DATABASE RENAME FILE''E:\app\Administrator\oradata\orcl\REDO02.LOG''TO ''F:\app\Administrator\oradata\orcl\REDO02.LOG'' ";SQL "ALTER DATABASE RENAME FILE''E:\app\Administrator\oradata\orcl\REDO03.LOG''TO ''F:\app\Administrator\oradata\orcl\REDO03.LOG'' ";RESTORE DATABASE;SWITCH DATAFILE ALL;}对switch datafile all的说明:--对于nocatalog模式下,rman备份的信息是保存在控制文件里的,包括文件的路径信息。

oracle-RMAN异机恢复

oracle-RMAN异机恢复

oracle-RMAN异机恢复Step1:设置环境变量[oracle@ehrprod ~]$ export ORACLE_SID=szuat01Step 2:恢复参数文件[oracle@ehrprod ~]$ rman target /Recovery Manager: Release 10.2.0.4.0 - Production on Thu Mar 10 15:01:36 2011Copyright (c) 1982, 2007, Oracle. All rights reserved.connected to target database (not started)RMAN> set dbid 2805194251;executing command: SET DBIDRMAN> restore spfile to pfile'/u01/oracle/product/10.2.0.1/dbs/initszuat01.ora' from'/backup/szuat01/rman/backupset/SZUAT01_df0_20110303_95_1_744768707';Starting restore at 10-MAR-11using target database control file instead of recovery catalog allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=36 devtype=DISKchannel ORA_DISK_1: autobackup found:/backup/szuat01/rman/backupset/SZUAT01_df0_20110303_95_1_7447 68707channel ORA_DISK_1: SPFILE restore from autobackup complete Finished restore at 10-MAR-11Step3:根据initSID.ora文件创建目录,同时也可以根据需要修改initSID.ora里面的参数Step 4:用参数文件启动DB到nomountRMAN> startup force nomountpfile='/u01/oracle/product/10.2.0.1/dbs/initszuat01.ora';Oracle instance startedTotal System Global Area 2147483648 bytesFixed Size 1268508 bytesVariable Size 570426596 bytesDatabase Buffers 1560281088 bytesRedo Buffers 15507456 bytesStep 5:恢复控制文件:RMAN> restore controlfile from'/backup/szuat01/rman/backupset/SZUAT01_df0_20110303_95_1_7447 68707';Starting restore at 10-MAR-11allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=156 devtype=DISKchannel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:02 output filename=/u01/oracle/szuat01/control01.ctloutput filename=/u01/oracle/szuat01/control02.ctloutput filename=/u02/oracle/szuat01/control03.ctlFinished restore at 10-MAR-11Step 6:恢复Datafile文件。

将10g RAC库用rman 的方式备份并恢复到异机_百度文库

将10g RAC库用rman 的方式备份并恢复到异机_百度文库

将 10g RAC库用 rman 的方式备份并恢复到异机 -- 刚试验通过与大家分享主 RAC 库:2个节点 rac1(192.168.218.168,rac2(192.168.218.168 采用ASM+RAW备机 standby(192.168.218.188 文件系统一。

在 rac 库备份:rac1-> crs_stat -tName Type Target State Host------------------------------------------------------------ora....SM1.asm application ONLINE ONLINE rac1ora....C1.lsnr application ONLINE ONLINE rac1ora.rac1.gsd application ONLINE ONLINE rac1ora.rac1.ons application ONLINE ONLINE rac1ora.rac1.vip application ONLINE ONLINE rac1ora....SM2.asm application ONLINE ONLINE rac2ora....C2.lsnr application ONLINE ONLINE rac2ora.rac2.gsd application ONLINE ONLINE rac2ora.rac2.ons application ONLINE ONLINE rac2ora.rac2.vip application ONLINE ONLINE rac2ora.racdb.db application ONLINE ONLINE rac1ora....b1.inst application ONLINE ONLINE rac1ora....b2.inst application ONLINE ONLINE rac2rac1->rac1-> export ORACLE_SID=racdb1rac1-> rman target / nocatalogRMAN> run{2> allocate CHANNEL ch00 type DISK CONNECT 'sys/oracle@racdb1';3> allocate CHANNEL ch01 type DISK CONNECT 'sys/oracle@racdb2';4> backup database format '/rmanset/racdb_full_%d%t%s%p' tag 'fullbackup'; 5> BACKUP FORMAT '/rmanset/%d_arch_%s_%p_%h' ARCHIVELOG ALL;6> backup format '/rmanset/cf_%d_%s_%p'7> (current controlfile;8> RELEASE CHANNEL ch00;9> RELEASE CHANNEL ch01;10> }allocated channel: ch00channel ch00: sid=148 instance=racdb1 devtype=DISKallocated channel: ch01channel ch01: sid=148 instance=racdb2 devtype=DISKStarting backup at 02-NOV-08channel ch00: starting full datafile backupsetchannel ch00: specifying datafile(s in backupsetinput datafile fno=00001 name=+RACDATA/racdb/datafile/system.259.669487425 input datafile fno=00005 name=+RACDATA/racdb/datafile/users.264.669487561input datafile fno=00004name=+RACDATA/racdb/datafile/undotbs2.263.669487539 channel ch00: starting piece 1 at 02-NOV-08channel ch01: starting full datafile backupsetchannel ch01: specifying datafile(s in backupsetinput datafile fno=00003 name=+RACDATA/racdb/datafile/sysaux.261.669487497input datafile fno=00002name=+RACDATA/racdb/datafile/undotbs1.260.669487479 channel ch01: starting piece 1 at 02-NOV-08channel ch00: finished piece 1 at 02-NOV-08piece handle=/rmanset/racdb_full_RACDB669769770931 tag=FULLBACKUP comment=NONEchannel ch00: backup set complete, elapsed time: 00:02:19channel ch00: starting full datafile backupsetchannel ch00: specifying datafile(s in backupsetincluding current control file in backupsetchannel ch00: starting piece 1 at 02-NOV-08channel ch01: finished piece 1 at 02-NOV-08piece handle=/rmanset/racdb_full_RACDB669769784941 tag=FULLBACKUP comment=NONEchannel ch01: backup set complete, elapsed time: 00:02:28channel ch01: starting full datafile backupsetchannel ch01: specifying datafile(s in backupsetincluding current SPFILE in backupsetchannel ch01: starting piece 1 at 02-NOV-08channel ch00: finished piece 1 at 02-NOV-08piece handle=/rmanset/racdb_full_RACDB669769914951 tag=FULLBACKUP comment=NONEchannel ch00: backup set complete, elapsed time: 00:00:11channel ch01: finished piece 1 at 02-NOV-08piece handle=/rmanset/racdb_full_RACDB669769933961 tag=FULLBACKUP comment=NONEchannel ch01: backup set complete, elapsed time: 00:00:05Finished backup at 02-NOV-08Starting backup at 02-NOV-08current log archivedchannel ch00: starting archive log backupsetchannel ch00: specifying archive log(s in backup setinput archive log thread=1 sequence=42 recid=141 stamp=669603048 input archive log thread=1 sequence=44 recid=149 stamp=669640424 input archive log thread=1 sequence=45 recid=151 stamp=669675778 input archive log thread=1 sequence=46 recid=152 stamp=669679426 input archive log thread=1 sequence=47 recid=156 stamp=669690456 channel ch00: starting piece 1 at 02-NOV-08channel ch01: starting archive log backupsetchannel ch01: specifying archive log(s in backup setinput archive log thread=1 sequence=53 recid=170 stamp=669767346 input archive log thread=1 sequence=54 recid=172 stamp=669769357 input archive log thread=2 sequence=44 recid=165 stamp=669764276 input archive log thread=2 sequence=45 recid=167 stamp=669765472 input archive log thread=2 sequence=46 recid=168 stamp=669765474 input archive log thread=2 sequence=47 recid=169 stamp=669767345 input archive log thread=2 sequence=48 recid=171 stamp=669769352 input archive log thread=2 sequence=49 recid=175 stamp=669769944channel ch01: starting piece 1 at 02-NOV-08channel ch01: finished piece 1 at 02-NOV-08piece handle=/rmanset/RACDB_arch_98_1_2 tag=TAG20081102T231211 comment=NONE channel ch01: backup set complete, elapsed time: 00:00:04channel ch00: finished piece 1 at 02-NOV-08piece handle=/rmanset/RACDB_arch_97_1_1 tag=TAG20081102T231211 comment=NONE channel ch00: backup set complete, elapsed time: 00:00:11channel ch00: starting archive log backupsetchannel ch00: specifying archive log(s in backup setinput archive log thread=1 sequence=48 recid=158 stamp=669690550input archive log thread=1 sequence=49 recid=160 stamp=669691146input archive log thread=1 sequence=50 recid=162 stamp=669755973input archive log thread=1 sequence=51 recid=163 stamp=669757116input archive log thread=1 sequence=52 recid=166 stamp=669764278input archive log thread=1 sequence=55 recid=173 stamp=669769375input archive log thread=1 sequence=56 recid=174 stamp=669769928channel ch00: starting piece 1 at 02-NOV-08channel ch00: finished piece 1 at 02-NOV-08piece handle=/rmanset/RACDB_arch_99_1_1 tag=TAG20081102T231211 comment=NONE channel ch00: backup set complete, elapsed time: 00:00:08Finished backup at 02-NOV-08Starting backup at 02-NOV-08channel ch00: starting full datafile backupsetchannel ch00: specifying datafile(s in backupsetincluding current control file in backupsetchannel ch00: starting piece 1 at 02-NOV-08channel ch00: finished piece 1 at 02-NOV-08piece handle=/rmanset/cf_RACDB_100_1 tag=TAG20081102T231235 comment=NONEchannel ch00: backup set complete, elapsed time: 00:00:07Finished backup at 02-NOV-08released channel: ch00released channel: ch012. 在 rac 库上创建 pfileSQL> create pfile='/rmanset/initracdb.ora' from spfile;将 rac1,rac2上的备份出来的 rman 文件和 pfile ftp 至 standby 主机二: standby 主机做恢复的过程:0. 修改 ftp 过来的 pfile ,主要是 rac 中一些参数去掉:#*.cluster_database_instances=2*.cluster_database=false#racdb2.instance_number=2#racdb1.instance_number=1#racdb2.thread=2#racdb1.thread=1#racdb2.undo_tablespace='UNDOTBS2'#*.db_file_name_convert='+RACDATA/racdb/datafile/','/oradata/racdb/'#*.fal_client='RACDB'#*.fal_server='STANDBY'#*.log_archive_config='DG_CONFIG=(racdb,standby'#racdb2.log_archive_dest_1='LOCATION=/racdb2_archVALID_FOR=(ALL_LOGFILES,ALL_ROLES DB_UNIQUE_NAME=racdb'#*.log_archive_dest_2='SERVICE=standby LGWR ASYNCVALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLEDB_UNIQUE_NAME=standby'#*.log_archive_dest_state_2='ENABLE'#*.log_file_name_convert='+RACDATA/racdb/onlinelog/','/oradata/racdb/'#*.remote_listener='LISTENERS_RACDB'#*.standby_file_management='AUTO'1. 数据库启动到 nomount2.restore controlfile3.restore archivelog4.recover database5. 改变 logfile 的位置,重新建 redo6.drop 一个 undo tablespace.7.add a temp tablespace8. 配 tnsnames.ora 和 listener .ora下为操作的过程:standby-> rman target /Recovery Manager: Release 10.2.0.1.0 - Production on Sun Nov 2 14:22:39 2008 Copyright (c 1982, 2005, Oracle. All rights reserved.connected to target database: racdb (not mounted--恢复 controlfileRMAN> restore controlfile from '/rmanset/cf_RACDB_100_1';Starting restore at 02-NOV-08using channel ORA_DISK_1channel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:05output filename=/oradata/racdb/control01.ctlFinished restore at 02-NOV-08---restore datafile and archive logRMAN> sql 'alter database mount';sql statement: alter database mountreleased channel: ORA_DISK_1RMAN> run{2> set until sequence 57 thread 1;3> set newname for datafile 1 to '/oradata/racdb/system01.dbf';4> set newname for datafile 2 to '/oradata/racdb/undotbs01.dbf';5> set newname for datafile 3 to '/oradata/racdb/sysaux01.dbf';6> set newname for datafile 4 to '/oradata/racdb/users01.dbf';7> set newname for datafile 5 to '/oradata/racdb/undotbs02.dbf';8> restore database;9> switch datafile all;10> }executing command: SET until clauseexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEStarting restore at 02-NOV-08allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=155 devtype=DISKchannel ORA_DISK_1: starting datafile backupset restorechannel ORA_DISK_1: specifying datafile(s to restore from backup setrestoring datafile 00001 to /oradata/racdb/system01.dbfrestoring datafile 00004 to /oradata/racdb/users01.dbfrestoring datafile 00005 to /oradata/racdb/undotbs02.dbfchannel ORA_DISK_1: reading from backup piece/rmanset/racdb_full_RACDB669769770931channel ORA_DISK_1: restored backup piece 1piece handle=/rmanset/racdb_full_RACDB669769770931 tag=FULLBACKUP channel ORA_DISK_1: restore complete, elapsed time: 00:00:36channel ORA_DISK_1: starting datafile backupset restorechannel ORA_DISK_1: specifying datafile(s to restore from backup setrestoring datafile 00002 to /oradata/racdb/undotbs01.dbfrestoring datafile 00003 to /oradata/racdb/sysaux01.dbfchannel ORA_DISK_1: reading from backup piece/rmanset/racdb_full_RACDB669769784941channel ORA_DISK_1: restored backup piece 1piece handle=/rmanset/racdb_full_RACDB669769784941 tag=FULLBACKUPchannel ORA_DISK_1: restore complete, elapsed time: 00:00:35Finished restore at 02-NOV-08datafile 1 switched to datafile copyinput datafile copy recid=10 stamp=669738296filename=/oradata/racdb/system01.dbf datafile 2 switched to datafile copyinput datafile copy recid=11 stamp=669738296filename=/oradata/racdb/undotbs01.dbf datafile 3 switched to datafile copyinput datafile copy recid=12 stamp=669738296filename=/oradata/racdb/sysaux01.dbf datafile 4 switched to datafile copyinput datafile copy recid=13 stamp=669738297 filename=/oradata/racdb/users01.dbf datafile 5 switched to datafile copyinput datafile copy recid=14 stamp=669738297filename=/oradata/racdb/undotbs02.dbf RMAN>--列出备份的 archivelog:RMAN> list backup of archivelog all;using target database control file instead of recovery catalogList of Backup Sets===================BS Key Size Device Type Elapsed Time Completion Time------- ---------- ----------- ------------ ---------------89 2.44M DISK 00:00:03 02-NOV-08BP Key: 89 Status: AVAILABLE Compressed: NO Tag: TAG20081102T231211 Piece Name: /rmanset/RACDB_arch_98_1_2List of Archived Logs in backup set 89Thrd Seq Low SCN Low Time Next SCN Next Time---- ------- ---------- --------- ---------- ---------1 53 356353 02-NOV-08 396535 02-NOV-081 54 396535 02-NOV-08 398232 02-NOV-082 44 350717 02-NOV-08 356350 02-NOV-082 45 356350 02-NOV-08 376487 02-NOV-082 46 376487 02-NOV-08 396536 02-NOV-082 47 396536 02-NOV-08 397820 02-NOV-082 48 397820 02-NOV-08 398228 02-NOV-082 49 398228 02-NOV-08 398963 02-NOV-08BS Key Size Device Type Elapsed Time Completion Time------- ---------- ----------- ------------ ---------------90 17.42M DISK 00:00:07 02-NOV-08BP Key: 90 Status: AVAILABLE Compressed: NO Tag: TAG20081102T231211Piece Name: /rmanset/RACDB_arch_97_1_1List of Archived Logs in backup set 90Thrd Seq Low SCN Low Time Next SCN Next Time---- ------- ---------- --------- ---------- ---------1 42 285767 01-NOV-08 285925 01-NOV-081 44 286441 01-NOV-08 286516 01-NOV-081 45 286516 01-NOV-08 308174 01-NOV-081 46 308174 01-NOV-08 312441 01-NOV-081 47 312441 01-NOV-08 324657 02-NOV-08BS Key Size Device Type Elapsed Time Completion Time------- ---------- ----------- ------------ ---------------91 9.69M DISK 00:00:04 02-NOV-08BP Key: 91 Status: AVAILABLE Compressed: NO Tag: TAG20081102T231211 Piece Name: /rmanset/RACDB_arch_99_1_1List of Archived Logs in backup set 91Thrd Seq Low SCN Low Time Next SCN Next Time---- ------- ---------- --------- ---------- ---------1 48 324657 02-NOV-08 324727 02-NOV-081 49 324727 02-NOV-08 325613 02-NOV-081 50 325613 02-NOV-08 349040 02-NOV-081 51 349040 02-NOV-08 350714 02-NOV-081 52 350714 02-NOV-08 356353 02-NOV-081 55 398232 02-NOV-08 398433 02-NOV-081 56 398433 02-NOV-08 398960 02-NOV-08--restore archivelog and recover database.RMAN>RMAN> run{2> set archivelog destination to '/racdb_arch';3> restore archivelog from sequence 49 thread 2;}4>executing command: SET ARCHIVELOG DESTINATIONStarting restore at 02-NOV-08using channel ORA_DISK_1channel ORA_DISK_1: starting archive log restore to user-specified destination archive log destination=/racdb_archchannel ORA_DISK_1: restoring archive logarchive log thread=2 sequence=49channel ORA_DISK_1: reading from backup piece /rmanset/RACDB_arch_98_1_2 channel ORA_DISK_1: restored backup piece 1piece handle=/rmanset/RACDB_arch_98_1_2 tag=TAG20081102T231211channel ORA_DISK_1: restore complete, elapsed time: 00:00:02Finished restore at 02-NOV-08RMAN>RMAN>RMAN> run{2> set archivelog destination to '/racdb_arch';3> restore archivelog from sequence 44 thread 2;4> }executing command: SET ARCHIVELOG DESTINATIONStarting restore at 02-NOV-08using channel ORA_DISK_1archive log thread 2 sequence 49 is already on disk as file/racdb_arch/2_49_669487401.dbf channel ORA_DISK_1: starting archive log restore to user-specified destinationarchive log destination=/racdb_archchannel ORA_DISK_1: restoring archive logarchive log thread=2 sequence=44channel ORA_DISK_1: restoring archive logarchive log thread=2 sequence=45channel ORA_DISK_1: restoring archive logarchive log thread=2 sequence=46channel ORA_DISK_1: restoring archive logarchive log thread=2 sequence=47channel ORA_DISK_1: restoring archive logarchive log thread=2 sequence=48channel ORA_DISK_1: reading from backup piece /rmanset/RACDB_arch_98_1_2 channel ORA_DISK_1: restored backup piece 1piece handle=/rmanset/RACDB_arch_98_1_2 tag=TAG20081102T231211 channel ORA_DISK_1: restore complete, elapsed time: 00:00:02Finished restore at 02-NOV-08RMAN> run{2> set until sequence 57 thread 1;3> recover database;4> }executing command: SET until clauseStarting recover at 02-NOV-08using channel ORA_DISK_1starting media recoveryarchive log thread 2 sequence 49 is already on disk as file/racdb_arch/2_49_669487401.dbf channel ORA_DISK_1: starting archive log restore to default destinationchannel ORA_DISK_1: restoring archive logarchive log thread=1 sequence=56channel ORA_DISK_1: reading from backup piece /rmanset/RACDB_arch_99_1_1channel ORA_DISK_1: restored backup piece 1piece handle=/rmanset/RACDB_arch_99_1_1 tag=TAG20081102T231211channel ORA_DISK_1: restore complete, elapsed time: 00:00:02archive log filename=/racdb_arch/1_56_669487401.dbf thread=1 sequence=56archive log filename=/racdb_arch/2_49_669487401.dbf thread=2 sequence=49media recovery complete, elapsed time: 00:00:01Finished recover at 02-NOV-08--对 redo 作修改:alter database rename file '+RACDATA/racdb/onlinelog/group_1.257.669487411' to '/oradata/racdb/redo1';alter database rename file '+RACDATA/racdb/onlinelog/group_2.258.669487419' to '/oradata/racdb/redo2';alter database rename file '+RACDATA/racdb/onlinelog/group_3.265.669489319' to '/oradata/racdb/redo3';alter database rename file '+RACDATA/racdb/onlinelog/group_4.266.669489327' to '/oradata/racdb/redo4';SQL> select member from v$logfile;MEMBER--------------------------------------------------------------------------------+RACDATA/racdb/onlinelog/group_1.257.669487411+RACDATA/racdb/onlinelog/group_2.258.669487419+RACDATA/racdb/onlinelog/group_3.265.669489319+RACDATA/racdb/onlinelog/group_4.266.669489327SQL> alter database rename file'+RACDATA/racdb/onlinelog/group_1.257.669487411' to '/oradata/racdb/redo1';Database altered.SQL> alter database rename file'+RACDATA/racdb/onlinelog/group_2.258.669487419' to '/oradata/racdb/redo2';alter database rename file '+RACDATA/racdb/onlinelog/group_3.265.669489319' to '/oradata/racdb/redo3';alter database rename file '+RACDATA/racdb/onlinelog/group_4.266.669489327' to '/oradata/racdb/redo4';Database altered.SQL>Database altered.SQL>Database altered.SQL> alter database open resetlogs;Database altered.SQL>SQL>SQL>SQL> select THREAD#, STATUS, ENABLED from v$thread;THREAD# STATUS ENABLED---------- ------ --------1 OPEN PUBLIC2 CLOSED PUBLICSQL>SQL> select group# from v$log where THREAD#=2;GROUP#----------34SQL> alter database disable thread 2;Database altered.SQL> alter database drop logfile group 4;alter database drop logfile group 4*ERROR at line 1:ORA-00350: log 4 of instance racdb2 (thread 2 needs to be archived ORA-00312: online log 4 thread 2: '/oradata/racdb/redo4'SQL> alter database clear unarchived logfile group 3;Database altered.SQL> alter database drop logfile group 3;Database altered.SQL> alter database drop logfile group 4;alter database drop logfile group 4*ERROR at line 1:ORA-00350: log 4 of instance racdb2 (thread 2 needs to be archived ORA-00312: online log 4 thread 2: '/oradata/racdb/redo4'SQL> alter database clear unarchived logfile group 4;Database altered.SQL> alter database drop logfile group 4;Database altered.SQL> select group#,member from v$logfile;GROUP#----------MEMBER-------------------------------------------------------------------------------- 1/oradata/racdb/redo12/oradata/racdb/redo2SQL> select THREAD#, STATUS, ENABLED from v$thread;THREAD# STATUS ENABLED---------- ------ --------1 OPEN PUBLIC对 undo 的处理:SQL> show parameter undoNAME TYPE VALUE------------------------------------ ----------- ------------------------------undo_management string AUTOundo_retention integer 900undo_tablespace string UNDOTBS1SQL> select tablespace_name from dba_tablespaces where contents='UNDO'; TABLESPACE_NAME------------------------------UNDOTBS1UNDOTBS2SQL> drop tablespace UNDOTBS2 including contents and datafiles;T ablespace dropped.SQL> select tablespace_name from dba_tablespaces where contents='UNDO'; TABLESPACE_NAME------------------------------UNDOTBS1SQL>对 temp 的处理:create temporary tablespace TEMP1 tempfile '/oradata/racdb/temp01.dbf' size 50M autoextend off;SQL> select name from v$tempfile;NAME---------------------------------------------------------------------------------------------------------------------------------------------/oradata/racdb/RACDB/datafile/o1_mf_temp_4jtl9yfl_.tmpSQL>SQL>SQL> select tablespace_name from dba_tablespaces wherecontents='TEMPORARY';TABLESPACE_NAME------------------------------TEMPSQL> create temporary tablespace TEMP12 tempfile '/oradata/racdb/temp01.dbf'3 size 50M autoextend off;T ablespace created.SQL> alter database default temporary tablespace TEMP1; Database altered. SQL> drop tablespace TEMP including contents and datafiles; T ablespace dropped. SQL>再配上 tnsnames.ora 及 listener.ora。

使用RMAN恢复数据库到不同主机

使用RMAN恢复数据库到不同主机

使用RMAN恢复数据库到不同主机2009-05-20 14:33当未使用catalog方式进行rman备份时,将备份集转移到其他主机时,除非目录结构相同,否则控制文件将无法识别路径不同的备份集,针对这类问题,可以使用dbms_backup_restore包进行文件回复;但是从Oracle 10g开始,Oracle终于简化了这类问题的处理,现在通过rman可以很容易地处理不同主机的rman备份集恢复。

一、获得源数据库的参数文件,修改后传送至目标数据库,修改后的参数文件可以用于数据库启动,主要修改的参数应该包括:*_dmpb_dest、control_files、db_recovery_file_dest、db_create_file_dest等。

二、建立相应的文件夹如:admin下建立cinwa及里面对应的文件夹(adump,bdump,cdump,dpdump,pfile,udump),oradata下建立cinwa,flash_recovery_area下建立cinwa三、在window平台下,可以通过oradim创建一个服务启动oracle环境C:\>oradim -new -sid cinwa实例已创建。

注意:记得启动服务。

四、通过rman来启动数据库到nomount状态C:\>set oracle_sid=cinwaC:\>rman target /RMAN> startup nomount pfile ='D:\oracle\product\10.2.0\admin\cinwa\pfile\init.ora';通过参数文件启动到noumount状态,参数文件所在位置在$ORACLE_HOME/database,$ORACLE_HOME/dbs,$ORACLE_BASE/admin/pfile相应目录下,记录了各种启动所必须得参数,如果现在所在的数据库的安装目录与源数据库不同,则需要更改路径.五、通过备份的控制文件恢复出控制文件RMAN> restore controlfile from 'D:\oracle\product\10.2.0\\backupC-515068080-20090518-02.BKP';然后根据参数文件的control_files设置,复制相应的副本。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
以下恢复数据文件
Startup nomount
DECLARE
devtype varchar2(256);
done boolean;
BEGIN
devtype:=sys.dbms_backup_restore.deviceAllocate (type=>'',ident=>'t1');
sys.dbms_backup_restore.restoreSetDatafile;
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>03,toname=>'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\SYSAUX01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>04,toname=>'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\USERS01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>05,toname=>'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\EXAMPLE01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>06,toname=>'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\HIS01');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>01,toname=>'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\SYSTEM01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>02,toname=>'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\UNDOTBS01.DBF');
在RMAN中设置DBID
set DBID=79382924
6.恢复控制文件
在sqlplus中启动到NOMOUNT状态
Sql>Startup nomount
Sql>exit
进入RMAN
C:\>rman target sys/bsoft
执行命令
run{
set controlfile autobackup format for device type disk to 'E:\ora_bak\ %d_%s_%p.bak';
end;
结果: 成功!
然后拷贝二个一样的文件(control01,control02)到同一目录下
7.修改数据文件路径在RMAN中到新机器安装路径,然后RESTORE DATABASE
Rman sys/bsoft
Startup mount
Run{
Set newname for datafile 1 to 'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\SYSTEM01.DBF';
Set newname for datafile 4 to 'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\USERS01.DBF';
Set newname for datafile 5 to 'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\EXAMPLE01.DBF';
/
结果: 恢复成功!
以下恢复归档日志
SQL> DECLARE
devtype varchar2(256);
done boolean;
BEGIN
devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'t1');
Alter database rename file 'I:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\STREAMS_TBS.DBF' to 'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\STREAMS_TBS.DBF';
"E:\ora_bak\pfilehrp270.ora"
结果: 成功!
注意
用此方法建的ORACLE服务只是个壳,windows服务启动不代表ORACLE的实例启动,需要在安装完ORACLE后在注册表中设置
加在HKEY_LOCAL_MACHINE\ORACLE\HOME下加上
ORA_SID_AUTOSTART=TURE
sys.dbms_backup_restore.restoreSetArchivedLog(destination=>' D:\oracle\product.2.0\flash_recovery_area\HRP270\ARCHIVELOG');
sys.dbms_backup_restore.restoreArchivedLog(thread=>1,sequence=>6);
sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'E:\ora_bak\HRP270_18_1.BAK', params=>null);
sys.dbms_backup_restore.deviceDeSet newname for datafile 6 to 'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\HIS01';
Set newname for datafile 7 to 'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\TEST01';
dbms_backup_restore.restoresetdatafile;
dbms_backup_restore.restorecontrolfileto('D:\oracle\product.2.0\oradata\hrp270\control01.ctl');
dbms_backup_restore.restorebackuppiece('E:\ora_bak\C-79382924-20070330-00',DONE=>done);
RMAN 备份集在异机异路径下恢复过程详解!
这两天对备份与恢复做了点研究,整理成文档如下:
RMAN 备份集在异机异路径下恢复过程
原数据库环境
机器名:yfzx
数据库名:HRP270
归档模式打开
路径: I:\ORACLE\PRODUCT.2.0\db_1
新数据库环境:
机器名:zhengsh
只安装了数据库ORACLE 10.2G软件,在D盘,没有建数据库,该机器没有I盘
1.通过网络拷贝RMAN备份文件到zhengsh机器下E:\ora_bak,包括数据备份、控制文件备份、SPFILE文件备份
2.建立数据库服务
C:\Documents and Settings\zhengsh>oradim -NEW -SID HRP270 -INTPWD bsoft -pfile
/
结果: 无法打开归档日志,恢复失败!,估计sequence值需要正确设置,但怎么找还不知道。
下面就用无归档日志来恢复数据库
9.修改数据文件在控制文件中路径
Alter database rename file 'I:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\SYSTEM01.DBF' to 'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\SYSTEM01.DBF';
Alter database rename file 'I:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\USERS01.DBF' to 'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\USERS01.DBF';
Alter database rename file 'I:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\EXAMPLE01.DBF' to 'D:\ORACLE\PRODUCT.2.0\ORADATA\HRP270\EXAMPLE01.DBF';
sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'E:\ora_bak\HRP270_17_1.BAK',params=>null);
sys.dbms_backup_restore.deviceDeallocate;
END;
ORA_SID_SHUTDOWN=TURE
ORA_SID_SHUTDOWNTYPE=i
3.配置监听与网络连接
结果:
监听配置成功
相关文档
最新文档