分类: Oracle
Oracle在非归档模式下RMAN的备份和恢复

1、Oracle数据库在非归档模式下的备份:

[oracle@dbnode1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on 星期三 8月 8 21:24:39 2018

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 and Data Mining options

SQL> archive log list;   #查看是否启用归档模式
Database log mode           No Archive Mode
Automatic archival           Disabled
Archive destination           /home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/arch
Oldest online log sequence     31004
Current log sequence           31006

登录到rman下:

[oracle@dbnode1 ~]$ rman target /   #登录rman

Recovery Manager: Release 11.2.0.3.0 - Production on 星期三 8月 8 21:29:02 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1351645873)
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   25120276480 bytes

Fixed Size                     2240016 bytes
Variable Size              19193135600 bytes
Database Buffers            5905580032 bytes
Redo Buffers                  19320832 bytes

开始全量备份

RMAN> run
2> {
3> allocate channel t1 type disk;
4>  backup database format '/bak/rmanbak/20180808/df_%t_%s_%p.bak';
5> }

allocated channel: t1
channel t1: SID=518 device type=DISK

Starting backup at 08-8月 -18
channel t1: starting full datafile backup set
channel t1: specifying datafile(s) in backup set
input datafile file number=00005 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_data01.dbf
input datafile file number=00003 name=/home/oracle/app/oracle/oradata/ORCL/undotbs01.dbf
input datafile file number=00010 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_index03.dbf
input datafile file number=00007 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_data03.dbf
input datafile file number=00008 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_index01.dbf
input datafile file number=00013 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_data01b.dbf
input datafile file number=00006 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_data02.dbf
input datafile file number=00001 name=/home/oracle/app/oracle/oradata/ORCL/system01.dbf
input datafile file number=00012 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_data01a.dbf
input datafile file number=00002 name=/home/oracle/app/oracle/oradata/ORCL/sysaux01.dbf
input datafile file number=00009 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_index02.dbf
input datafile file number=00011 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/IUFO.dbf
input datafile file number=00004 name=/home/oracle/app/oracle/oradata/ORCL/users01.dbf
channel t1: starting piece 1 at 08-8月 -18
channel t1: finished piece 1 at 08-8月 -18
piece handle=/bak/rmanbak/20180808/df_983655480_2_1.bak tag=TAG20180808T213800 comment=NONE
channel t1: backup set complete, elapsed time: 00:18:16
channel t1: starting full datafile backup set
channel t1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel t1: starting piece 1 at 08-8月 -18
channel t1: finished piece 1 at 08-8月 -18
piece handle=/bak/rmanbak/20180808/df_983656576_3_1.bak tag=TAG20180808T213800 comment=NONE
channel t1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-8月 -18
released channel: t1
RMAN> alter database open;   #打开数据库

database opened

RMAN> 

2、非归档模式数据库恢复

RMAN> shutdown immediate    #停止数据库

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 535662592 bytes

Fixed Size 1375792 bytes
Variable Size 411042256 bytes
Database Buffers 117440512 bytes
Redo Buffers 5804032 bytes
RMAN> restore database;    #恢复数据库

Starting restore at 03-NOV-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=133 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 D:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF
channel ORA_DISK_1: restoring datafile 00002 to D:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF
channel ORA_DISK_1: restoring datafile 00004 to D:\ORACLE\ORADATA\ORCL\USERS01.DBF
channel ORA_DISK_1: restoring datafile 00005 to D:\ORACLE\ORADATA\ORCL\TEST01.DBF channel ORA_DISK_1: restoring datafile 00006 to D:\ORACLE\ORADATA\ORCL\UNDOTBS02.DBF
channel ORA_DISK_1: reading from backup piece E:\RMAN_BAK\20111103\DF_766235030_5_1.BAK
channel ORA_DISK_1: piece handle=E:\RMAN_BAK\20111103\DF_766235030_5_1.BAK tag=TAG20111103T110349
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:35
Finished restore at 03-NOV-11
RMAN> recover database;   #恢复数据库

Starting recover at 03-NOV-18
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 3246 is already on disk as file D:\ORACLE\ORADATA\ORCL\REDO03.LOG archived log for thread 1 with sequence 3247 is already on disk as file D:\ORACLE\ORADATA\ORCL\REDO01.LOG
archived log file name=D:\ORACLE\ORADATA\ORCL\REDO03.LOG thread=1 sequence=3246
archived log file name=D:\ORACLE\ORADATA\ORCL\REDO01.LOG thread=1 sequence=3247
media recovery complete, elapsed time: 00:00:09
Finished recover at 03-NOV-18

打开数据库进行读/写操作时,会立即完成刚刚执行的还原。因此,先先在READ ONLY模式下打开数据库并查看某些数据,检查恢复操作是否符合预期结果。

RMAN> SQL 'ALTER DATABASE OPEN READ ONLY';

如对恢复结果感到满意,则使用RESETLOGS选项打开数据库

RMAN> alter database open resetlogs;   

database opened

VIA: https://blog.csdn.net/rlhua/article/details/12346829


相关博文:

发表新评论