最近在验证、测试备份有效性时,遇到了“ORA-01180: can not create datafile 1”这个错误,顺便结合metalink的官方文档“RMAN restore fails with ORA-01180: can not create datafile 1 (文档 ID 1265151.1)”里面的内容做一个学习、归纳、总结,顺便加深一下理解。

creating datafile fno=1 name=/u01/oradata/SCM2/system01.dbf

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 06/14/2018 10:28:34

ORA-01180: can not create datafile 1

ORA-01110: data file 1: '/u01/oradata/SCM2/system01.dbf'

当然这个数据文件可能是system01.dbf,也可能是其它任何数据文件。但是如果它是FILE_ID为1数据文件,那么就是关键问题,因为FILE_ID为1是系统数据文件。它无法在RMAN还原过程中被创建。而它又必须从备份中还原(restore)。出现这个错误呢,要么就是没有可用的备份(no backups available for use),要么是当前的化身(Incarnation) 未正确设置。

官方文档提供下面命令来判别具体原因.

RMAN> list incarnation of database;

 

RMAN> list backup of datafile 1;

 

RMAN> list copy of datafile 1;

 

RMAN> list backup summary;

1: 检查是否没有可用的备份

如下命令所示,你可以检查是否存在可用的备份

RMAN>  list backup of datafile 1;

 

 

List of Backup Sets

===================

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

21778   Full    2.47G      DISK        00:08:28     03-JUN-18      

        BP Key: 21778   Status: EXPIRED  Compressed: YES  Tag: TAG20180603T002006

        Piece Name: /u04/backup/backupsets/ora_df977790007_s23771_s1

  List of Datafiles in backup set 21778

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 28945050985 03-JUN-18 /u01/oradata/SCM2/system01.dbf

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

21792   Full    2.47G      DISK        00:08:21     04-JUN-18      

        BP Key: 21792   Status: EXPIRED  Compressed: YES  Tag: TAG20180604T001936

        Piece Name: /u04/backup/backupsets/ora_df977876376_s23786_s1

  List of Datafiles in backup set 21792

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 28945603859 04-JUN-18 /u01/oradata/SCM2/system01.dbf

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

21806   Full    2.47G      DISK        00:08:33     05-JUN-18      

        BP Key: 21806   Status: AVAILABLE  Compressed: YES  Tag: TAG20180605T002025

        Piece Name: /u04/backup/backupsets/ora_df977962825_s23801_s1

  List of Datafiles in backup set 21806

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 28946703480 05-JUN-18 /u01/oradata/SCM2/system01.dbf

 

RMAN> 

如上所示,虽然有两个备份文件状态是EXPIRED,但是还是存在一个可用的备份文件,如果备份的状态全部是EXPIRED,则对备份集键运行crosscheck 查看它是否存在,例如

RMAN> crosscheck backupset 138;

如果存在,状态将会被更新为AVAILABLE。如果在运行crosscheck后状态仍为EXPIRED,则你需要的备份在物理上不存在。

RMAN> crosscheck backupset 21806;

 

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=910 devtype=DISK

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/u04/backup/backupsets/ora_df977962825_s23801_s1 recid=21806 stamp=977962827

Crosschecked 1 objects

 

RMAN> crosscheck backupset 21804;

 

using channel ORA_DISK_1

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of crosscheck command at 06/15/2018 08:21:59

RMAN-06160: no backup pieces found for backup set key: 21804

 

RMAN> 

$ ls  /u04/backup/backupsets/ora_df977876376_s23786_s1

  ls: /u04/backup/backupsets/ora_df977876376_s23786_s1: No such file or directory

$ ls /u04/backup/backupsets/ora_df977790007_s23771_s1

  ls: /u04/backup/backupsets/ora_df977790007_s23771_s1: No such file or directory

$ ls /u04/backup/backupsets/ora_df977962825_s23801_s1

  /u04/backup/backupsets/ora_df977962825_s23801_s1

$ 

2: 检查数据库当前的Incarnation

 

 

官方文档提供的例子如下所示

