时间:2021-07-01 10:21:17 帮助过:11人阅读
【RMAN】利用备份片还原数据库
【RMAN】利用备份片还原数据库(上): http://blog.itpub.net/26736162/viewspace-1621581/
在上一篇blog中我们介绍了采用dbms_backup_restore来找回控制文件并恢复整个数据库的方法,本篇blog我们介绍采用创建临时库来找回控制文件的方法。
由于RMAN必须工作在MOUNT模式,所有的数据文件都丢失,无法通过只重建控制文件将其启动到MOUNT模式,所以这里利用dbca创建一个临时数据库环境,数据库的名称与原有名称保持不变,文件存放到默认位置即可。
一、 搭建临时库来注册备份集
这里我们假设有一个临时环境供我们测试,ORACLE_SID=orcltest,由于是第二天做的测试,所以我重新对原库做了备份并传递到备份库
[root@rhel6_lhr backupset]# scp -r 2015_05_02 oracle@192.168.59.129:/tmp
oracle@192.168.59.129‘s password:
o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp 100% 9728 9.5KB/s 00:00
o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp 100% 236MB 6.6MB/s 00:36
o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp 100% 1096MB 54.8MB/s 00:20
o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp 100% 10MB 9.8MB/s 00:00
o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp 100% 9600KB 9.4MB/s 00:00
[root@rhel6_lhr backupset]#
[root@rhel6_lhr 2015_05_02]# ll -h
total 1.4G
-rw-r----- 1 oracle asmadmin 9.9M May 2 11:23 o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp
-rw-r----- 1 oracle asmadmin 9.5K May 2 11:31 o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp
-rw-r----- 1 oracle asmadmin 9.4M May 2 11:31 o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp
-rw-r----- 1 oracle asmadmin 236M May 2 10:56 o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
-rw-r----- 1 oracle asmadmin 1.1G May 2 11:31 o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
由下边的方法(备份集中无控制文件的备份)的方法得知,这里创建一个临时库的方法比较麻烦,不太推荐:
[oracle@orcltest tmp]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orcltest -sid orcltest -sysPassword lhr -systemPassword lhr -responseFile NO_VALUE -datafileDestination /u02/app/oracle/oradata -redoLogFileSize 50 -recoveryAreaDestination /u02/app/oracle/flash_recovery_area -storageType FS -characterSet ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -memoryPercentage 30 -totalMemory 200 -databaseType OLTP -emConfiguration NONE -automaticMemoryManagement true
Copying database files
1% complete
3% complete
10% complete
17% complete
24% complete
35% complete
Creating and starting Oracle instance
37% complete
42% complete
47% complete
52% complete
53% complete
56% complete
58% complete
Registering database with Oracle Restart
64% complete
Completing Database Creation
68% complete
71% complete
75% complete
85% complete
96% complete
100% complete
Look at the log file "/u02/app/oracle/cfgtoollogs/dbca/orcltest/orcltest0.log" for further details.
[oracle@orcltest tmp]$ crsstat
Name Type Target State Host
------------------------------ -------------------------- ---------- --------- -------
ora.DATA.dg ora.diskgroup.type ONLINE ONLINE orcltest
ora.LISTENER.lsnr ora.listener.type ONLINE ONLINE orcltest
ora.asm ora.asm.type ONLINE ONLINE orcltest
ora.cssd ora.cssd.type ONLINE ONLINE orcltest
ora.diskmon ora.diskmon.type OFFLINE OFFLINE
ora.evmd ora.evm.type ONLINE ONLINE orcltest
ora.ons ora.ons.type OFFLINE OFFLINE
ora.orcltest.db ora.database.type ONLINE ONLINE orcltest
[oracle@orcltest 2015_05_02]$ ll
total 1383664
-rw-r----- 1 oracle oinstall 10278400 May 2 11:34 o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp
-rw-r----- 1 oracle oinstall 9728 May 2 11:33 o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp
-rw-r----- 1 oracle oinstall 9830400 May 2 11:34 o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp
-rw-r----- 1 oracle oinstall 247463936 May 2 11:34 o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
-rw-r----- 1 oracle oinstall 1149280256 May 2 11:34 o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
[oracle@orcltest 2015_05_02]$ ORACLE_SID=orcltest
[oracle@orcltest 2015_05_02]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Sat May 2 11:36:51 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@orcltest 2015_05_02]$
[oracle@orcltest 2015_05_02]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Sat May 2 11:37:24 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCLTEST (DBID=2626150865)
RMAN> list backupset;
specification does not match any backup in the repository
RMAN>
RMAN> catalog start with ‘/tmp/2015_05_02/‘;
using target database control file instead of recovery catalog
searching for all files that match the pattern /tmp/2015_05_02/
List of Files Unknown to the Database
=====================================
File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp
File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp
File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
no files cataloged
List of Files Which Where Not Cataloged
=======================================
File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp
RMAN-07518: Reason: Foreign database file DBID: 4270446895 Database Name: ORA11G
File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
RMAN-07518: Reason: Foreign database file DBID: 4270446895 Database Name: ORA11G
File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
RMAN-07518: Reason: Foreign database file DBID: 4270446895 Database Name: ORA11G
File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp
RMAN-07518: Reason: Foreign database file DBID: 4270446895 Database Name: ORA11G
File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp
RMAN-07518: Reason: Foreign database file DBID: 4270446895 Database Name: ORA11G
RMAN>
RMAN> catalog backuppiece ‘/tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp‘;
ORA-19870: error while restoring backup piece /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp
ORA-19691: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp is from different database: id=4270446895, name=ORA11G
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of catalog command at 05/02/2015 11:40:26
RMAN-06209: List of failed objects
RMAN-06211: ==========================
RMAN-06212: Object Type Filename/Handle
RMAN-06213: --------------- ---------------------------------------------------
RMAN-06214: Backup Piece /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp
RMAN>
RMAN>
由此可以看出,命令catalog start with ‘/tmp/2015_05_02/‘; 在异库注册可以查看到原库的信息:DBID: 4270446895 Database Name: ORA11G,(10g下测试也可以获取到这些信息)这里dbname和dbid都不一样所以不能注册在该数据库下,将备份片的信息加入到控制文件的时候报错,原因在于原有数据库和临时数据库的DBID不同,那么我们是否可以尝试修改临时数据库的DBID,使它与原有数据库DBID保持一致呢,试试呗。
1、 修改dbname和dbid
首先启动临时库到open read only状态,然后执行脚本:
[oracle@orcltest dbs]$ ORACLE_SID=orcltest
[oracle@orcltest dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Sat May 2 12:56:05 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.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> startup open read only;
ORACLE instance started.
Total System Global Area 409194496 bytes
Fixed Size 2228864 bytes
Variable Size 281021824 bytes
Database Buffers 117440512 bytes
Redo Buffers 8503296 bytes
Database mounted.
Database opened.
SQL> @?/dbs/change_dbid.sql
PL/SQL procedure successfully completed.
OLD_NAME
--------------------------------
ORCLTEST
Enter the new Database Name:ORA11G
Enter the new Database ID:4270446895
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
Convert ORCLTEST(2626156129) to ORA11G(4270446895)
PL/SQL procedure successfully completed.
ControlFile:
=> Change Name:1
=> Change DBID:1
DataFile: /u02/app/oracle/oradata/orcltest/system01.dbf
=> Skipped:0
=> Change Name:1
=> Change DBID:1
DataFile: /u02/app/oracle/oradata/orcltest/sysaux01.dbf
=> Skipped:0
=> Change Name:1
=> Change DBID:1
DataFile: /u02/app/oracle/oradata/orcltest/undotbs01.dbf
=> Skipped:0
=> Change Name:1
=> Change DBID:1
DataFile: /u02/app/oracle/oradata/orcltest/users01.dbf
=> Skipped:0
=> Change Name:1
=> Change DBID:1
DataFile: /u02/app/oracle/oradata/orcltest/example01.dbf
=> Skipped:0
=> Change Name:1
=> Change DBID:1
DataFile: /u02/app/oracle/oradata/orcltest/temp01.dbf
=> Skipped:0
=> Change Name:1
=> Change DBID:1
PL/SQL procedure successfully completed.
SQL> create pfile from spfile;
File created.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@orcltest dbs]$ ll
total 52
-rw-r--r-- 1 oracle oinstall 2239 May 2 12:33 change_dbid.sql
-rw-rw---- 1 oracle oinstall 1544 May 2 10:56 hc_DBUA5452531.dat
-rw-rw---- 1 oracle oinstall 1544 May 2 12:45 hc_ORA11G.dat
-rw-rw---- 1 oracle oinstall 1544 May 2 12:56 hc_orcltest.dat
-rw-r----- 1 oracle oinstall 165 May 2 10:54 initDBUA5452531.ora
-rw-r--r-- 1 oracle oinstall 2851 May 15 2009 init.ora
-rw-r--r-- 1 oracle oinstall 640 May 2 12:10 initORA11G.ora
-rw-r--r-- 1 oracle oinstall 997 May 2 12:58 initorcltest.ora
-rw-r----- 1 oracle oinstall 0 May 2 10:55 lkinstDBUA5452531
-rw-r----- 1 oracle oinstall 24 May 2 12:10 lkORA11G
-rw-r----- 1 oracle oinstall 24 Apr 21 16:27 lkORCLTEST
-rw-r----- 1 oracle oinstall 1536 May 2 10:54 orapwDBUA5452531
-rw-r----- 1 oracle oinstall 1536 May 2 12:53 orapworcltest
-rw-r----- 1 oracle oinstall 3584 May 2 12:57 spfileorcltest.ora
[oracle@orcltest dbs]$ vi initorcltest.ora
。。。。
*.db_name=‘ORA11G‘
。。。。
[oracle@orcltest dbs]$ mv initorcltest.ora initORA11G.ora
[oracle@orcltest dbs]$ ORACLE_SID=ORA11G
[oracle@orcltest dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Sat May 2 13:04:44 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> startup mount;
ORACLE instance started.
Total System Global Area 409194496 bytes
Fixed Size 2228864 bytes
Variable Size 272633216 bytes
Database Buffers 125829120 bytes
Redo Buffers 8503296 bytes
Database mounted.
SQL> alter database open resetlogs;
Database altered.
SQL> select dbid,name from v$database;
DBID NAME
---------- ---------
4270446895 ORA11G
SQL>
好了,和原库一样了,现在我们重新注册
2、 重新注册
[oracle@orcltest dbs]$ORACLE_SID=ORA11G
[oracle@orcltest dbs]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Sat May 2 13:10:35 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORA11G (DBID=4270446895)
RMAN> catalog start with ‘/tmp/2015_05_02/‘;
using target database control file instead of recovery catalog
searching for all files that match the pattern /tmp/2015_05_02/
List of Files Unknown to the Database
=====================================
File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp
File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp
File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp
File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp
File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp
RMAN>
成功注册,接下来就简单了,查看备份集中含有哪些内容
RMAN> list backupset;
List of Backup Sets
===================
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
1 9.00K DISK 00:00:00 02-MAY-15
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20150502T113152
Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp
List of Archived Logs in backup set 1
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 15 1145640 02-MAY-15 1145812 02-MAY-15
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 235.99M DISK 00:00:00 02-MAY-15
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20150502T105103
Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1122334 02-MAY-15 /u02/app/oracle/oradata/orcltest/system01.dbf
2 Full 1122334 02-MAY-15 /u02/app/oracle/oradata/orcltest/sysaux01.dbf
3 Full 1122334 02-MAY-15 /u02/app/oracle/oradata/orcltest/undotbs01.dbf
4 Full 1122334 02-MAY-15 /u02/app/oracle/oradata/orcltest/users01.dbf
5 Full 1092435 30-APR-15 /u02/app/oracle/oradata/orcltest/example01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 1.07G DISK 00:00:00 02-MAY-15
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20150502T112355
Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
List of Datafiles in backup set 3
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1145650 02-MAY-15 /u02/app/oracle/oradata/orcltest/system01.dbf
2 Full 1145650 02-MAY-15 /u02/app/oracle/oradata/orcltest/sysaux01.dbf
3 Full 1145650 02-MAY-15 /u02/app/oracle/oradata/orcltest/undotbs01.dbf
4 Full 1145650 02-MAY-15 /u02/app/oracle/oradata/orcltest/users01.dbf
5 Full 1092435 30-APR-15 /u02/app/oracle/oradata/orcltest/example01.dbf
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
4 9.80M DISK 00:00:00 02-MAY-15
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20150502T112352
Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp
List of Archived Logs in backup set 4
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 13 1122206 02-MAY-15 1145003 02-MAY-15
1 14 1145003 02-MAY-15 1145640 02-MAY-15
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5 Full 9.36M DISK 00:00:00 02-MAY-15
BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20150502T112355
Piece Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp
SPFILE Included: Modification time: 02-MAY-15
SPFILE db_unique_name: ORA11G
Control File Included: Ckp SCN: 1145807 Ckp time: 02-MAY-15
RMAN>
我们可以看到,控制文件和spfile都在备份文件: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp 中,有归档文件,有数据文件,此时我们就可以考虑还原策略了,我们可以使用备份中的spfile和控制文件,也可以只还原数据文件,这个根据自己的需要而定,这里我们测试的话就从spfile、control file,datafile都还原吧。
二、 还原操作 1、 还原spfile
RMAN> restore spfile from ‘/tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp‘;
Starting restore at 02-MAY-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=144 device type=DISK
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 02-MAY-15
RMAN>
[oracle@orcltest ~]$ cd $ORACLE_HOME/dbs
[oracle@orcltest dbs]$ ll spfile*
-rw-r----- 1 oracle oinstall 2560 May 2 13:21 spfileORA11G.ora
-rw-r----- 1 oracle oinstall 3584 May 2 12:57 spfileorcltest.ora
[oracle@orcltest dbs]$
2、 还原控制文件
RMAN> restore controlfile to ‘/tmp/2015_05_02/cont.ctl‘ from ‘/tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp‘;
Starting restore at 02-MAY-15
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 02-MAY-15
RMAN>
这里可以采用原数据库的控制文件,即现在还原出来的控制文件,也可以采用目前临时库的控制文件,都可以,当然,如果备份集中没有控制文件的备份的话我们可以考虑 采用临时库的控制文件,或者备份片段中没有控制文件的备份 这个方法。
3、 还原database
这里分情况,如果采用原库的控制文件的话,我们可以这样还原:
①、 方法一:采用原库控制文件--推荐
将原库控制文件拷贝到pfile定义的相关目录:
[oracle@orcltest orcltest]$ cp /tmp/2015_05_02/cont.ctl /u02/app/oracle/flash_recovery_area/orcltest/control02.ctl
[oracle@orcltest orcltest]$ cp /tmp/2015_05_02/cont.ctl /u02/app/oracle/oradata/orcltest/control01.ctl
[oracle@orcltest orcltest]$ cd /u01/app/oracle/oradata/ora11g/
[oracle@orcltest dbs]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Sat May 2 13:32:55 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORA11G (DBID=4270446895, not open)
RMAN> list backupset;
using target database control file instead of recovery catalog
List of Backup Sets
===================
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
6 9.80M DISK 00:00:00 02-MAY-15
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20150502T112352
Piece Name: /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp
List of Archived Logs in backup set 6
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 13 1122206 02-MAY-15 1145003 02-MAY-15
1 14 1145003 02-MAY-15 1145640 02-MAY-15
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7 Full 1.07G DISK 00:07:46 02-MAY-15
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20150502T112355
Piece Name: /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
List of Datafiles in backup set 7
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1145650 02-MAY-15 /u01/app/oracle/oradata/ora11g/system01.dbf
2 Full 1145650 02-MAY-15 /u01/app/oracle/oradata/ora11g/sysaux01.dbf
3 Full 1145650 02-MAY-15 /u01/app/oracle/oradata/ora11g/undotbs01.dbf
4 Full 1145650 02-MAY-15 /u01/app/oracle/oradata/ora11g/users01.dbf
5 Full 1092435 30-APR-15 /u01/app/oracle/oradata/ora11g/example01.dbf
RMAN> delete backupset;
Starting implicit crosscheck backup at 02-MAY-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
Crosschecked 2 objects
Finished implicit crosscheck backup at 02-MAY-15
Starting implicit crosscheck copy at 02-MAY-15
using channel ORA_DISK_1
Finished implicit crosscheck copy at 02-MAY-15
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u02/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_05_02/o1_mf_1_2_bn8o55o8_.arc
File Name: /u02/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_05_02/o1_mf_1_3_bn8o6tkw_.arc
File Name: /u02/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_05_02/o1_mf_1_1_bn8o4j7z_.arc
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
6 6 1 1 EXPIRED DISK /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp
7 7 1 1 EXPIRED DISK /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp RECID=6 STAMP=878642633
deleted backup piece
backup piece handle=/u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp RECID=7 STAMP=878642635
Deleted 2 objects
RMAN> crosscheck backupset;
using channel ORA_DISK_1
specification does not match any backup in the repository
RMAN> list backupset;
specification does not match any backup in the repository
RMAN> exit
Recovery Manager complete.
[oracle@orcltest dbs]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Sat May 2 13:33:41 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORA11G (DBID=4270446895, not open)
RMAN> list backupset;
using target database control file instead of recovery catalog
specification does not match any backup in the repository
RMAN> catalog start with ‘/tmp/2015_05_02/‘;
searching for all files that match the pattern /tmp/2015_05_02/
List of Files Unknown to the Database
=====================================
File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp
File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
File Name: /tmp/2015_05_02/cont.ctl
File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp
File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp
File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
File Name: /tmp/2015_05_02/cont.ctl
File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp
File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp
RMAN> list backupset;
List of Backup Sets
===================
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
8 9.00K DISK 00:00:00 02-MAY-15
BP Key: 8 Status: AVAILABLE Compressed: NO Tag: TAG20150502T113152
Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp
List of Archived Logs in backup set 8
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 15 1145640 02-MAY-15 1145812 02-MAY-15
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9 Full 235.99M DISK 00:00:00 02-MAY-15
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20150502T105103
Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
List of Datafiles in backup set 9
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1122334 02-MAY-15 /u01/app/oracle/oradata/ora11g/system01.dbf
2 Full 1122334 02-MAY-15 /u01/app/oracle/oradata/ora11g/sysaux01.dbf
3 Full 1122334 02-MAY-15 /u01/app/oracle/oradata/ora11g/undotbs01.dbf
4 Full 1122334 02-MAY-15 /u01/app/oracle/oradata/ora11g/users01.dbf
5 Full 1092435 30-APR-15 /u01/app/oracle/oradata/ora11g/example01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10 Full 1.07G DISK 00:00:00 02-MAY-15
BP Key: 10 Status: AVAILABLE Compressed: NO Tag: TAG20150502T112355
Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
List of Datafiles in backup set 10
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1145650 02-MAY-15 /u01/app/oracle/oradata/ora11g/system01.dbf
2 Full 1145650 02-MAY-15 /u01/app/oracle/oradata/ora11g/sysaux01.dbf
3 Full 1145650 02-MAY-15 /u01/app/oracle/oradata/ora11g/undotbs01.dbf
4 Full 1145650 02-MAY-15 /u01/app/oracle/oradata/ora11g/users01.dbf
5 Full 1092435 30-APR-15 /u01/app/oracle/oradata/ora11g/example01.dbf
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
11 9.80M DISK 00:00:00 02-MAY-15
BP Key: 11 Status: AVAILABLE Compressed: NO Tag: TAG20150502T112352
Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp
List of Archived Logs in backup set 11
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 13 1122206 02-MAY-15 1145003 02-MAY-15
1 14 1145003 02-MAY-15 1145640 02-MAY-15
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
12 Full 9.36M DISK 00:00:00 02-MAY-15
BP Key: 12 Status: AVAILABLE Compressed: NO Tag: TAG20150502T112355
Piece Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp
SPFILE Included: Modification time: 02-MAY-15
SPFILE db_unique_name: ORA11G
Control File Included: Ckp SCN: 1145807 Ckp time: 02-MAY-15
RMAN> restore database;
Starting restore at 02-MAY-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=125 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/ora11g/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/ora11g/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ora11g/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ora11g/users01.dbf
channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
channel ORA_DISK_1: ORA-19870: error while restoring backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
ORA-19504: failed to create file "/u01/app/oracle/oradata/ora11g/system01.dbf"
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ora11g/example01.dbf
channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
channel ORA_DISK_1: ORA-19870: error while restoring backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
ORA-19504: failed to create file "/u01/app/oracle/oradata/ora11g/example01.dbf"
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1
failover to previous backup
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/ora11g/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/ora11g/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ora11g/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ora11g/users01.dbf
channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
channel ORA_DISK_1: ORA-19870: error while restoring backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
ORA-19504: failed to create file "/u01/app/oracle/oradata/ora11g/system01.dbf"
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ora11g/example01.dbf
channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
channel ORA_DISK_1: ORA-19870: error while restoring backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
ORA-19504: failed to create file "/u01/app/oracle/oradata/ora11g/example01.dbf"
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1
failover to previous backup
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/02/2015 13:34:38
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 5 found to restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore
缺少目录,我们建立目录重试:
[oracle@orcltest orcltest]$ mkdir -p /u01/app/oracle/oradata/ora11g/
RMAN> restore database;
Starting restore at 02-MAY-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/ora11g/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/ora11g/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ora11g/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ora11g/users01.dbf
channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
channel ORA_DISK_1: piece handle=/tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp tag=TAG20150502T112355
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:06
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ora11g/example01.dbf
channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp
channel ORA_DISK_1: piece handle=/tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp tag=TAG20150502T105103
channel ORA_DISK_1: restored backup piece 1
restore not complete
Restore did not complete for some files from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp (piecenum=1, pieces_done=1, done=FALSE, failover=FALSE)
Please check alert log for additional information.
failover to previous backup
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ora11g/example01.dbf
channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp
channel ORA_DISK_1: piece handle=/tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp tag=TAG20150502T112355
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 02-MAY-15
RMAN> recover database;
Starting recover at 02-MAY-15
using channel ORA_DISK_1
datafile 5 not processed because file is read-only
starting media recovery
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=15
channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113