傻瓜式实战Oracle10g RMAN之数据库备份和恢复

参考视频:

  vedios->[bbk1824]

数据库最重要的是数据,数据最重要的就是可靠性,不能丢失.

RMAN产生的一些备份信息,存储在控制文件当中.也就是说,在没有catalog的情况下,rman的备份信息是存放在controlfile当中的.

RMAN备份

非catalog方式:

  • 全备份
  • 0级增量备份
  • 1几增量备份

RMAN>backup incremental level 0 database;

RMAN> backup incremental level 0 database;

Starting backup at 2013/07/10 10:20:23
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=33 instance=devdb1 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=00007 name=+DATA/devdb/datafile/app_mis.275.820345293
input datafile file number=00001 name=+DATA/devdb/datafile/system.256.820154751
input datafile file number=00002 name=+DATA/devdb/datafile/sysaux.257.820154753
input datafile file number=00005 name=+DATA/devdb/datafile/example.264.820154917
input datafile file number=00003 name=+DATA/devdb/datafile/undotbs1.258.820154753
input datafile file number=00006 name=+DATA/devdb/datafile/undotbs2.265.820155189
input datafile file number=00004 name=+DATA/devdb/datafile/users.259.820154753
channel ORA_DISK_1: starting piece 1 at 2013/07/10 10:20:25
channel ORA_DISK_1: finished piece 1 at 2013/07/10 10:25:40
piece handle=+FLASH/devdb/backupset/2013_07_10/nnndn0_tag20130710t102024_0.351.820405229 tag=TAG20130710T102024 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:05:15
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 2013/07/10 10:25:44
channel ORA_DISK_1: finished piece 1 at 2013/07/10 10:25:47
piece handle=+FLASH/devdb/backupset/2013_07_10/ncsnn0_tag20130710t102024_0.352.820405545 tag=TAG20130710T102024 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 2013/07/10 10:25:47

RMAN> 
rman incremental level 0 backup database;

 

RMAN> list backupset;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
1       Full    17.67M     DISK        00:01:08     2013/07/07 18:02:42
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_04oe5mru_1_1.bak
  Control File Included: Ckp SCN: 1211000      Ckp time: 2013/07/07 18:01:34

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
2       Full    80.00K     DISK        00:00:11     2013/07/07 18:03:08
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_05oe5muh_1_1.bak
  SPFILE Included: Modification time: 2013/07/07 17:28:58
  SPFILE db_unique_name: DEVDB

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
3       Full    82.26M     DISK        00:01:41     2013/07/07 18:03:12
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_03oe5mrr_1_1.bak
  List of Datafiles in backup set 3
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  3       Full 1210998    2013/07/07 18:01:34 +DATA/devdb/datafile/undotbs1.258.820154753
  5       Full 1210998    2013/07/07 18:01:34 +DATA/devdb/datafile/example.264.820154917

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
4       Full    437.32M    DISK        00:01:57     2013/07/07 18:03:26
        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_02oe5mrp_1_1.bak
  List of Datafiles in backup set 4
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  2       Full 1210078    2013/07/07 18:01:30 +DATA/devdb/datafile/sysaux.257.820154753
  4       Full 1210078    2013/07/07 18:01:30 +DATA/devdb/datafile/users.259.820154753

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
5       Full    625.63M    DISK        00:02:04     2013/07/07 18:03:32
        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_01oe5mro_1_1.bak
  List of Datafiles in backup set 5
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 1210004    2013/07/07 18:01:29 +DATA/devdb/datafile/system.256.820154751
  6       Full 1210004    2013/07/07 18:01:29 +DATA/devdb/datafile/undotbs2.265.820155189