RMAN> list backup of datafile 1;

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ --------------------
138     Full    531.25M    DISK        00:00:00     13 FEB 2015 14:31:35
        BP Key: 136   Status: AVAILABLE  Compressed: NO  Tag: TAG20150213T143135
        Piece Name: /opt/app/oracle/fra/ORA102/backupset/2015_02_13/o1_mf_nnndf_TAG20150213T143135_bftw0r14_.bkp
  List of Datafiles in backup set 138
  File LV Type Ckp SCN    Ckp Time             Name
  ---- -- ---- ---------- -------------------- ----
  1       Full 25207062   13 FEB 2015 14:31:35 /opt/app/oracle/oradata/ORA102/system01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ --------------------
139     Full    531.32M    DISK        00:00:00     13 FEB 2015 14:09:34
        BP Key: 137   Status: AVAILABLE  Compressed: NO  Tag: TAG20150213T140934
        Piece Name: /opt/app/oracle/fra/ORA102/backupset/2015_02_13/o1_mf_nnndf_TAG20150213T140934_bfttqhh6_.bkp
  List of Datafiles in backup set 139
  File LV Type Ckp SCN    Ckp Time             Name
  ---- -- ---- ---------- -------------------- ----
  1       Full 25206825   13 FEB 2015 14:09:34 /opt/app/oracle/oradata/ORA102/system01.dbf

RMAN> list incarnation of database;

List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       ORA102   400119926        CURRENT 1          19 MAR 2012 15:29:58
2       2       ORA102   400119926        ORPHAN  5766931    04 OCT 2012 15:37:51
3       3       ORA102   400119926        ORPHAN  5768164    16 OCT 2012 15:33:09
...
9       9       ORA102   400119926        ORPHAN  25204629   13 FEB 2015 13:03:55
10      10      ORA102   400119926        ORPHAN  25205038   13 FEB 2015 13:35:57
11      11      ORA102   400119926        ORPHAN  25206695   13 FEB 2015 14:09:07
13      13      ORA102   400119926        ORPHAN  25206882   13 FEB 2015 14:16:24
14      14      ORA102   400119926        ORPHAN  25206882   13 FEB 2015 14:43:32
12      12      ORA102   400119926        ORPHAN  25206883   13 FEB 2015 14:30:54

要还原在2015年2月13日14点09分34秒进行的备份标签 (TAG20150213T140934),你必须在执行还原之前将incarnation重置为11 。

RMAN> reset database to incarnation 11;

个人遇到的例子如下,使用Tag为TAG20180605T002025的备份集还原,照理说当前的Incarnation是正确的

RMAN> list backup of datafile 1;

 

using target database control file instead of recovery catalog

 

List of Backup Sets

===================

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

21806   Full    2.47G      DISK        00:08:33     05-JUN-18      

        BP Key: 21806   Status: AVAILABLE  Compressed: YES  Tag: TAG20180605T002025

        Piece Name: /u04/backup/backupsets/ora_df977962825_s23801_s1

  List of Datafiles in backup set 21806

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 28946703480 05-JUN-18 /u01/oradata/SCM2/system01.dbf

RMAN> list incarnation of database;

 

 

List of Database Incarnations

DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time

------- ------- -------- ---------------- --- ---------- ----------

1       1       SCM2     4095319980       PARENT  1          05-OCT-12

2       2       SCM2     4095319980       CURRENT 28333829966 28-MAR-18

那么,我们检查一下告警日志,如下截图所示,因为catalog归档日志时,把不相关的归档日志catalog了,Oracle从归档日志中自动探测到incarnation信息,并重置incarnation,从而导致恢复报错。

参考官方文档 RMAN restore database fails ORA-01180: can not create datafile 1 (文档 ID 1573040.1)

When a BACKUP controlfile is used with a Flash Recovery Area defined, an  implicit crosscheck of the FRA is done and any files found belonging to the database are catalog'd to the controlfile.

Archivelogs created after a resetlogs operation will cause a new incarnation to be registered in the controlfile.

The new incarnations meant the database backup needed for restore  no longer belonged to the current incarnation.

参考资料:

RMAN restore fails with ORA-01180: can not create datafile 1 (文档 ID 1265151.1)

RMAN restore database fails ORA-01180: can not create datafile 1 (文档 ID 1573040.1)

