热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

非归档下oracle的备份和恢复

数据库处于非归档状态,其联机日志循环覆盖使用,这意味着如果数据库需要进行介质恢复应用相关归档,又由于非归档导致归档文件不存在,那么此时数据库只能执行..

数据库处于非归档状态,其联机日志循环覆盖使用,这意味着如果数据库需要进行介质恢复应用相关归档,又由于非归档导致归档文件不存在,那么此时数据库只能执行..

数据库处于非归档状态,其联机日志循环覆盖使用,这意味着如果数据库需要进行介质恢复应用相关归档,又由于非归档导致归档文件不存在,那么此时数据库只能执行基于取消的恢复,回退整个数据库到上一次全备份状态。或者修改数据文件头部信息,来规避缺失归档。但不管怎么样都会丢失数据。

下面介绍非归档模式下几种常见故障处理方法。

一 非归档下的常用备份和恢复方法:

如何备份

Backing Up a Database in NOARCHIVELOG Mode You can only backup a database in NOARCHIVELOG mode when the database is closed and in a consistent state.

1 shutdown immediate

2 startup mount

3 backup database

如何恢复

注意 和归档模式下的恢复有如下不同点:

1 Only consistent backups can be used in restoring a database in NOARCHIVELOG mode.

2 Media recovery is not possible because no archived redo logs exist.

恢复步骤如下:

1 startup force mount;

2 restore database;

3 recover database until cancel;

4 alter database open resetlogs;

举例如下:

备份

SQL> archive log list;

Database log mode No Archive Mode

Automatic archival Disabled

Archive destination /oracle/archive

Oldest online log sequence 1

Current log sequence 2

RMAN> shutdown immediate;

using target database control file instead of recovery catalog

database closed

database dismounted

Oracle instance shut down

RMAN> startup mount;

connected to target database (not started)

Oracle instance started

database mounted

Total System Global Area 1252663296 bytes

Fixed Size 2226072 bytes

Variable Size 1006635112 bytes

Database Buffers 234881024 bytes

Redo Buffers 8921088 bytes

RMAN> backup database;

Starting backup at 2013-02-03 13:26:36

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=63 device type=DISK

allocated channel: ORA_DISK_2

channel ORA_DISK_2: SID=129 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00004 name=/backup/users01.dbf

input datafile file number=00003 name=/oracle/CRM/undotbs3.dbf

input datafile file number=00006 name=/oracle/CRM/erp.dbf

input datafile file number=00007 name=/oracle/CRM/user01.dbf

channel ORA_DISK_1: starting piece 1 at 2013-02-03 13:26:38

channel ORA_DISK_2: starting full datafile backup set

channel ORA_DISK_2: specifying datafile(s) in backup set

input datafile file number=00001 name=/oracle/CRM/system01.dbf

input datafile file number=00002 name=/oracle/CRM/sysaux01.dbf

input datafile file number=00005 name=/oracle/CRM/pos.dbf

channel ORA_DISK_2: starting piece 1 at 2013-02-03 13:26:39

channel ORA_DISK_1: finished piece 1 at 2013-02-03 13:29:36

piece handle=/backup/20130203_fro11v4d_1_1 tag=TAG20130203T132637 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:02:59

channel ORA_DISK_2: finished piece 1 at 2013-02-03 13:29:38

piece handle=/backup/20130203_fso11v4e_1_1 tag=TAG20130203T132637 comment=NONE

channel ORA_DISK_2: backup set complete, elapsed time: 00:02:59

Finished backup at 2013-02-03 13:29:38

Starting Control File and SPFILE Autobackup at 2013-02-03 13:29:38

piece handle=/backup/c-3599153036-20130203-00 comment=NONE

Finished Control File and SPFILE Autobackup at 2013-02-03 13:29:41

恢复

RMAN> startup force mount;

Oracle instance started

database mounted

Total System Global Area 1252663296 bytes

Fixed Size 2226072 bytes