BS Key  Size       Device Type Elapsed Time Completion Time    
------- ---------- ----------- ------------ -------------------
6       95.33M     DISK        00:00:04     2013/07/07 18:04:31
        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180427
        Piece Name: /rman_backup/ARC_06oe5n1b_1_1.bak

  List of Archived Logs in backup set 6
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    6       1085528    2013/07/07 12:54:49 1155519    2013/07/07 16:32:19
  1    7       1155519    2013/07/07 16:32:19 1155521    2013/07/07 16:32:26
  1    8       1155521    2013/07/07 16:32:26 1177787    2013/07/07 16:41:46
  1    9       1177787    2013/07/07 16:41:46 1177790    2013/07/07 16:41:48
  1    10      1200276    2013/07/07 17:28:56 1211333    2013/07/07 18:04:23
  2    1       1087789    2013/07/07 12:56:23 1087803    2013/07/07 12:56:24
  2    2       1088328    2013/07/07 12:57:15 1134543    2013/07/07 13:29:01
  2    3       1134543    2013/07/07 13:29:01 1155490    2013/07/07 14:05:46
  2    4       1155517    2013/07/07 16:32:19 1177794    2013/07/07 16:41:50
  2    5       1177794    2013/07/07 16:41:50 1199675    2013/07/07 17:25:54
  2    6       1199675    2013/07/07 17:25:54 1211337    2013/07/07 18:04:13

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
7       Full    17.67M     DISK        00:00:03     2013/07/07 18:07:03
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180700
        Piece Name: /rman_backup/standby_07oe5n64_1_1.ctl
  Standby Control File Included: Ckp SCN: 1211612      Ckp time: 2013/07/07 18:07:00

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
8       Incr 0  1.17G      DISK        00:05:15     2013/07/10 10:25:39
        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20130710T102024
        Piece Name: +FLASH/devdb/backupset/2013_07_10/nnndn0_tag20130710t102024_0.351.820405229
  List of Datafiles in backup set 8
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/system.256.820154751
  2    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/sysaux.257.820154753
  3    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/undotbs1.258.820154753
  4    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/users.259.820154753
  5    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/example.264.820154917
  6    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/undotbs2.265.820155189
  7    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/app_mis.275.820345293

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
9       Incr 0  17.92M     DISK        00:00:05     2013/07/10 10:25:46
        BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: TAG20130710T102024
        Piece Name: +FLASH/devdb/backupset/2013_07_10/ncsnn0_tag20130710t102024_0.352.820405545
  SPFILE Included: Modification time: 2013/07/10 10:16:13
  SPFILE db_unique_name: DEVDB
  Control File Included: Ckp SCN: 1815489      Ckp time: 2013/07/10 10:25:40

RMAN> 
view backupset info

 

RMAN>backup incremental level 1 database;

RMAN> backup incremental level 1 database;

Starting backup at 2013/07/10 10:28:52
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=+DATA/devdb/datafile/app_mis.275.820345293
input datafile file number=00001 name=+DATA/devdb/datafile/system.256.820154751
input datafile file number=00002 name=+DATA/devdb/datafile/sysaux.257.820154753
input datafile file number=00005 name=+DATA/devdb/datafile/example.264.820154917
input datafile file number=00003 name=+DATA/devdb/datafile/undotbs1.258.820154753
input datafile file number=00006 name=+DATA/devdb/datafile/undotbs2.265.820155189
input datafile file number=00004 name=+DATA/devdb/datafile/users.259.820154753
channel ORA_DISK_1: starting piece 1 at 2013/07/10 10:28:53
channel ORA_DISK_1: finished piece 1 at 2013/07/10 10:32:48
piece handle=+FLASH/devdb/backupset/2013_07_10/nnndn1_tag20130710t102852_0.353.820405735 tag=TAG20130710T102852 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:03:55
channel ORA_DISK_1: starting incremental level 1 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 2013/07/10 10:32:51
channel ORA_DISK_1: finished piece 1 at 2013/07/10 10:32:54
piece handle=+FLASH/devdb/backupset/2013_07_10/ncsnn1_tag20130710t102852_0.354.820405971 tag=TAG20130710T102852 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 2013/07/10 10:32:54

RMAN> 
rman incremental level 1 backup database;

 