RMAN restore fails with ORA-01180: can not create datafile 1的更多相关文章

  1. RMAN restore fails with ORA-01180: can not create datafile 1 (文档 ID 1265151.1)

    http://blog.itpub.net/26655292/viewspace-2131269/ ########Q&A issue1:ORA-01180: can not create d ...

  2. rman restore spfile from backup

    spfile一般在$ORACLE_HOME/dbs(linux)目录,如果你丢失了spfile并不会引起实例立刻停掉,你的实例可以继续操作,尽管当你restore spfile的时候需要关闭重启实例, ...

  3. 11g RMAN Restore archivelog用法

    I.备份所有归档日志文件 RMAN> BACKUP FORMAT '/u01/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVE ...

  4. Oracle 12c: RMAN restore/recover pluggable database

    查看数据库状态 运行在归档模式,可拔插数据库name=pdborcl SQL> archive log list; Database log mode Archive Mode Automati ...

  5. RMAN Restore, Recovery

    Complete recovery: rman target / nocatalog startup mount; restore database; recover database; alter ...

  6. Checklist for an RMAN Restore (Doc ID 1554636.1)

    Checklist for an RMAN Restore (Doc ID 1554636.1) APPLIES TO: Oracle Database - Enterprise Edition - ...

  7. asm单机dg dbca报错ORA-01031 CRS-2676,rman restore主库控制文件报错ORA-15081

    dg-> ll $ORACLE_HOME/bin/oracle -r-xr-s--x 1 oracle asmadmin 210824714 Nov 20 16:41 /u01/app/orac ...

  8. 转 rman 恢复报错

    ###sample 1   原因是新库起了FRA 区,FRA 区的旧文件属于之前的归档日志文件产生,这样会导致无法识别的问题. 解决办法,清空FRA或者恢复时候不启用FRA. RMAN RESTORE ...

  9. 如何将RAC数据库的 RMAN Disk 备份 Restore 到另一个节点上的单个实例 (Doc ID 415579.1)

    HowTo Restore RMAN Disk backups of RAC Database to Single Instance On Another Node (Doc ID 415579.1) ...

随机推荐

  1. Python GUI之tkinter窗口视窗教程大集合(看这篇就够了)

    一.前言 由于本篇文章较长,所以下面给出内容目录方便跳转阅读,当然也可以用博客页面最右侧的文章目录导航栏进行跳转查阅. 一.前言 二.Tkinter 是什么 三.Tkinter 控件详细介绍 1. T ...

  2. 03 使用Tensorflow做计算题

    我们使用Tensorflow,计算((a+b)*c)^2/a,然后求平方根.看代码: import tensorflow as tf # 输入储存容器 a = tf.placeholder(tf.fl ...

  3. linux 命令 — grep

    grep 用于文本搜索,能接受文件或者stdin作为输入,能输出各种格式 grep match_pattern filename 搜索文件中出现match_pattern的行,match_patter ...

  4. 始于阿里,回归社区:阿里8个项目进入CNCF云原生全景图

    破土而出的生命力,源自理想主义者心底对技术的信念. 云原生技术正席卷全球,云原生基金会在去年KubeCon +CloudNativeCon NA的现场宣布: 其正在孵化的项目已达14个,入驻的厂家或产 ...

  5. Thrift架构介绍

    Thrift是一个跨语言的服务部署框架,最初由Facebook于2007年开发,2008年进入Apache开源项目.Thrift通过一个中间语言(IDL, 接口定义语言)来定义RPC的接口和数据类型, ...

  6. 从a文件判断是否删除b文件中的行(sed示例)

    bash&shell系列文章:http://www.cnblogs.com/f-ck-need-u/p/7048359.html test.xml文件很大,内容结构如下: <?xml v ...

  7. python模块之xml

    xml模块 xml结构 xml是种实现不同语言或程序之间进行数据交换的协议,跟json差不多,但没json使用简单.但是因为历史遗留问题,至今很多行业依然使用xml这种数据格式. xml的格式如下,是 ...

  8. [转]nodejs中package.json和package-lock.json文件的功能分析

    本文转自:https://blog.csdn.net/u013992330/article/details/81110018 最新版nodejs中,多了一个package-lock.json文件,刚开 ...

  9. [转]Docker php extensions gd

    本文转自:https://docs.docker.com/samples/library/php/ How to use this image Create a Dockerfile in your ...

  10. 行为型---中介者模式(Mediator Pattern)

    中介者模式的定义 中介者模式,定义了一个中介对象来封装一系列对象之间的交互关系.中介者使各个对象之间不需要显式地相互引用,从而使耦合性降低,而且可以独立地改变它们之间的交互行为.   中介者模式的结构 ...