Variable Size 1006635112 bytes

Database Buffers 234881024 bytes

Redo Buffers 8921088 bytes

RMAN> restore database;

Starting restore at 2013-02-03 16:13:04

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=63 device type=DISK

allocated channel: ORA_DISK_2

channel ORA_DISK_2: SID=129 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 00003 to /oracle/CRM/undotbs3.dbf

channel ORA_DISK_1: restoring datafile 00004 to /backup/users01.dbf

channel ORA_DISK_1: restoring datafile 00006 to /oracle/CRM/erp.dbf

channel ORA_DISK_1: restoring datafile 00007 to /oracle/CRM/user01.dbf

channel ORA_DISK_1: reading from backup piece /backup/20130203_fro11v4d_1_1

channel ORA_DISK_2: starting datafile backup set restore

channel ORA_DISK_2: specifying datafile(s) to restore from backup set

channel ORA_DISK_2: restoring datafile 00001 to /oracle/CRM/system01.dbf

channel ORA_DISK_2: restoring datafile 00002 to /oracle/CRM/sysaux01.dbf

channel ORA_DISK_2: restoring datafile 00005 to /oracle/CRM/pos.dbf

channel ORA_DISK_2: reading from backup piece /backup/20130203_fso11v4e_1_1

channel ORA_DISK_1: piece handle=/backup/20130203_fro11v4d_1_1 tag=TAG20130203T132637

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:04:09

channel ORA_DISK_2: piece handle=/backup/20130203_fso11v4e_1_1 tag=TAG20130203T132637

channel ORA_DISK_2: restored backup piece 1

channel ORA_DISK_2: restore complete, elapsed time: 00:04:11

Finished restore at 2013-02-03 16:17:17

RMAN> host;