RMAN> list backupset;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
1       Full    17.67M     DISK        00:01:08     2013/07/07 18:02:42
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_04oe5mru_1_1.bak
  Control File Included: Ckp SCN: 1211000      Ckp time: 2013/07/07 18:01:34

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
2       Full    80.00K     DISK        00:00:11     2013/07/07 18:03:08
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_05oe5muh_1_1.bak
  SPFILE Included: Modification time: 2013/07/07 17:28:58
  SPFILE db_unique_name: DEVDB

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
3       Full    82.26M     DISK        00:01:41     2013/07/07 18:03:12
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_03oe5mrr_1_1.bak
  List of Datafiles in backup set 3
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  3       Full 1210998    2013/07/07 18:01:34 +DATA/devdb/datafile/undotbs1.258.820154753
  5       Full 1210998    2013/07/07 18:01:34 +DATA/devdb/datafile/example.264.820154917

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
4       Full    437.32M    DISK        00:01:57     2013/07/07 18:03:26
        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_02oe5mrp_1_1.bak
  List of Datafiles in backup set 4
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  2       Full 1210078    2013/07/07 18:01:30 +DATA/devdb/datafile/sysaux.257.820154753
  4       Full 1210078    2013/07/07 18:01:30 +DATA/devdb/datafile/users.259.820154753

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
5       Full    625.63M    DISK        00:02:04     2013/07/07 18:03:32
        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_01oe5mro_1_1.bak
  List of Datafiles in backup set 5
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 1210004    2013/07/07 18:01:29 +DATA/devdb/datafile/system.256.820154751
  6       Full 1210004    2013/07/07 18:01:29 +DATA/devdb/datafile/undotbs2.265.820155189

BS Key  Size       Device Type Elapsed Time Completion Time    
------- ---------- ----------- ------------ -------------------
6       95.33M     DISK        00:00:04     2013/07/07 18:04:31
        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180427
        Piece Name: /rman_backup/ARC_06oe5n1b_1_1.bak

  List of Archived Logs in backup set 6
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    6       1085528    2013/07/07 12:54:49 1155519    2013/07/07 16:32:19
  1    7       1155519    2013/07/07 16:32:19 1155521    2013/07/07 16:32:26
  1    8       1155521    2013/07/07 16:32:26 1177787    2013/07/07 16:41:46
  1    9       1177787    2013/07/07 16:41:46 1177790    2013/07/07 16:41:48
  1    10      1200276    2013/07/07 17:28:56 1211333    2013/07/07 18:04:23
  2    1       1087789    2013/07/07 12:56:23 1087803    2013/07/07 12:56:24
  2    2       1088328    2013/07/07 12:57:15 1134543    2013/07/07 13:29:01
  2    3       1134543    2013/07/07 13:29:01 1155490    2013/07/07 14:05:46
  2    4       1155517    2013/07/07 16:32:19 1177794    2013/07/07 16:41:50
  2    5       1177794    2013/07/07 16:41:50 1199675    2013/07/07 17:25:54
  2    6       1199675    2013/07/07 17:25:54 1211337    2013/07/07 18:04:13

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
7       Full    17.67M     DISK        00:00:03     2013/07/07 18:07:03
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180700
        Piece Name: /rman_backup/standby_07oe5n64_1_1.ctl
  Standby Control File Included: Ckp SCN: 1211612      Ckp time: 2013/07/07 18:07:00

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
8       Incr 0  1.17G      DISK        00:05:15     2013/07/10 10:25:39
        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20130710T102024
        Piece Name: +FLASH/devdb/backupset/2013_07_10/nnndn0_tag20130710t102024_0.351.820405229
  List of Datafiles in backup set 8
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/system.256.820154751
  2    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/sysaux.257.820154753
  3    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/undotbs1.258.820154753
  4    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/users.259.820154753
  5    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/example.264.820154917
  6    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/undotbs2.265.820155189
  7    0  Incr 1814648    2013/07/10 10:20:25 +DATA/devdb/datafile/app_mis.275.820345293

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
9       Incr 0  17.92M     DISK        00:00:05     2013/07/10 10:25:46
        BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: TAG20130710T102024
        Piece Name: +FLASH/devdb/backupset/2013_07_10/ncsnn0_tag20130710t102024_0.352.820405545
  SPFILE Included: Modification time: 2013/07/10 10:16:13
  SPFILE db_unique_name: DEVDB
  Control File Included: Ckp SCN: 1815489      Ckp time: 2013/07/10 10:25:40

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
10      Incr 1  1.23M      DISK        00:03:51     2013/07/10 10:32:44
        BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: TAG20130710T102852
        Piece Name: +FLASH/devdb/backupset/2013_07_10/nnndn1_tag20130710t102852_0.353.820405735
  List of Datafiles in backup set 10
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1    1  Incr 1815958    2013/07/10 10:28:53 +DATA/devdb/datafile/system.256.820154751
  2    1  Incr 1815958    2013/07/10 10:28:53 +DATA/devdb/datafile/sysaux.257.820154753
  3    1  Incr 1815958    2013/07/10 10:28:53 +DATA/devdb/datafile/undotbs1.258.820154753
  4    1  Incr 1815958    2013/07/10 10:28:53 +DATA/devdb/datafile/users.259.820154753
  5    1  Incr 1815958    2013/07/10 10:28:53 +DATA/devdb/datafile/example.264.820154917
  6    1  Incr 1815958    2013/07/10 10:28:53 +DATA/devdb/datafile/undotbs2.265.820155189
  7    1  Incr 1815958    2013/07/10 10:28:53 +DATA/devdb/datafile/app_mis.275.820345293

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
11      Incr 1  17.92M     DISK        00:00:04     2013/07/10 10:32:52
        BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20130710T102852
        Piece Name: +FLASH/devdb/backupset/2013_07_10/ncsnn1_tag20130710t102852_0.354.820405971
  SPFILE Included: Modification time: 2013/07/10 10:16:13
  SPFILE db_unique_name: DEVDB
  Control File Included: Ckp SCN: 1816583      Ckp time: 2013/07/10 10:32:48

