oracle:rman恢复----通过增量备份来恢复

2023-04-23,,

试验计划:先rman进行一个0级备份,插入表相关数据,再进行level 1级增量备份,进行rman恢复

实验环境:归档模式下,oracle10.2.0.1

开始试验:

1. rman level 0级备份

RMAN> backup incremental level 0 database;

Starting backup at -DEC-
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno= name=/u01/app/oracle/product/10.2./db_2/oradata/orcl/system01.dbf
input datafile fno= name=/u01/app/oracle/product/10.2./db_2/oradata/orcl/sysaux01.dbf
input datafile fno= name=/u01/app/oracle/product/10.2./db_2/oradata/orcl/undotbs01.dbf
input datafile fno= name=/u01/app/oracle/product/10.2./db_2/oradata/orcl/yn.dbf
input datafile fno= name=/u01/app/oracle/product/10.2./db_2/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece at -DEC-
channel ORA_DISK_1: finished piece at -DEC-
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_12_02/o1_mf_nnnd0_TAG20131202T222739_99s66wc3_.bkp tag=TAG20131202T222739 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: ::
channel ORA_DISK_1: starting incremental level datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece at -DEC-
channel ORA_DISK_1: finished piece at -DEC-
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_12_02/o1_mf_ncsn0_TAG20131202T222739_99s6bvm4_.bkp tag=TAG20131202T222739 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: ::
Finished backup at -DEC-

2.插入相关表数据

SQL> select * from t1;

    ID NAME
---------- --------------------
first
second SQL> insert into t1 values(,'rman3'); row created. SQL> commit; Commit complete. SQL> insert into t1 values(,'rman4'); row created. SQL> commit; Commit complete. SQL> alter system switch logfile; System altered. SQL> alter system checkpoint; System altered. SQL>

3.rman level  0级备份

RMAN> backup incremental level 1 database;

Starting backup at -DEC-
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno= name=/u01/app/oracle/product/10.2./db_2/oradata/orcl/system01.dbf
input datafile fno= name=/u01/app/oracle/product/10.2./db_2/oradata/orcl/sysaux01.dbf
input datafile fno= name=/u01/app/oracle/product/10.2./db_2/oradata/orcl/undotbs01.dbf
input datafile fno= name=/u01/app/oracle/product/10.2./db_2/oradata/orcl/yn.dbf
input datafile fno= name=/u01/app/oracle/product/10.2./db_2/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece at -DEC-
channel ORA_DISK_1: finished piece at -DEC-
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_12_02/o1_mf_nnnd1_TAG20131202T223244_99s6jfdz_.bkp tag=TAG20131202T223244 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: ::
channel ORA_DISK_1: starting incremental level datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece at -DEC-
channel ORA_DISK_1: finished piece at -DEC-
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_12_02/o1_mf_ncsn1_TAG20131202T223244_99s6k6o1_.bkp tag=TAG20131202T223244 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: ::
Finished backup at -DEC- RMAN>

4.查看此时的备份文件、关闭数据库、重启数据库

[root@app 2013_12_02]# ll
?昏.
-rw-r----- oracle oinstall - : o1_mf_ncsn0_TAG20131202T222739_99s6bvm4_.bkp
-rw-r----- oracle oinstall - : o1_mf_ncsn1_TAG20131202T223244_99s6k6o1_.bkp
-rw-r----- oracle oinstall - : o1_mf_nnnd0_TAG20131202T222739_99s66wc3_.bkp
-rw-r----- oracle oinstall - : o1_mf_nnnd1_TAG20131202T223244_99s6jfdz_.bkp
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started. Total System Global Area bytes
Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes
Database mounted.

5.rman恢复

RMAN> run {
> allocate channel c1 type disk;
> restore database;
> recover database;
> sql 'alter database open';
> } allocated channel: c1
channel c1: sid= devtype=DISK Starting restore at -DEC- channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile to /u01/app/oracle/product/10.2./db_2/oradata/orcl/system01.dbf
restoring datafile to /u01/app/oracle/product/10.2./db_2/oradata/orcl/undotbs01.dbf
restoring datafile to /u01/app/oracle/product/10.2./db_2/oradata/orcl/sysaux01.dbf
restoring datafile to /u01/app/oracle/product/10.2./db_2/oradata/orcl/users01.dbf
restoring datafile to /u01/app/oracle/product/10.2./db_2/oradata/orcl/yn.dbf
channel c1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_12_02/o1_mf_nnnd0_TAG20131202T222739_99s66wc3_.bkp
channel c1: restored backup piece
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_12_02/o1_mf_nnnd0_TAG20131202T222739_99s66wc3_.bkp tag=TAG20131202T222739
channel c1: restore complete, elapsed time: ::
Finished restore at -DEC- Starting recover at -DEC-
channel c1: starting incremental datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
destination for restore of datafile : /u01/app/oracle/product/10.2./db_2/oradata/orcl/system01.dbf
destination for restore of datafile : /u01/app/oracle/product/10.2./db_2/oradata/orcl/undotbs01.dbf
destination for restore of datafile : /u01/app/oracle/product/10.2./db_2/oradata/orcl/sysaux01.dbf
destination for restore of datafile : /u01/app/oracle/product/10.2./db_2/oradata/orcl/users01.dbf
destination for restore of datafile : /u01/app/oracle/product/10.2./db_2/oradata/orcl/yn.dbf
channel c1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_12_02/o1_mf_nnnd1_TAG20131202T223244_99s6jfdz_.bkp
channel c1: restored backup piece
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_12_02/o1_mf_nnnd1_TAG20131202T223244_99s6jfdz_.bkp tag=TAG20131202T223244
channel c1: restore complete, elapsed time: :: starting media recovery
media recovery complete, elapsed time: :: Finished recover at -DEC- sql statement: alter database open
released channel: c1 RMAN>

6.查询数据

[oracle@app ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1. - Production on Mon Dec  :: 

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

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1. - 64bit Production
With the Partitioning, OLAP and Data Mining options SQL> select * from t1;
id name
---------------------
1 first
2 second
3 rman3
4 rman4

这里说一个我在进行此试验时,遇到的一个另外问题:

level 1级备份操作后,进行了drop table t1;我以为利用 level  0+level  1 恢复时,rman只恢复到我level  1备份处,t1表的4条数据还是存在的。

但,当我这样操作后,进行select × from t1 查询时,发现提示该表不存在。

后来仔细想了想,当我利用recover database时,数据库会自动读取redo或者归档文件来进行drop table t1操作的。

oracle:rman恢复----通过增量备份来恢复的相关教程结束。

《oracle:rman恢复----通过增量备份来恢复.doc》

下载本文的Word格式文档,以方便收藏与打印。