首页 > 数据库 > Oracle > Oracle 11g RMAN备份-基本操作
|
--rman连接目标数据库 [oracle@S1011:/export/home/oracle]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Tue Aug 13 17:15:41 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: TESTDB11 (DBID=2578856066)
RMAN>
--执行实例管理命令 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 855982080 bytes
Fixed Size 2230792 bytes Variable Size 641730040 bytes Database Buffers 209715200 bytes Redo Buffers 2306048 bytes
RMAN> open database;
database opened
--执行SQL语句
RMAN> sql 'alter system switch logfile';
sql statement: alter system switch logfile
--查看channel的配置 RMAN> show channel;
RMAN configuration parameters for database with db_unique_name TESTDB11 are: RMAN configuration has no stored or default parameters
--配置2个rman通道 RMAN> configure channel 1 device type disk format '/pooldisk02/backup03/%U';
new RMAN configuration parameters: CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/pooldisk02/backup03/%U'; new RMAN configuration parameters are successfully stored
RMAN> configure channel 2 device type disk format '/pooldisk02/backup04/%U';
using target database control file instead of recovery catalog new RMAN configuration parameters: CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/pooldisk02/backup04/%U'; new RMAN configuration parameters are successfully stored
--查看配置的通道 RMAN> show channel;
RMAN configuration parameters for database with db_unique_name TESTDB11 are: CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/pooldisk02/backup03/%U'; CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/pooldisk02/backup04/%U';
--对users表空间进行备份 RMAN> backup tablespace users;
Starting backup at 13-AUG-13 configuration for DISK channel 2 is ignored allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=41 device type=DISK channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00004 name=/oradata/users01.dbf channel ORA_DISK_1: starting piece 1 at 13-AUG-13 channel ORA_DISK_1: finished piece 1 at 13-AUG-13 piece handle=/pooldisk02/backup03/03oh77tu_1_1 tag=TAG20130813T174742 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 13-AUG-13
--为什么只使用一个channel,这与当前的配置有关 RMAN> show all;
RMAN configuration parameters for database with db_unique_name TESTDB11 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 CHANNEL 1 DEVICE TYPE DISK FORMAT '/pooldisk02/backup03/%U'; CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/pooldisk02/backup04/%U'; 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/dbhome_1/dbs/snapcf_TestDB11.f'; # default
--重新配置磁盘设备的备份并行度 RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters: CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET; new RMAN configuration parameters are successfully stored released channel: ORA_DISK_1
--再次对users表空间进行备份 RMAN> backup tablespace users;
Starting backup at 13-AUG-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=41 device type=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: SID=42 device type=DISK channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00004 name=/oradata/users01.dbf channel ORA_DISK_1: starting piece 1 at 13-AUG-13 channel ORA_DISK_1: finished piece 1 at 13-AUG-13 piece handle=/pooldisk02/backup03/04oh7891_1_1 tag=TAG20130813T175336 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 13-AUG-13 --手工分配channel RMAN> run{ 2> backup datafile 2 channel ORA_DISK_2; 3> backup datafile 4 channel ORA_DISK_1; 4> }
Starting backup at 13-AUG-13 using channel ORA_DISK_1 using channel ORA_DISK_2 channel ORA_DISK_2: starting full datafile backup set channel ORA_DISK_2: specifying datafile(s) in backup set input datafile file number=00002 name=/oradata/sysaux01.dbf channel ORA_DISK_2: starting piece 1 at 13-AUG-13 channel ORA_DISK_2: finished piece 1 at 13-AUG-13 piece handle=/pooldisk02/backup04/05oh78g9_1_1 tag=TAG20130813T175729 comment=NONE channel ORA_DISK_2: backup set complete, elapsed time: 00:00:45 Finished backup at 13-AUG-13
Starting backup at 13-AUG-13 using channel ORA_DISK_1 using channel ORA_DISK_2 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00004 name=/oradata/users01.dbf channel ORA_DISK_1: starting piece 1 at 13-AUG-13 channel ORA_DISK_1: finished piece 1 at 13-AUG-13 piece handle=/pooldisk02/backup03/06oh78hm_1_1 tag=TAG20130813T175814 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 13-AUG-13
--临时分配一个channel RMAN> run 2> { allocate channel c1 device type disk format '/pooldisk02/backup05/%U'; 3> allocate channel c2 device type disk format '/pooldisk02/backup06/%U'; 4> backup datafile 3 channel c1; 5> backup tablespace users channel c2; 6> release channel c1; 7> release channel c2; 8> }
released channel: ORA_DISK_1 released channel: ORA_DISK_2 allocated channel: c1 channel c1: SID=41 device type=DISK
allocated channel: c2 channel c2: SID=42 device type=DISK
Starting backup at 13-AUG-13 channel c1: starting full datafile backup set channel c1: specifying datafile(s) in backup set input datafile file number=00003 name=/oradata/undotbs01.dbf channel c1: starting piece 1 at 13-AUG-13 channel c1: finished piece 1 at 13-AUG-13 piece handle=/pooldisk02/backup05/07oh792c_1_1 tag=TAG20130813T180708 comment=NONE channel c1: backup set complete, elapsed time: 00:00:07 Finished backup at 13-AUG-13
Starting backup at 13-AUG-13 channel c2: starting full datafile backup set channel c2: specifying datafile(s) in backup set input datafile file number=00004 name=/oradata/users01.dbf channel c2: starting piece 1 at 13-AUG-13 channel c2: finished piece 1 at 13-AUG-13 piece handle=/pooldisk02/backup06/08oh792j_1_1 tag=TAG20130813T180715 comment=NONE channel c2: backup set complete, elapsed time: 00:00:01 Finished backup at 13-AUG-13
released channel: c1
released channel: c2 --查看表空间users的备份情况 RMAN> list backup of tablespace users;
List of Backup Sets ===================
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 1 Full 4.23M DISK 00:00:01 13-AUG-13 BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20130813T174742 Piece Name: /pooldisk02/backup03/03oh77tu_1_1 List of Datafiles in backup set 1 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 4 Full 2596084 13-AUG-13 /oradata/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 2 Full 4.23M DISK 00:00:00 13-AUG-13 BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20130813T175336 Piece Name: /pooldisk02/backup03/04oh7891_1_1 List of Datafiles in backup set 2 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 4 Full 2596442 13-AUG-13 /oradata/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 4 Full 4.23M DISK 00:00:00 13-AUG-13 BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20130813T175814 Piece Name: /pooldisk02/backup03/06oh78hm_1_1 List of Datafiles in backup set 4 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 4 Full 2596651 13-AUG-13 /oradata/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 6 Full 4.23M DISK 00:00:00 13-AUG-13 BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20130813T180715 Piece Name: /pooldisk02/backup06/08oh792j_1_1 List of Datafiles in backup set 6 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 4 Full 2597212 13-AUG-13 /oradata/users01.dbf
--修改时间的显示格式 [oracle@S1011:/export/home/oracle]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
RMAN> list backup of tablespace users;
using target database control file instead of recovery catalog
List of Backup Sets ===================
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 1 Full 4.23M DISK 00:00:01 2013-08-13 17:47:43 BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20130813T174742 Piece Name: /pooldisk02/backup03/03oh77tu_1_1 List of Datafiles in backup set 1 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- ------------------- ---- 4 Full 2596084 2013-08-13 17:47:43 /oradata/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 2 Full 4.23M DISK 00:00:00 2013-08-13 17:53:37 BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20130813T175336 Piece Name: /pooldisk02/backup03/04oh7891_1_1 List of Datafiles in backup set 2 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- ------------------- ---- 4 Full 2596442 2013-08-13 17:53:37 /oradata/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 4 Full 4.23M DISK 00:00:00 2013-08-13 17:58:14 BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20130813T175814 Piece Name: /pooldisk02/backup03/06oh78hm_1_1 List of Datafiles in backup set 4 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- ------------------- ---- 4 Full 2596651 2013-08-13 17:58:14 /oradata/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 6 Full 4.23M DISK 00:00:00 2013-08-13 18:07:15 BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20130813T180715 Piece Name: /pooldisk02/backup06/08oh792j_1_1 List of Datafiles in backup set 6 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- ------------------- ---- 4 Full 2597212 2013-08-13 18:07:15 /oradata/users01.dbf
--查看参数配置 RMAN> show all;
RMAN configuration parameters for database with db_unique_name TESTDB11 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 2 BACKUP TYPE TO BACKUPSET; CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/pooldisk02/backup03/%U'; CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/pooldisk02/backup04/%U'; 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/dbhome_1/dbs/snapcf_TestDB11.f'; # default --保留策略1,冗余度(redundancy) RMAN> show retention policy;
RMAN configuration parameters for database with db_unique_name TESTDB11 are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default --查看需要的备份 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 ---- ----- ----------------------------------------------------- 1 0 /oradata/system01.dbf 5 0 /oradata/example01.dbf 6 0 /oradata/newts01.dbf 7 0 /oradata/fbtbs01.dbf
RMAN> backup datafile 7;
Starting backup at 2013-08-14 01:38:21 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=47 device type=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: SID=52 device type=DISK 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=/oradata/fbtbs01.dbf channel ORA_DISK_1: starting piece 1 at 2013-08-14 01:38:21 channel ORA_DISK_1: finished piece 1 at 2013-08-14 01:38:23 piece handle=/pooldisk02/backup03/09oh83gd_1_1 tag=TAG20130814T013821 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 Finished backup at 2013-08-14 01:38:23
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 ---- ----- ----------------------------------------------------- 1 0 /oradata/system01.dbf 5 0 /oradata/example01.dbf 6 0 /oradata/newts01.dbf
--调整保留策略 RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters: CONFIGURE RETENTION POLICY TO REDUNDANCY 2; new RMAN configuration parameters are successfully stored
RMAN> report need backup;
RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 2 Report of files with less than 2 redundant backups File #bkps Name ---- ----- ----------------------------------------------------- 1 0 /oradata/system01.dbf 2 1 /oradata/sysaux01.dbf 3 1 /oradata/undotbs01.dbf 5 0 /oradata/example01.dbf 6 0 /oradata/newts01.dbf 7 1 /oradata/fbtbs01.dbf
--把文件7再备份一次 RMAN> backup datafile 7;
Starting backup at 2013-08-14 01:41:06 using channel ORA_DISK_1 using channel ORA_DISK_2 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=/oradata/fbtbs01.dbf channel ORA_DISK_1: starting piece 1 at 2013-08-14 01:41:06 channel ORA_DISK_1: finished piece 1 at 2013-08-14 01:41:07 piece handle=/pooldisk02/backup03/0aoh83li_1_1 tag=TAG20130814T014106 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2013-08-14 01:41:07
RMAN> report need backup;
RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 2 Report of files with less than 2 redundant backups File #bkps Name ---- ----- ----------------------------------------------------- 1 0 /oradata/system01.dbf 2 1 /oradata/sysaux01.dbf 3 1 /oradata/undotbs01.dbf 5 0 /oradata/example01.dbf 6 0 /oradata/newts01.dbf --查看过期的备份(根据备份策略来决定是否过期) RMAN> report obsolete;
RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 2 Report of obsolete backups and copies Type Key Completion Time Filename/Handle -------------------- ------ ------------------ -------------------- Backup Set 1 2013-08-13 17:47:43 Backup Piece 1 2013-08-13 17:47:43 /pooldisk02/backup03/03oh77tu_1_1 Backup Set 2 2013-08-13 17:53:37 Backup Piece 2 2013-08-13 17:53:37 /pooldisk02/backup03/04oh7891_1_1
--修改回原来的保留策略 RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
old RMAN configuration parameters: CONFIGURE RETENTION POLICY TO REDUNDANCY 2; new RMAN configuration parameters: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; new RMAN configuration parameters are successfully stored
RMAN> report obsolete;
RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 1 Report of obsolete backups and copies Type Key Completion Time Filename/Handle -------------------- ------ ------------------ -------------------- Backup Set 1 2013-08-13 17:47:43 Backup Piece 1 2013-08-13 17:47:43 /pooldisk02/backup03/03oh77tu_1_1 Backup Set 2 2013-08-13 17:53:37 Backup Piece 2 2013-08-13 17:53:37 /pooldisk02/backup03/04oh7891_1_1 Backup Set 4 2013-08-13 17:58:14 Backup Piece 4 2013-08-13 17:58:14 /pooldisk02/backup03/06oh78hm_1_1 Backup Set 7 2013-08-14 01:38:22 Backup Piece 7 2013-08-14 01:38:22 /pooldisk02/backup03/09oh83gd_1_1
--保留策略2,恢复窗口,设置恢复窗口为7天 RMAN> CONFIGURE RETENTION POLICY TO recovery window of 7 days;
old RMAN configuration parameters: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; new RMAN configuration parameters: CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS; new RMAN configuration parameters are successfully stored
--清除现有参数的设置,使用默认值 RMAN> CONFIGURE RETENTION POLICY clear;
old RMAN configuration parameters: CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS; RMAN configuration parameters are successfully reset to default value --查看当前设置 RMAN> show RETENTION POLICY;
RMAN configuration parameters for database with db_unique_name TESTDB11 are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
--查看当前的备份优化的设置,是指数据文件、归档日志、备份集如果存在相同的就不会再备份 RMAN> show backup optimization;
RMAN configuration parameters for database with db_unique_name TESTDB11 are: CONFIGURE BACKUP OPTIMIZATION OFF; # default
--控制文件自动备份,如果设置为off,则不会单独地自动备份控制文件和初始化参数文件。 --但当备份集中包含1号数据文件时,会在同一备份集中包含控制文件和初始化参数文件 RMAN> show CONTROLFILE AUTOBACKUP;
RMAN configuration parameters for database with db_unique_name TESTDB11 are: CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default --备份4号数据文件,没有备份控制文件 RMAN> backup datafile 4;
Starting backup at 2013-08-14 02:07:27 using channel ORA_DISK_1 using channel ORA_DISK_2 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00004 name=/oradata/users01.dbf channel ORA_DISK_1: starting piece 1 at 2013-08-14 02:07:28 channel ORA_DISK_1: finished piece 1 at 2013-08-14 02:07:29 piece handle=/pooldisk02/backup03/0boh856v_1_1 tag=TAG20130814T020727 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 Finished backup at 2013-08-14 02:07:29
--备份1号文件,包含控制文件和初始化参数文件 RMAN> backup datafile 1;
Starting backup at 2013-08-14 02:08:10 using channel ORA_DISK_1 using channel ORA_DISK_2 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/oradata/system01.dbf channel ORA_DISK_1: starting piece 1 at 2013-08-14 02:08:10 channel ORA_DISK_2: starting full datafile backup set channel ORA_DISK_2: specifying datafile(s) in backup set channel ORA_DISK_1: finished piece 1 at 2013-08-14 02:08:56 piece handle=/pooldisk02/backup03/0coh858a_1_1 tag=TAG20130814T020810 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:46 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at 2013-08-14 02:08:56 including current control file in backup set channel ORA_DISK_2: starting piece 1 at 2013-08-14 02:08:56 channel ORA_DISK_1: finished piece 1 at 2013-08-14 02:08:57 piece handle=/pooldisk02/backup03/0eoh859o_1_1 tag=TAG20130814T020810 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 channel ORA_DISK_2: finished piece 1 at 2013-08-14 02:08:57 piece handle=/pooldisk02/backup04/0doh858b_1_1 tag=TAG20130814T020810 comment=NONE channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01 Finished backup at 2013-08-14 02:08:57
--清除备份 RMAN> delete backup;
using channel ORA_DISK_1 using channel ORA_DISK_2
List of Backup Pieces BP Key BS Key Pc# Cp# Status Device Type Piece Name ------- ------- --- --- ----------- ----------- ---------- 1 1 1 1 AVAILABLE DISK /pooldisk02/backup03/03oh77tu_1_1 2 2 1 1 AVAILABLE DISK /pooldisk02/backup03/04oh7891_1_1 3 3 1 1 AVAILABLE DISK /pooldisk02/backup04/05oh78g9_1_1 4 4 1 1 AVAILABLE DISK /pooldisk02/backup03/06oh78hm_1_1 5 5 1 1 AVAILABLE DISK /pooldisk02/backup05/07oh792c_1_1 6 6 1 1 AVAILABLE DISK /pooldisk02/backup06/08oh792j_1_1 7 7 1 1 AVAILABLE DISK /pooldisk02/backup03/09oh83gd_1_1 8 8 1 1 AVAILABLE DISK /pooldisk02/backup03/0aoh83li_1_1 9 9 1 1 AVAILABLE DISK /pooldisk02/backup03/0boh856v_1_1 10 10 1 1 AVAILABLE DISK /pooldisk02/backup03/0coh858a_1_1 11 11 1 1 AVAILABLE DISK /pooldisk02/backup03/0eoh859o_1_1 12 12 1 1 AVAILABLE DISK /pooldisk02/backup04/0doh858b_1_1
--打开控制文件自动备份,会在单独的备份集中创建控制文件和初始化参数文件的备份 RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;
new RMAN configuration parameters: CONFIGURE CONTROLFILE AUTOBACKUP ON; new RMAN configuration parameters are successfully stored
RMAN> backup datafile 4;
Starting backup at 2013-08-14 02:12:00 using channel ORA_DISK_1 using channel ORA_DISK_2 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00004 name=/oradata/users01.dbf channel ORA_DISK_1: starting piece 1 at 2013-08-14 02:12:00 channel ORA_DISK_1: finished piece 1 at 2013-08-14 02:12:01 piece handle=/pooldisk02/backup03/0foh85fg_1_1 tag=TAG20130814T021200 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2013-08-14 02:12:01
Starting Control File and SPFILE Autobackup at 2013-08-14 02:12:01 piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823399921_90pcg1ng_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 2013-08-14 02:12:02
--查看备份的控制文件的信息 RMAN> list backup of controlfile;
List of Backup Sets ===================
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 14 Full 9.67M DISK 00:00:01 2013-08-14 02:12:02 BP Key: 14 Status: AVAILABLE Compressed: NO Tag: TAG20130814T021201 Piece Name: /u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823399921_90pcg1ng_.bkp Control File Included: Ckp SCN: 2633674 Ckp time: 2013-08-14 02:12:01
--自动备份的控制文件的格式 RMAN> show CONTROLFILE AUTOBACKUP FORMAT;
RMAN configuration parameters for database with db_unique_name TESTDB11 are: CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
--查看rman所有配置参数,一一加以解释 RMAN> show all;
RMAN configuration parameters for database with db_unique_name TESTDB11 are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET; CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/pooldisk02/backup03/%U'; CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/pooldisk02/backup04/%U'; 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/dbhome_1/dbs/snapcf_TestDB11.f'; # default
--rman备份可以分为镜像拷贝和备份集2种 --1.备份拷贝 RMAN> backup as copy datafile 4;
Starting backup at 2013-08-14 02:35:19 using channel ORA_DISK_1 using channel ORA_DISK_2 channel ORA_DISK_1: starting datafile copy input datafile file number=00004 name=/oradata/users01.dbf output file name=/pooldisk02/backup03/data_D-TESTDB11_I-2578856066_TS-USERS_FNO-4_0hoh86r8 tag=TAG20130814T023519 RECID=3 STAMP=823401320 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 Finished backup at 2013-08-14 02:35:21
Starting Control File and SPFILE Autobackup at 2013-08-14 02:35:21 piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823401321_90pdssjc_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 2013-08-14 02:35:22 --查看已经产生的镜像拷贝 RMAN> list copy of datafile 4;
List of Datafile Copies =======================
Key File S Completion Time Ckp SCN Ckp Time ------- ---- - ------------------- ---------- ------------------- 3 4 A 2013-08-14 02:35:20 2634778 2013-08-14 02:35:20 Name: /pooldisk02/backup03/data_D-TESTDB11_I-2578856066_TS-USERS_FNO-4_0hoh86r8 Tag: TAG20130814T023519
--镜像拷贝保持原大小 [root@S1011:/pooldisk02]# ls -lh /oradata/users01.dbf -rw-r----- 1 oracle oinstall 6.3M Aug 14 02:35 /oradata/users01.dbf [root@S1011:/pooldisk02]# ls -lh ls -lh /pooldisk02/backup03/data_D-TESTDB11_I-2578856066_TS-USERS_FNO-4_0hoh86r8 ls: No such file or directory -lh: No such file or directory -rw-r----- 1 oracle oinstall 6.3M Aug 14 02:35 /pooldisk02/backup03/data_D-TESTDB11_I-2578856066_TS-USERS_FNO-4_0hoh86r8
--镜像拷贝也可以自己指定产生的位置和名称 RMAN> copy datafile 4 to '/pooldisk02/backup01/user01.bak';
Starting backup at 2013-08-14 02:44:44 using channel ORA_DISK_1 using channel ORA_DISK_2 channel ORA_DISK_1: starting datafile copy input datafile file number=00004 name=/oradata/users01.dbf output file name=/pooldisk02/backup01/user01.bak tag=TAG20130814T024444 RECID=4 STAMP=823401885 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 Finished backup at 2013-08-14 02:44:46
Starting Control File and SPFILE Autobackup at 2013-08-14 02:44:46 piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823401886_90pfcgf0_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 2013-08-14 02:44:47
--重新将备份并行度设置为1 RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
using target database control file instead of recovery catalog old RMAN configuration parameters: CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; new RMAN configuration parameters: CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; new RMAN configuration parameters are successfully stored
--2. 给表空间users添加一个数据文件 sys@TESTDB11>alter tablespace users add datafile '/oradata/users02.dbf' size 50m;
Tablespace altered.
--生成备份集 RMAN> backup tablespace users;
Starting backup at 2013-08-14 02:52:12 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=00008 name=/oradata/users02.dbf input datafile file number=00004 name=/oradata/users01.dbf channel ORA_DISK_1: starting piece 1 at 2013-08-14 02:52:12 channel ORA_DISK_1: finished piece 1 at 2013-08-14 02:52:13 piece handle=/pooldisk02/backup03/0noh87qs_1_1 tag=TAG20130814T025212 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2013-08-14 02:52:13
Starting Control File and SPFILE Autobackup at 2013-08-14 02:52:14 piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823402334_90pfsgb4_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 2013-08-14 02:52:15
RMAN> list backup of tablespace users;
List of Backup Sets ===================
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 19 Full 5.23M DISK 00:00:01 2013-08-14 02:52:13 BP Key: 19 Status: AVAILABLE Compressed: NO Tag: TAG20130814T025212 Piece Name: /pooldisk02/backup03/0noh87qs_1_1 List of Datafiles in backup set 19 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- ------------------- ---- 4 Full 2635901 2013-08-14 02:52:12 /oradata/users01.dbf 8 Full 2635901 2013-08-14 02:52:12 /oradata/users02.dbf
--查看生成的备份集的大小,比原来数据文件小多了 [root@S1011:/pooldisk02]# ls -lh /pooldisk02/backup03/0noh87qs_1_1 -rw-r----- 1 oracle oinstall 5.2M Aug 14 02:52 /pooldisk02/backup03/0noh87qs_1_1 |
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/13754335/viewspace-2135350/ ,如需转载,请注明出处,否则将追究法律责任。