RMAN> 
view backupset info

 

RMAN备份常用命令

非catalog方式:

备份archivelog

 

rman target /
rman login cmd
node1-> rman target sys/Oracle168@phydb

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jul 10 10:41:27 2013

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

connected to target database: DEVDB (DBID=724884837)

RMAN>
View Code

 

 

RMAN> list backupset;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
1       Full    17.67M     DISK        00:01:08     2013/07/07 18:02:42
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_04oe5mru_1_1.bak
  Control File Included: Ckp SCN: 1211000      Ckp time: 2013/07/07 18:01:34

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
2       Full    80.00K     DISK        00:00:11     2013/07/07 18:03:08
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_05oe5muh_1_1.bak
  SPFILE Included: Modification time: 2013/07/07 17:28:58
  SPFILE db_unique_name: DEVDB

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
3       Full    82.26M     DISK        00:01:41     2013/07/07 18:03:12
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_03oe5mrr_1_1.bak
  List of Datafiles in backup set 3
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  3       Full 1210998    2013/07/07 18:01:34 +DATA/devdb/datafile/undotbs1.258.820154753
  5       Full 1210998    2013/07/07 18:01:34 +DATA/devdb/datafile/example.264.820154917

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
4       Full    437.32M    DISK        00:01:57     2013/07/07 18:03:26
        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_02oe5mrp_1_1.bak
  List of Datafiles in backup set 4
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  2       Full 1210078    2013/07/07 18:01:30 +DATA/devdb/datafile/sysaux.257.820154753
  4       Full 1210078    2013/07/07 18:01:30 +DATA/devdb/datafile/users.259.820154753

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
5       Full    625.63M    DISK        00:02:04     2013/07/07 18:03:32
        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180127
        Piece Name: /rman_backup/Full_01oe5mro_1_1.bak
  List of Datafiles in backup set 5
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 1210004    2013/07/07 18:01:29 +DATA/devdb/datafile/system.256.820154751
  6       Full 1210004    2013/07/07 18:01:29 +DATA/devdb/datafile/undotbs2.265.820155189

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ -------------------
6       95.33M     DISK        00:00:04     2013/07/07 18:04:31
        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180427
        Piece Name: /rman_backup/ARC_06oe5n1b_1_1.bak

  List of Archived Logs in backup set 6
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    6       1085528    2013/07/07 12:54:49 1155519    2013/07/07 16:32:19
  1    7       1155519    2013/07/07 16:32:19 1155521    2013/07/07 16:32:26
  1    8       1155521    2013/07/07 16:32:26 1177787    2013/07/07 16:41:46
  1    9       1177787    2013/07/07 16:41:46 1177790    2013/07/07 16:41:48
  1    10      1200276    2013/07/07 17:28:56 1211333    2013/07/07 18:04:23
  2    1       1087789    2013/07/07 12:56:23 1087803    2013/07/07 12:56:24
  2    2       1088328    2013/07/07 12:57:15 1134543    2013/07/07 13:29:01
  2    3       1134543    2013/07/07 13:29:01 1155490    2013/07/07 14:05:46
  2    4       1155517    2013/07/07 16:32:19 1177794    2013/07/07 16:41:50
  2    5       1177794    2013/07/07 16:41:50 1199675    2013/07/07 17:25:54
  2    6       1199675    2013/07/07 17:25:54 1211337    2013/07/07 18:04:13

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
7       Full    17.67M     DISK        00:00:03     2013/07/07 18:07:03
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20130707T180700
        Piece Name: /rman_backup/standby_07oe5n64_1_1.ctl
  Standby Control File Included: Ckp SCN: 1211612      Ckp time: 2013/07/07 18:07:00
