- SQL> select * from duanbb.t1;
-
- ID NAME
- ---------- --------------------------------------------------
- 1 111
复制代码 rman全备:
- RMAN> backup incremental level 0 database;
-
- Starting backup at 09-JUL-15
- using target database control file instead of recovery catalog
- allocated channel: ORA_DISK_1
- channel ORA_DISK_1: SID=63 device type=DISK
- channel ORA_DISK_1: starting incremental level 0 datafile backup set
- channel ORA_DISK_1: specifying datafile(s) in backup set
- input datafile file number=00002 name=/home/oracle11/app/oracle11/oradata/orcl/sysaux01.dbf
- input datafile file number=00001 name=/home/oracle11/app/oracle11/oradata/orcl/system01.dbf
- input datafile file number=00003 name=/home/oracle11/app/oracle11/oradata/orcl/undotbs01.dbf
- input datafile file number=00004 name=/home/oracle11/app/oracle11/oradata/orcl/users01.dbf
- channel ORA_DISK_1: starting piece 1 at 09-JUL-15
- channel ORA_DISK_1: finished piece 1 at 09-JUL-15
- piece handle=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/backupset/2015_07_09/o1_mf_nnnd0_TAG20150709T022947_bsw56w9p_.bkp tag=TAG20150709T022947 comment=NONE
- channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
- channel ORA_DISK_1: starting incremental level 0 datafile backup set
- channel ORA_DISK_1: specifying datafile(s) in backup set
- including current control file in backup set
- including current SPFILE in backup set
- channel ORA_DISK_1: starting piece 1 at 09-JUL-15
- channel ORA_DISK_1: finished piece 1 at 09-JUL-15
- piece handle=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/backupset/2015_07_09/o1_mf_ncsn0_TAG20150709T022947_bsw58yp1_.bkp tag=TAG20150709T022947 comment=NONE
- channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
- Finished backup at 09-JUL-15
复制代码 插入一条数据,进行日志备份:
- SQL> insert into duanbb.t1 values(2, '222');
-
- 1 row created.
-
- SQL> commit;
-
- Commit complete.
-
- SQL> alter system switch logfile;
-
- System altered.
-
- SQL> alter system checkpoint;
-
- SQL> select * from duanbb.t1;
-
- ID NAME
- ---------- --------------------------------------------------
- 1 111
- 2 222
复制代码- RMAN> backup archivelog all delete input;
-
- Starting backup at 09-JUL-15
- current log archived
- using channel ORA_DISK_1
- channel ORA_DISK_1: starting archived log backup set
- channel ORA_DISK_1: specifying archived log(s) in backup set
- input archived log thread=1 sequence=3 RECID=473 STAMP=884557194
- input archived log thread=1 sequence=4 RECID=474 STAMP=884559659
- input archived log thread=1 sequence=5 RECID=475 STAMP=884568650
- input archived log thread=1 sequence=6 RECID=476 STAMP=884571491
- input archived log thread=1 sequence=7 RECID=477 STAMP=884572546
- input archived log thread=1 sequence=8 RECID=478 STAMP=884572648
- channel ORA_DISK_1: starting piece 1 at 09-JUL-15
- channel ORA_DISK_1: finished piece 1 at 09-JUL-15
- piece handle=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/backupset/2015_07_09/o1_mf_annnn_TAG20150709T023728_bsw5o8w2_.bkp tag=TAG20150709T023728 comment=NONE
- channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
- channel ORA_DISK_1: deleting archived log(s)
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_08/o1_mf_1_3_bsvpl9xj_.arc RECID=473 STAMP=884557194
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_08/o1_mf_1_4_bsvrzcfm_.arc RECID=474 STAMP=884559659
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_09/o1_mf_1_5_bsw1rb2n_.arc RECID=475 STAMP=884568650
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_09/o1_mf_1_6_bsw4k3pw_.arc RECID=476 STAMP=884571491
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_09/o1_mf_1_7_bsw5l2jy_.arc RECID=477 STAMP=884572546
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_09/o1_mf_1_8_bsw5o8fs_.arc RECID=478 STAMP=884572648
- Finished backup at 09-JUL-15
复制代码 再次插入一条数据,备份日志:
- SQL> insert into duanbb.t1 values(3, '333');
-
- 1 row created.
-
- SQL> commit;
-
- Commit complete.
-
- SQL> alter system switch logfile;
-
- System altered.
-
- SQL> alter system checkpoint;
复制代码- RMAN> backup archivelog all delete input;
-
- Starting backup at 09-JUL-15
- current log archived
- using channel ORA_DISK_1
- channel ORA_DISK_1: starting archived log backup set
- channel ORA_DISK_1: specifying archived log(s) in backup set
- input archived log thread=1 sequence=9 RECID=479 STAMP=884572860
- input archived log thread=1 sequence=10 RECID=480 STAMP=884573073
- channel ORA_DISK_1: starting piece 1 at 09-JUL-15
- channel ORA_DISK_1: finished piece 1 at 09-JUL-15
- piece handle=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/backupset/2015_07_09/o1_mf_annnn_TAG20150709T024433_bsw62kjx_.bkp tag=TAG20150709T024433 comment=NONE
- channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
- channel ORA_DISK_1: deleting archived log(s)
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_09/o1_mf_1_9_bsw5vwjy_.arc RECID=479 STAMP=884572860
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_09/o1_mf_1_10_bsw62kbg_.arc RECID=480 STAMP=884573073
- Finished backup at 09-JUL-15
复制代码三次备份生成的文件:
第一次:全备
o1_mf_nnnd0_TAG20150709T022947_bsw56w9p_.bkp
o1_mf_ncsn0_TAG20150709T022947_bsw58yp1_.bkp
第二次:日志
o1_mf_annnn_TAG20150709T023728_bsw5o8w2_.bkp
第三次: 日志
o1_mf_annnn_TAG20150709T024433_bsw62kjx_.bkp
完全恢复(自动恢复到最新状态):
- RMAN> startup mount
-
- connected to target database (not started)
- Oracle instance started
- database mounted
-
- Total System Global Area 1221992448 bytes
-
- Fixed Size 1336176 bytes
- Variable Size 939527312 bytes
- Database Buffers 268435456 bytes
- Redo Buffers 12693504 bytes
复制代码- RMAN> run {
- 2> allocate channel c1 type disk;
- 3> restore database;
- 4> recover database;
- 5> sql 'alter database open';
- 6> }
-
- allocated channel: c1
- channel c1: SID=63 device type=DISK
-
- Starting restore at 09-JUL-15
-
- channel c1: starting datafile backup set restore
- channel c1: specifying datafile(s) to restore from backup set
- channel c1: restoring datafile 00001 to /home/oracle11/app/oracle11/oradata/orcl/system01.dbf
- channel c1: restoring datafile 00002 to /home/oracle11/app/oracle11/oradata/orcl/sysaux01.dbf
- channel c1: restoring datafile 00003 to /home/oracle11/app/oracle11/oradata/orcl/undotbs01.dbf
- channel c1: restoring datafile 00004 to /home/oracle11/app/oracle11/oradata/orcl/users01.dbf
- channel c1: reading from backup piece /home/oracle11/app/oracle11/flash_recovery_area/ORCL/backupset/2015_07_09/o1_mf_nnnd0_TAG20150709T022947_bsw56w9p_.bkp
- channel c1: piece handle=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/backupset/2015_07_09/o1_mf_nnnd0_TAG20150709T022947_bsw56w9p_.bkp tag=TAG20150709T022947
- channel c1: restored backup piece 1
- channel c1: restore complete, elapsed time: 00:00:36
- Finished restore at 09-JUL-15
-
- Starting recover at 09-JUL-15
-
- starting media recovery
-
- channel c1: starting archived log restore to default destination
- channel c1: restoring archived log
- archived log thread=1 sequence=7
- channel c1: restoring archived log
- archived log thread=1 sequence=8
- channel c1: reading from backup piece /home/oracle11/app/oracle11/flash_recovery_area/ORCL/backupset/2015_07_09/o1_mf_annnn_TAG20150709T023728_bsw5o8w2_.bkp
- channel c1: piece handle=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/backupset/2015_07_09/o1_mf_annnn_TAG20150709T023728_bsw5o8w2_.bkp tag=TAG20150709T023728
- channel c1: restored backup piece 1
- channel c1: restore complete, elapsed time: 00:00:01
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_09/o1_mf_1_7_bsw6gt1l_.arc thread=1 sequence=7
- channel default: deleting archived log(s)
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_09/o1_mf_1_7_bsw6gt1l_.arc RECID=482 STAMP=884573466
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_09/o1_mf_1_8_bsw6gt1s_.arc thread=1 sequence=8
- channel default: deleting archived log(s)
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_09/o1_mf_1_8_bsw6gt1s_.arc RECID=481 STAMP=884573466
- media recovery complete, elapsed time: 00:00:01
- channel c1: starting archived log restore to default destination
- channel c1: restoring archived log
- archived log thread=1 sequence=9
- channel c1: restoring archived log
- archived log thread=1 sequence=10
- channel c1: reading from backup piece /home/oracle11/app/oracle11/flash_recovery_area/ORCL/backupset/2015_07_09/o1_mf_annnn_TAG20150709T024433_bsw62kjx_.bkp
- channel c1: piece handle=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/backupset/2015_07_09/o1_mf_annnn_TAG20150709T024433_bsw62kjx_.bkp tag=TAG20150709T024433
- channel c1: restored backup piece 1
- channel c1: restore complete, elapsed time: 00:00:01
- channel default: deleting archived log(s)
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_09/o1_mf_1_9_bsw6gwgm_.arc RECID=483 STAMP=884573468
- channel default: deleting archived log(s)
- archived log file name=/home/oracle11/app/oracle11/flash_recovery_area/ORCL/archivelog/2015_07_09/o1_mf_1_10_bsw6gwgq_.arc RECID=484 STAMP=884573468
- Finished recover at 09-JUL-15
-
- sql statement: alter database open
- released channel: c1
复制代码 还原后的数据 :
- SQL> select * from duanbb.t1;
-
- ID NAME
- ---------- --------------------------------------------------
- 1 111
- 2 222
- 3 333
复制代码