非归档下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: {<RET>=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