view backup information
RMAN> report need backup;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of files with less than 1 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
7    0     +DATA/devdb/datafile/app_mis.275.820345293
report need backup
RMAN> show all;

RMAN configuration parameters for database with db_unique_name DEVDB are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_devdb1.f'; # default

RMAN>
view configuration information
backup database plus archivelog delete input;
backup datafile,controlfile,archivelog file,parameter file;

 

RMAN> report schema;

Report of database schema for database with db_unique_name DEVDB

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    720      SYSTEM               ***     +DATA/devdb/datafile/system.256.820154751
2    660      SYSAUX               ***     +DATA/devdb/datafile/sysaux.257.820154753
3    110      UNDOTBS1             ***     +DATA/devdb/datafile/undotbs1.258.820154753
4    5        USERS                ***     +DATA/devdb/datafile/users.259.820154753
5    345      EXAMPLE              ***     +DATA/devdb/datafile/example.264.820154917
6    50       UNDOTBS2             ***     +DATA/devdb/datafile/undotbs2.265.820155189
7    1024     APP_MIS              ***     +DATA/devdb/datafile/app_mis.275.820345293

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    32       TEMP                 32767       +DATA/devdb/tempfile/temp.263.820154899

RMAN> 
在rman中查看表空间信息

 

RMAN> backup tablespace app_mis;

Starting backup at 2013/07/10 10:52:31
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=+DATA/devdb/datafile/app_mis.275.820345293
channel ORA_DISK_1: starting piece 1 at 2013/07/10 10:52:32
channel ORA_DISK_1: finished piece 1 at 2013/07/10 10:52:35
piece handle=+FLASH/devdb/backupset/2013_07_10/nnndf0_tag20130710t105231_0.355.820407153 tag=TAG20130710T105231 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 2013/07/10 10:52:35

RMAN> 
备份指定表空间文件

RMAN备份

  • 单命令

backup database;

  • 批命令 
RMAN>run{
    allocate channel cha1 type disk;
    backup
    format "/u01/rmanbak/full_%t"
    tag full-backup
    database;
    release channel cha1;
}
View Code
  • format

%c:备份片的拷贝数(从1开始编号)

%d:数据库名称

%D:位于该月中的天数(DD)

%M:位于该年中的月份(MM)

%F:一个基于DBID唯一的名称,这个格式的形式为c-xxx-YYYYMMDD-QQ,其中xxx为该数据库的DBID,YYYYMMDD为日期,QQ是一个1-256的序列

%n:数据库名称,并且会在右侧用x字符进行填充,使其保持长度为8;

%u:是一个由备份集编号和建立实际那压缩后组成的8字符名称。利用%u可以为每个备份集生成一个唯一的名称;

%p:表示备份集中备份片段的编号,从1开始编号;

%U:是%u_%p_%c的简写形式,利用它可以为每一个备份片段(即磁盘文件)生成一个唯一名称,这是最常用的命名方式;

%s:备份集的号;

%t:备份集时间戳;