[oracle@oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Sun Feb 3 16:27:12 2013

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> recover database until cancel;

ORA-00279: change 2942346 generated at 02/03/2013 13:26:11 needed for thread 1

ORA-00289: suggestion : /oracle/archive/1_2_806264057.dbf

ORA-00280: change 2942346 for thread 1 is in sequence #2

Specify log: {=suggested | filename | AUTO | CANCEL}

cancel

Media recovery cancelled.

SQL> alter database open resetlogs;

Database altered.

SQL> select group#,archived,sequence#,status from v$Log;

GROUP# ARC SEQUENCE# STATUS

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

1 NO 1 CURRENT

2 YES 0 UNUSED

3 YES 0 UNUSED

4 YES 0 UNUSED

二 非归档无备份,单个文件丢失造成数据库无法打开

第一种方法:

SQL> startup ;

ORACLE instance started.

Total System Global Area 1252663296 bytes

Fixed Size 2226072 bytes

Variable Size 1006635112 bytes

Database Buffers 234881024 bytes

Redo Buffers 8921088 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 8 - see DBWR trace file

ORA-01110: data file 8: '/oracle/CRM/test.dbf'

SQL> alter database datafile 8 offline drop;

Database altered.

SQL> alter database open;

Database altered.

SQL> alter database create datafile '/oracle/CRM/test.dbf';

Database altered.

SQL> select hxfil,fhscn,fhrba_seq from x$kcvfh;

HXFIL FHSCN FHRBA_SEQ

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

1 3078640 37

2 3078640 37

3 3078640 37

4 3078640 37

5 3078640 37

6 3078640 37

7 3078640 37

8 3077425 31

8 rows selected.

SQL> select group#,archived,sequence#,status from v$log;

GROUP# ARC SEQUENCE# STATUS

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

1 NO 37 CURRENT

2 NO 34 INACTIVE

3 NO 35 INACTIVE

4 NO 36 INACTIVE

由于是非归档则31、32、33号归档丢失,完全恢复已经不可能,只能执行基于取消的恢复,回退整个数据库。

SQL> startup force mount;

ORACLE instance started.

Total System Global Area 1252663296 bytes

Fixed Size 2226072 bytes

Variable Size 1006635112 bytes

Database Buffers 234881024 bytes

Redo Buffers 8921088 bytes

Database mounted.

SQL> recover database until cancel;

ORA-00279: change 3078640 generated at 02/20/2013 16:44:47 needed for thread 1

ORA-00289: suggestion : /oracle/archive/1_37_806501358.dbf

ORA-00280: change 3078640 for thread 1 is in sequence #37

Specify log: {=suggested | filename | AUTO | CANCEL}

cancel

ORA-10879: error signaled in parallel recovery slave

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below

ORA-01194: file 1 needs more recovery to be consistent

ORA-01110: data file 1: '/oracle/CRM/system01.dbf

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01194: file 1 needs more recovery to be consistent

ORA-01110: data file 1: '/oracle/CRM/system01.dbf'

SQL> alter system set "_allow_resetlogs_corruption"=true scope=spfile;

System altered.

SQL> startup force mount;

ORACLE instance started.

Total System Global Area 1252663296 bytes

Fixed Size 2226072 bytes

Variable Size 1006635112 bytes

Database Buffers 234881024 bytes

Redo Buffers 8921088 bytes

Database mounted.

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01092: ORACLE instance terminated. Disconnection forced

ORA-00600: internal error code, arguments: [2662], [0], [3078648], [0],

[3078665], [4194432], [], [], [], [], [], []

Process ID: 5678

Session ID: 191 Serial number: 3

这里通过重启规避ora-600 [2662]错误

SQL> startup;

ORACLE instance started.

Total System Global Area 1252663296 bytes

Fixed Size 2226072 bytes

Variable Size 1006635112 bytes

Database Buffers 234881024 bytes

Redo Buffers 8921088 bytes

Database mounted.

Database opened.

第二种方法

SQL> startup

ORACLE instance started.

Total System Global Area 1252663296 bytes

Fixed Size 2226072 bytes

Variable Size 1006635112 bytes

Database Buffers 234881024 bytes

Redo Buffers 8921088 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 8 - see DBWR trace file

ORA-01110: data file 8: '/oracle/CRM/test.dbf'

SQL> alter database create datafile '/oracle/CRM/test.dbf';

Database altered.

注意,当我们用 alter database create datafile 创建数据文件时,香港空间,数据文件头部scn以及rba.seq号均取自于该数据文件创建时控制文件中记录的scn和rba.seq号,如下:

DATA FILE #8:

name #14: /oracle/CRM/test.dbf

Creation Checkpointed at scn: 0x0000.002d4053 02/03/2013 17:02:59

thread:1 rba:(0x2.20d.10)

0x2d4053准换为10进制为2965587

rba:(0x2.20d.10)则表示seq号为2.块525.偏移量10

SQL> select hxfil,fhscn,fhrba_seq,fhrba_bno from x$kcvfh;

HXFIL FHSCN FHRBA_SEQ FHRBA_BNO

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

推荐阅读
  • ubuntu用sqoop将数据从hive导入mysql时,命令: ... [详细]
  • 本文详细介绍了在ASP.NET中获取插入记录的ID的几种方法,包括使用SCOPE_IDENTITY()和IDENT_CURRENT()函数,以及通过ExecuteReader方法执行SQL语句获取ID的步骤。同时,还提供了使用这些方法的示例代码和注意事项。对于需要获取表中最后一个插入操作所产生的ID或马上使用刚插入的新记录ID的开发者来说,本文提供了一些有用的技巧和建议。 ... [详细]
  • 本文介绍了adg架构设置在企业数据治理中的应用。随着信息技术的发展,企业IT系统的快速发展使得数据成为企业业务增长的新动力,但同时也带来了数据冗余、数据难发现、效率低下、资源消耗等问题。本文讨论了企业面临的几类尖锐问题,并提出了解决方案,包括确保库表结构与系统测试版本一致、避免数据冗余、快速定位问题等。此外,本文还探讨了adg架构在大版本升级、上云服务和微服务治理方面的应用。通过本文的介绍,读者可以了解到adg架构设置的重要性及其在企业数据治理中的应用。 ... [详细]
  • 在说Hibernate映射前,我们先来了解下对象关系映射ORM。ORM的实现思想就是将关系数据库中表的数据映射成对象,以对象的形式展现。这样开发人员就可以把对数据库的操作转化为对 ... [详细]
  • 本文介绍了使用postman进行接口测试的方法,以测试用户管理模块为例。首先需要下载并安装postman,然后创建基本的请求并填写用户名密码进行登录测试。接下来可以进行用户查询和新增的测试。在新增时,可以进行异常测试,包括用户名超长和输入特殊字符的情况。通过测试发现后台没有对参数长度和特殊字符进行检查和过滤。 ... [详细]
  • 本文详细介绍了MysqlDump和mysqldump进行全库备份的相关知识,包括备份命令的使用方法、my.cnf配置文件的设置、binlog日志的位置指定、增量恢复的方式以及适用于innodb引擎和myisam引擎的备份方法。对于需要进行数据库备份的用户来说,本文提供了一些有价值的参考内容。 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • 本文由编程笔记小编整理,介绍了PHP中的MySQL函数库及其常用函数,包括mysql_connect、mysql_error、mysql_select_db、mysql_query、mysql_affected_row、mysql_close等。希望对读者有一定的参考价值。 ... [详细]
  • 本文介绍了Oracle数据库中tnsnames.ora文件的作用和配置方法。tnsnames.ora文件在数据库启动过程中会被读取,用于解析LOCAL_LISTENER,并且与侦听无关。文章还提供了配置LOCAL_LISTENER和1522端口的示例,并展示了listener.ora文件的内容。 ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • Java String与StringBuffer的区别及其应用场景
    本文主要介绍了Java中String和StringBuffer的区别,String是不可变的,而StringBuffer是可变的。StringBuffer在进行字符串处理时不生成新的对象,内存使用上要优于String类。因此,在需要频繁对字符串进行修改的情况下,使用StringBuffer更加适合。同时,文章还介绍了String和StringBuffer的应用场景。 ... [详细]
  • Oracle分析函数first_value()和last_value()的用法及原理
    本文介绍了Oracle分析函数first_value()和last_value()的用法和原理,以及在查询销售记录日期和部门中的应用。通过示例和解释,详细说明了first_value()和last_value()的功能和不同之处。同时,对于last_value()的结果出现不一样的情况进行了解释,并提供了理解last_value()默认统计范围的方法。该文对于使用Oracle分析函数的开发人员和数据库管理员具有参考价值。 ... [详细]
  • MyBatis错题分析解析及注意事项
    本文对MyBatis的错题进行了分析和解析,同时介绍了使用MyBatis时需要注意的一些事项,如resultMap的使用、SqlSession和SqlSessionFactory的获取方式、动态SQL中的else元素和when元素的使用、resource属性和url属性的配置方式、typeAliases的使用方法等。同时还指出了在属性名与查询字段名不一致时需要使用resultMap进行结果映射,而不能使用resultType。 ... [详细]
  • 前景:当UI一个查询条件为多项选择,或录入多个条件的时候,比如查询所有名称里面包含以下动态条件,需要模糊查询里面每一项时比如是这样一个数组条件:newstring[]{兴业银行, ... [详细]
  • Oracle10g备份导入的方法及注意事项
    本文介绍了使用Oracle10g进行备份导入的方法及相关注意事项,同时还介绍了2019年独角兽企业重金招聘Python工程师的标准。内容包括导出exp命令、删用户、创建数据库、授权等操作,以及导入imp命令的使用。详细介绍了导入时的参数设置,如full、ignore、buffer、commit、feedback等。转载来源于https://my.oschina.net/u/1767754/blog/377593。 ... [详细]
author-avatar
頃刻想詤嗳伱kYU-2001
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有