一.RMAN 简介
详情见百度百科
二.查看属否开启归档模式
1: SQL> archive log list;
2: Database log mode Archive Mode
3: Automatic archival Enabled
4: Archive destination USE_DB_RECOVERY_FILE_DEST
5: Oldest online log sequence 127
6: Next log sequence to archive 129
7: Current log sequence 129
如果未开启归档模式,开启归档模式.
1: SQL> startup nomount ;
2: ORACLE instance started.
3:
4: Total System Global Area 608174080 bytes
5: Fixed Size 1220820 bytes
6: Variable Size 192941868 bytes
7: Database Buffers 406847488 bytes
8: Redo Buffers 7163904 bytes
9: SQL> alter database mount;
10:
11: Database altered.
12: SQL> alter database archivelog;
三.RMAN全备
1: $ rman target /
2:
3: Recovery Manager: Release 10.2.0.4.0 - Production on Tue Jun 21 19:30:52 2011
4:
5: Copyright (c) 1982, 2007, Oracle. All rights reserved.
6:
7: connected to target database: JCT (DBID=786899877)
8: -----
9: RMAN>; report schema;
列出数据库当前的schema
10:
11: using target database control file instead of recovery catalog
12: Report of database schema
13:
14: List of Permanent Datafiles
15: ===========================
16: File Size(MB) Tablespace RB segs Datafile Name
17: ---- -------- -------------------- ------- ------------------------
18: 1 490 SYSTEM *** /oradata/jct/jct/system01.dbf
19: 2 45 UNDOTBS1 *** /oradata/jct/jct/undotbs01.dbf
20: 3 400 SYSAUX *** /oradata/jct/jct/sysaux01.dbf
21: 4 22 USERS *** /oradata/jct/jct/users01.dbf
22: 5 800 DINFO *** /oradata/jct/jct/DINFO.dbf
23:
24: List of Temporary Files
25: =======================
26: File Size(MB) Tablespace Maxsize(MB) Tempfile Name
27: ---- -------- -------------------- ----------- --------------------
28: 1 20 TEMP 32767 /oradata/jct/jct/temp01.dbf
数据库全备
1: MAN>; run
2: 2>; {
3: 3>; allocate channel c1 type disk;
4: 4>; backup database
5: 5>; format '/oradata/bakup/db_%d_%s.bak';
6: 6>; }
7:
8: allocated channel: c1
9: channel c1: sid=123 devtype=DISK
10:
11: Starting backup at 21-JUN-11
12: channel c1: starting full datafile backupset
13: channel c1: specifying datafile(s) in backupset
14: input datafile fno=00005 name=/oradata/jct/jct/DINFO.dbf
15: input datafile fno=00001 name=/oradata/jct/jct/system01.dbf
16: input datafile fno=00003 name=/oradata/jct/jct/sysaux01.dbf
17: input datafile fno=00002 name=/oradata/jct/jct/undotbs01.dbf
18: input datafile fno=00004 name=/oradata/jct/jct/users01.dbf
19: channel c1: starting piece 1 at 21-JUN-11
20: channel c1: finished piece 1 at 21-JUN-11
21: piece handle=/oradata/bakup/db_JCT_1.bak tag=TAG20110621T203141 comment=NONE
22: channel c1: backup set complete, elapsed time: 00:00:28
23: channel c1: starting full datafile backupset
24: channel c1: specifying datafile(s) in backupset
25: including current control file in backupset
26: including current SPFILE in backupset
27: channel c1: starting piece 1 at 21-JUN-11
28: channel c1: finished piece 1 at 21-JUN-11
29: piece handle=/oradata/bakup/db_JCT_2.bak tag=TAG20110621T203141 comment=NONE
30: channel c1: backup set complete, elapsed time: 00:00:02
31: Finished backup at 21-JUN-11
32: released channel: c1
33:
查看备份数据
1: $ ls -l
2: total 1467256
3: -rw-r----- 1 oracle dba 745562112 Jun 21 20:32 db_JCT_1.bak
4: -rw-r----- 1 oracle dba 5668864 Jun 21 20:32 db_JCT_2.bak
增量备份
1: RMAN> backup incremental level 1 database;
2:
3: Starting backup at 21-JUN-11
4: using channel ORA_DISK_1
5: channel ORA_DISK_1: starting incremental level 1 datafile backupset
6: channel ORA_DISK_1: specifying datafile(s) in backupset
7: input datafile fno=00005 name=/oradata/jct/jct/DINFO.dbf
8: input datafile fno=00001 name=/oradata/jct/jct/system01.dbf
9: input datafile fno=00003 name=/oradata/jct/jct/sysaux01.dbf
10: input datafile fno=00002 name=/oradata/jct/jct/undotbs01.dbf
11: input datafile fno=00004 name=/oradata/jct/jct/users01.dbf
12: channel ORA_DISK_1: starting piece 1 at 21-JUN-11
13: channel ORA_DISK_1: finished piece 1 at 21-JUN-11
14: piece handle=/oracle/flash_recovery_area/JCT/backupset/2011_06_21/o1_mf_nnnd1_TAG20110621T203939_70148ddp_.bkp tag=TAG20110621T203939 comment=NONE
15: channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
16: channel ORA_DISK_1: starting incremental level 1 datafile backupset
17: channel ORA_DISK_1: specifying datafile(s) in backupset
18: including current control file in backupset
19: including current SPFILE in backupset
20: channel ORA_DISK_1: starting piece 1 at 21-JUN-11
21: channel ORA_DISK_1: finished piece 1 at 21-JUN-11
22: piece handle=/oracle/flash_recovery_area/JCT/backupset/2011_06_21/o1_mf_ncsn1_TAG20110621T203939_70149voy_.bkp tag=TAG20110621T203939 comment=NONE
23: channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
24: Finished backup at 21-JUN-11
列出备份文件
1: RMAN> list backup;
2:
3: using target database control file instead of recovery catalog
4:
5: List of Backup Sets
6: ===================
7:
8: BS Key Type LV Size Device Type Elapsed Time Completion Time
9: ------- ---- -- ---------- ----------- ------------ ---------------
10: 1 Full 711.02M DISK 00:00:24 21-JUN-11
11: BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20110621T203141
12: Piece Name: /oradata/bakup/db_JCT_1.bak
13: List of Datafiles in backup set 1
14: File LV Type Ckp SCN Ckp Time Name
15: ---- -- ---- ---------- --------- ----
16: 1 Full 4771360 21-JUN-11 /oradata/jct/jct/system01.dbf
17: 2 Full 4771360 21-JUN-11 /oradata/jct/jct/undotbs01.dbf
18: 3 Full 4771360 21-JUN-11 /oradata/jct/jct/sysaux01.dbf
19: 4 Full 4771360 21-JUN-11 /oradata/jct/jct/users01.dbf
20: 5 Full 4771360 21-JUN-11 /oradata/jct/jct/DINFO.dbf
21:
22: BS Key Type LV Size Device Type Elapsed Time Completion Time
23: ------- ---- -- ---------- ----------- ------------ ---------------
24: 2 Full 5.39M DISK 00:00:01 21-JUN-11
25: BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20110621T203141
26: Piece Name: /oradata/bakup/db_JCT_2.bak
27: Control File Included: Ckp SCN: 4771370 Ckp time: 21-JUN-11
28: SPFILE Included: Modification time: 09-MAY-11
29:
30: BS Key Type LV Size Device Type Elapsed Time Completion Time
31: ------- ---- -- ---------- ----------- ------------ ---------------
32: 3 Full 711.02M DISK 00:00:12 21-JUN-11
33: BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20110621T203312
34: Piece Name: /oracle/flash_recovery_area/JCT/backupset/2011_06_21/o1_mf_nnndf_TAG20110621T203312_7013w9hb_.bkp
35: List of Datafiles in backup set 3
36: File LV Type Ckp SCN Ckp Time Name
37: ---- -- ---- ---------- --------- ----
38: 1 Full 4771408 21-JUN-11 /oradata/jct/jct/system01.dbf
39: 2 Full 4771408 21-JUN-11 /oradata/jct/jct/undotbs01.dbf
40: 3 Full 4771408 21-JUN-11 /oradata/jct/jct/sysaux01.dbf
41: 4 Full 4771408 21-JUN-11 /oradata/jct/jct/users01.dbf
42: 5 Full 4771408 21-JUN-11 /oradata/jct/jct/DINFO.dbf
43:
44: BS Key Type LV Size Device Type Elapsed Time Completion Time
45: ------- ---- -- ---------- ----------- ------------ ---------------
46: 4 Full 5.39M DISK 00:00:00 21-JUN-11
47: BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20110621T203312
48: Piece Name: /oracle/flash_recovery_area/JCT/backupset/2011_06_21/o1_mf_ncsnf_TAG20110621T203312_7013wrk8_.bkp
49: Control File Included: Ckp SCN: 4771421 Ckp time: 21-JUN-11
50: SPFILE Included: Modification time: 09-MAY-11
51:
52: BS Key Type LV Size Device Type Elapsed Time Completion Time
53: ------- ---- -- ---------- ----------- ------------ ---------------
54: 5 Full 711.02M DISK 00:00:14 21-JUN-11
55: BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20110621T203512
56: Piece Name: /oracle/flash_recovery_area/JCT/backupset/2011_06_21/o1_mf_nnndf_TAG20110621T203512_701400pd_.bkp
57: List of Datafiles in backup set 5
58: File LV Type Ckp SCN Ckp Time Name
59: ---- -- ---- ---------- --------- ----
60: 1 Full 4771470 21-JUN-11 /oradata/jct/jct/system01.dbf
61: 2 Full 4771470 21-JUN-11 /oradata/jct/jct/undotbs01.dbf
62: 3 Full 4771470 21-JUN-11 /oradata/jct/jct/sysaux01.dbf
63: 4 Full 4771470 21-JUN-11 /oradata/jct/jct/users01.dbf
64: 5 Full 4771470 21-JUN-11 /oradata/jct/jct/DINFO.dbf
65:
66: BS Key Type LV Size Device Type Elapsed Time Completion Time
67: ------- ---- -- ---------- ----------- ------------ ---------------
68: 6 Full 5.39M DISK 00:00:02 21-JUN-11
69: BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20110621T203512
70: Piece Name: /oracle/flash_recovery_area/JCT/backupset/2011_06_21/o1_mf_ncsnf_TAG20110621T203512_70140msj_.bkp
71: Control File Included: Ckp SCN: 4771511 Ckp time: 21-JUN-11
72: SPFILE Included: Modification time: 09-MAY-11
73:
74: BS Key Type LV Size Device Type Elapsed Time Completion Time
75: ------- ---- -- ---------- ----------- ------------ ---------------
76: 7 Incr 1 731.46M DISK 00:00:35 21-JUN-11
77: BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20110621T203939
78: Piece Name: /oracle/flash_recovery_area/JCT/backupset/2011_06_21/o1_mf_nnnd1_TAG20110621T203939_70148ddp_.bkp
79: List of Datafiles in backup set 7
80: File LV Type Ckp SCN Ckp Time Name
81: ---- -- ---- ---------- --------- ----
82: 1 1 Incr 4771627 21-JUN-11 /oradata/jct/jct/system01.dbf
83: 2 1 Incr 4771627 21-JUN-11 /oradata/jct/jct/undotbs01.dbf
84: 3 1 Incr 4771627 21-JUN-11 /oradata/jct/jct/sysaux01.dbf
85: 4 1 Incr 4771627 21-JUN-11 /oradata/jct/jct/users01.dbf
86: 5 1 Incr 4771627 21-JUN-11 /oradata/jct/jct/DINFO.dbf
87:
88: BS Key Type LV Size Device Type Elapsed Time Completion Time
89: ------- ---- -- ---------- ----------- ------------ ---------------
90: 8 Incr 1 5.39M DISK 00:00:01 21-JUN-11
91: BP Key: 8 Status: AVAILABLE Compressed: NO Tag: TAG20110621T203939
92: Piece Name: /oracle/flash_recovery_area/JCT/backupset/2011_06_21/o1_mf_ncsn1_TAG20110621T203939_70149voy_.bkp
93: Control File Included: Ckp SCN: 4771645 Ckp time: 21-JUN-11
94: SPFILE Included: Modification time: 09-MAY-11
多吃东西多喝水,
少玩游戏少睡觉! -------
望月飞鱼(珏石头)