%T:年月日格式(YYYYMMDD);

  • Channel通道

一个通道RMAN和目标数据库之间的一个连接,"allocate channel"命令在目标数据库启动一个服务器进程,同时必须定义服务器进程执行备份或者恢复操作使用的I/O类型通道控制命令可以用来:

  1. 控制RMAN使用的O/S资源
  2. 影响并行度
  3. 指定I/O带宽的限制值(设置limit read rate参数)
  4. 定义备份片大小的限制(设置limit kbytes)
  5. 指定当前打开文件的限制值(设置limit maxopenfiles)

RMAN备份

  • RMAN->Target Database
  • RMAN->Auxiliary Database
  • RMAN->Disk/SBT Tape
  • RMAN->Catalog Database or /Controlfile 

RMAN恢复 

  • spfile丢失
    1. startup nomount;
    2. set dbid 98123123;
    3. restore spfile from autobackup;
    4. shutdown immediate;
    5. set dbid 98123123;
    6. startup;

如何获取dbid?

[root@node1 ~]# su - oracle
node1-> rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Jul 11 10:20:36 2013

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

connected to target database: DEVDB (DBID=724884837)

RMAN> 
View Code
  • controfile丢失
    1. startup nomount;
    2. restore controfile from autobackup;
    3. alter database mount;
    4. recover database;
    5. alter database open resetlogs;

如果执行了alter database open resetlogs,建议最好执行一次全备(full database backup);

总结:spfile与controfile的丢失,都需要在nomount状态.

  • redolog file丢失

注意:redolog file丢失后,的恢复操作是在sqlplus里面执行的.

    1. shutdown immediate;
    2. startup mount;
    3. recover database until cancel;
    4. alter database open resetlogs;

如果执行了alter database open resetlogs,建议最好执行一次全备(full database backup);

controlfile与redolog file的丢失,在恢复完成以后,都需要执行一次alter database open resetlogs;

  • datafile丢失
    1. sql "alter database datafile 3 offline";
    2. restore datafile 3;
    3. recover datafile 3;
    4. sql "alter database datafile 3 online";
  • tablespace丢失
    1. sql "alter tablespace users offline";
    2. restore tablespace users;
    3. recover tablespace users;
    4. sql "alter tablespace users online";
  • no catalog 完全恢复

模拟场景:将oradata/目录下的所有内容都干掉.

    1. startup nomount;
    2. restore controfile from autobackup;
    3. alter database mount;
    4. restore database;

recover database until cancel;//这句的执行是在sqlplus里面 alter database open resetlogs;

上面执行到recover database unitl cancel的时候,会出错;因为Oracle是不允许在丢失online redo logfile的情况下就行Media恢复的.

解决办法:

    1. create pfile from spfile;
    2. 编辑pfile,在文件末尾添加*.allow_resetlogs_corruption='TRUE'
    3. shutdown immediate;
    4. startup pfile=$ORACLE_HOME/dbs/init$ORACLE_SID.ora mount
    5. alter database oppen resetlogs;

总结一下,只要看到alter database open resetlogs;基本上都可以说是不完全恢复.  

  • 基于时间点的恢复
run{

  set unitil time "to_date('07/01/02 15:00:00','mm/dd/yy hh24:mi:ss')"

  restore database;

  recover database;

  alter database open resetlogs;

}
View Code
  • 基于SCN的恢复
    1. statrtup mount;
    2. restore database UNTIL SCN 10000;
    3. recover database UNTIL SCN 10000;
    4. alter database open resetlogs;
  • 基于日志系列的恢复
    1. startup mount;
    2. restore database UNTIL SEQUENCE 100 thread 1;
    3. recover database UNTIL SEQUENCE 100 thread 1;
    4. alter database resetlogs; 

RMAN恢复

nocatalog方式下:

report schema->连接数据库查看schema信息.

list backup->查询controlfile里面的内容;

crosscheck backup->将controlfile中记录的备份记录索引信息与真实的物理文件信息进行比较.

delete->删除实际的物理文件与controfile里面的索引记录信息.

posted @ 2013-07-10 08:57  ArcerZhang  阅读(1486)  评论(0编辑  收藏  举报