【RMAN】RMAN備份恢復2 RMAN熱備指令碼與crontab計劃任務

531968912發表於2016-05-17
RMAN備份恢復2
RMAN熱備指令碼與crontab計劃任務

【rman熱備】

熱備(非一致性備份,不關庫備份。熱備要求資料庫必須是歸檔模式)

SYS@PROD>select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production



SYS@PROD>archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch
Oldest online log sequence     4
Current log sequence           6
SYS@PROD>




【建立目錄】
建立歸檔日誌檔案目錄
[oracle@rhel64 ~]$ mkdir /u01/app/oracle/arch

建立rman熱備目錄
[oracle@rhel64 ~]$ mkdir -p /u01/app/oracle/backup/rman_hot

建立備份指令碼目錄
[oracle@rhel64 ~]$ mkdir  /u01/app/oracle/scripts


【開歸檔】

設定歸檔路徑  
SYS@PROD>alter system set log_archive_dest_1='location=/u01/app/oracle/arch';
System altered.

設定歸檔檔名格式
SYS@PROD>alter system set log_archive_format='arch_%d_%t_%s_%r.dbf' scope=spfile;
System altered.

開歸檔
SYS@PROD>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@PROD>


SYS@PROD>startup mount;
ORACLE instance started.
Total System Global Area  626327552 bytes
Fixed Size                  2230952 bytes
Variable Size             390071640 bytes
Database Buffers          230686720 bytes
Redo Buffers                3338240 bytes
Database mounted.
SYS@PROD>


SYS@PROD>alter database archivelog;
Database altered.


SYS@PROD>archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/arch
Oldest online log sequence     4
Next log sequence to archive   6
Current log sequence           6
SYS@PROD>

SYS@PROD>alter database open;
Database altered.


SYS@PROD>alter system archive log current;
System altered.

SYS@PROD>/
System altered.

SYS@PROD>/
System altered.

SYS@PROD>archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/arch
Oldest online log sequence     7
Next log sequence to archive   9
Current log sequence           9
SYS@PROD>





【配置rman】 可選

[oracle@rhel64 ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Wed May 11 15:46:45 2016

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

connected to target database: PROD (DBID=314169367)

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name PROD 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/dbhome_1/dbs/snapcf_PROD.f'; # default



配置備份冗餘度2
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;

開啟備份最佳化
RMAN> CONFIGURE BACKUP OPTIMIZATION on;

開啟控制檔案自動備份
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;


RMAN> show all;

RMAN configuration parameters for database with db_unique_name PROD are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE BACKUP OPTIMIZATION ON;
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 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/dbhome_1/dbs/snapcf_PROD.f'; # default



【執行rman熱備測試】  連續執行3次 驗證刪除過時歸檔、備份命令

run{
crosscheck backup;
allocate channel c1 device type disk;
allocate channel c2 device type disk;
backup database format '/u01/app/oracle/backup/rman_hot/db_%d_%T_%U.bak'
plus archivelog format '/u01/app/oracle/backup/rman_hot/ar_%d_%T_%U.bak';
backup current controlfile format '/u01/app/oracle/backup/rman_hot/control_%d_%T_%U.bak';
report obsolete device type disk;
delete noprompt obsolete device type disk;
delete noprompt expired backup device type disk;
release channel c1;
release channel c2;
}



RMAN> run{
2> crosscheck backup;
3> allocate channel c1 device type disk;
4> allocate channel c2 device type disk;
5> backup database format '/u01/app/oracle/backup/rman_hot/db_%d_%T_%U.bak'
6> plus archivelog format '/u01/app/oracle/backup/rman_hot/ar_%d_%T_%U.bak';
7> backup current controlfile format '/u01/app/oracle/backup/rman_hot/control_%d_%T_%U.bak';
8> report obsolete device type disk;
9> delete noprompt obsolete device type disk;
10> delete noprompt expired backup device type disk;
11> release channel c1;
12> release channel c2;
13> }

using channel ORA_DISK_1
specification does not match any backup in the repository

released channel: ORA_DISK_1
allocated channel: c1
channel c1: SID=39 device type=DISK

allocated channel: c2
channel c2: SID=40 device type=DISK


Starting backup at 11-MAY-16
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=20 RECID=15 STAMP=911581803
input archived log thread=1 sequence=21 RECID=16 STAMP=911581852
input archived log thread=1 sequence=22 RECID=17 STAMP=911581888
channel c1: starting piece 1 at 11-MAY-16
channel c2: starting archived log backup set
channel c2: specifying archived log(s) in backup set
input archived log thread=1 sequence=23 RECID=18 STAMP=911581916
input archived log thread=1 sequence=24 RECID=19 STAMP=911581919
input archived log thread=1 sequence=25 RECID=20 STAMP=911581922
input archived log thread=1 sequence=26 RECID=21 STAMP=911581932
input archived log thread=1 sequence=27 RECID=22 STAMP=911581933
input archived log thread=1 sequence=28 RECID=23 STAMP=911581935
channel c2: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_0ur5b8ps_1_1.bak tag=TAG20160511T171332 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=29 RECID=24 STAMP=911581976
input archived log thread=1 sequence=30 RECID=25 STAMP=911582012
channel c1: starting piece 1 at 11-MAY-16
channel c2: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_0vr5b8ps_1_1.bak tag=TAG20160511T171332 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:01
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_10r5b8pt_1_1.bak tag=TAG20160511T171332 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-MAY-16

Starting backup at 11-MAY-16
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/PROD/example01.dbf
channel c1: starting piece 1 at 11-MAY-16
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD/users01.dbf
channel c2: starting piece 1 at 11-MAY-16
channel c2: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_12r5b8pu_1_1.bak tag=TAG20160511T171334 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:26
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_11r5b8pu_1_1.bak tag=TAG20160511T171334 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:36
Finished backup at 11-MAY-16

Starting backup at 11-MAY-16
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=31 RECID=26 STAMP=911582050
channel c1: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_13r5b8r2_1_1.bak tag=TAG20160511T171410 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-MAY-16

Starting backup at 11-MAY-16
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/control_PROD_20160511_14r5b8r3_1_1.bak tag=TAG20160511T171411 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-MAY-16

Starting Control File and SPFILE Autobackup at 11-MAY-16
piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-04 comment=NONE
Finished Control File and SPFILE Autobackup at 11-MAY-16

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
no obsolete backups found

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
no obsolete backups found

specification does not match any backup in the repository

released channel: c1

released channel: c2

RMAN>




[oracle@rhel64 arch]$ ls -lht
total 72K
-rw-r----- 1 oracle oinstall 7.0K May 11 17:14 arch_12b9d817_1_31_902331034.dbf
-rw-r----- 1 oracle oinstall 1.0K May 11 17:13 arch_12b9d817_1_30_902331034.dbf
-rw-r----- 1 oracle oinstall 6.0K May 11 17:12 arch_12b9d817_1_29_902331034.dbf
-rw-r----- 1 oracle oinstall 1.0K May 11 17:12 arch_12b9d817_1_28_902331034.dbf
-rw-r----- 1 oracle oinstall 1.0K May 11 17:12 arch_12b9d817_1_27_902331034.dbf
-rw-r----- 1 oracle oinstall 1.0K May 11 17:12 arch_12b9d817_1_26_902331034.dbf
-rw-r----- 1 oracle oinstall 1.5K May 11 17:12 arch_12b9d817_1_25_902331034.dbf
-rw-r----- 1 oracle oinstall 1.5K May 11 17:11 arch_12b9d817_1_24_902331034.dbf
-rw-r----- 1 oracle oinstall 6.0K May 11 17:11 arch_12b9d817_1_23_902331034.dbf
-rw-r----- 1 oracle oinstall 7.0K May 11 17:11 arch_12b9d817_1_22_902331034.dbf
-rw-r----- 1 oracle oinstall 6.0K May 11 17:10 arch_12b9d817_1_21_902331034.dbf
-rw-r----- 1 oracle oinstall 6.0K May 11 17:10 arch_12b9d817_1_20_902331034.dbf
[oracle@rhel64 arch]$






[oracle@rhel64 rman_hot]$ ls -lht
total 1.1G
-rw-r----- 1 oracle oinstall 9.4M May 11 17:14 control_PROD_20160511_14r5b8r3_1_1.bak
-rw-r----- 1 oracle oinstall 8.5K May 11 17:14 ar_PROD_20160511_13r5b8r2_1_1.bak
-rw-r----- 1 oracle oinstall 674M May 11 17:13 db_PROD_20160511_11r5b8pu_1_1.bak
-rw-r----- 1 oracle oinstall 428M May 11 17:13 db_PROD_20160511_12r5b8pu_1_1.bak
-rw-r----- 1 oracle oinstall 8.0K May 11 17:13 ar_PROD_20160511_10r5b8pt_1_1.bak
-rw-r----- 1 oracle oinstall  11K May 11 17:13 ar_PROD_20160511_0vr5b8ps_1_1.bak
-rw-r----- 1 oracle oinstall  20K May 11 17:13 ar_PROD_20160511_0ur5b8ps_1_1.bak
[oracle@rhel64 rman_hot]$









【第二次執行】

run{
crosscheck backup;
allocate channel c1 device type disk;
allocate channel c2 device type disk;
backup database format '/u01/app/oracle/backup/rman_hot/db_%d_%T_%U.bak'
plus archivelog format '/u01/app/oracle/backup/rman_hot/ar_%d_%T_%U.bak';
backup current controlfile format '/u01/app/oracle/backup/rman_hot/control_%d_%T_%U.bak';
report obsolete device type disk;
delete noprompt obsolete device type disk;
delete noprompt expired backup device type disk;
release channel c1;
release channel c2;
}




RMAN> run{
2> crosscheck backup;
3> allocate channel c1 device type disk;
4> allocate channel c2 device type disk;
5> backup database format '/u01/app/oracle/backup/rman_hot/db_%d_%T_%U.bak'
6> plus archivelog format '/u01/app/oracle/backup/rman_hot/ar_%d_%T_%U.bak';
7> backup current controlfile format '/u01/app/oracle/backup/rman_hot/control_%d_%T_%U.bak';
8> report obsolete device type disk;
9> delete noprompt obsolete device type disk;
10> delete noprompt expired backup device type disk;
11> release channel c1;
12> release channel c2;
13> }

allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=39 device type=DISK
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_0ur5b8ps_1_1.bak RECID=30 STAMP=911582012
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_0vr5b8ps_1_1.bak RECID=31 STAMP=911582012
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_10r5b8pt_1_1.bak RECID=32 STAMP=911582013
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_12r5b8pu_1_1.bak RECID=33 STAMP=911582016
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_11r5b8pu_1_1.bak RECID=34 STAMP=911582014
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_13r5b8r2_1_1.bak RECID=35 STAMP=911582050
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/control_PROD_20160511_14r5b8r3_1_1.bak RECID=36 STAMP=911582052
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-04 RECID=37 STAMP=911582053
Crosschecked 8 objects


released channel: ORA_DISK_1
allocated channel: c1
channel c1: SID=39 device type=DISK

allocated channel: c2
channel c2: SID=40 device type=DISK


Starting backup at 11-MAY-16
current log archived
skipping archived logs of thread 1 from sequence 20 to 31; already backed up
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=32 RECID=27 STAMP=911582152
channel c1: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_16r5b8u8_1_1.bak tag=TAG20160511T171552 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-MAY-16

Starting backup at 11-MAY-16
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/PROD/example01.dbf
channel c1: starting piece 1 at 11-MAY-16
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD/users01.dbf
channel c2: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_17r5b8u9_1_1.bak tag=TAG20160511T171553 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:25
channel c2: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_18r5b8u9_1_1.bak tag=TAG20160511T171553 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:25
Finished backup at 11-MAY-16

Starting backup at 11-MAY-16
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=33 RECID=28 STAMP=911582178
channel c1: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_19r5b8v2_1_1.bak tag=TAG20160511T171618 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-MAY-16

Starting backup at 11-MAY-16
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/control_PROD_20160511_1ar5b8v3_1_1.bak tag=TAG20160511T171619 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-MAY-16

Starting Control File and SPFILE Autobackup at 11-MAY-16
piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-05 comment=NONE
Finished Control File and SPFILE Autobackup at 11-MAY-16

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
-------------------- ------ ------------------ --------------------
Archive Log          15     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_20_902331034.dbf
Archive Log          16     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_21_902331034.dbf
Archive Log          17     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_22_902331034.dbf
Archive Log          18     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_23_902331034.dbf
Archive Log          19     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_24_902331034.dbf
Archive Log          20     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_25_902331034.dbf
Archive Log          21     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_26_902331034.dbf
Archive Log          22     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_27_902331034.dbf
Archive Log          23     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_28_902331034.dbf
Archive Log          24     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_29_902331034.dbf
Backup Set           30     11-MAY-16        
 Backup Piece       30     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_0ur5b8ps_1_1.bak
Archive Log          25     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_30_902331034.dbf
Backup Set           31     11-MAY-16        
 Backup Piece       31     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_0vr5b8ps_1_1.bak
Backup Set           32     11-MAY-16        
 Backup Piece       32     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_10r5b8pt_1_1.bak
Backup Set           36     11-MAY-16        
 Backup Piece       36     11-MAY-16          /u01/app/oracle/backup/rman_hot/control_PROD_20160511_14r5b8r3_1_1.bak

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log          15     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_20_902331034.dbf
Archive Log          16     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_21_902331034.dbf
Archive Log          17     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_22_902331034.dbf
Archive Log          18     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_23_902331034.dbf
Archive Log          19     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_24_902331034.dbf
Archive Log          20     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_25_902331034.dbf
Archive Log          21     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_26_902331034.dbf
Archive Log          22     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_27_902331034.dbf
Archive Log          23     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_28_902331034.dbf
Archive Log          24     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_29_902331034.dbf
Backup Set           30     11-MAY-16        
 Backup Piece       30     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_0ur5b8ps_1_1.bak
Archive Log          25     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_30_902331034.dbf
Backup Set           31     11-MAY-16        
 Backup Piece       31     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_0vr5b8ps_1_1.bak
Backup Set           32     11-MAY-16        
 Backup Piece       32     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_10r5b8pt_1_1.bak
Backup Set           36     11-MAY-16        
 Backup Piece       36     11-MAY-16          /u01/app/oracle/backup/rman_hot/control_PROD_20160511_14r5b8r3_1_1.bak
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_20_902331034.dbf RECID=15 STAMP=911581803
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_21_902331034.dbf RECID=16 STAMP=911581852
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_22_902331034.dbf RECID=17 STAMP=911581888
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_23_902331034.dbf RECID=18 STAMP=911581916
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_24_902331034.dbf RECID=19 STAMP=911581919
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_25_902331034.dbf RECID=20 STAMP=911581922
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_26_902331034.dbf RECID=21 STAMP=911581932
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_27_902331034.dbf RECID=22 STAMP=911581933
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_28_902331034.dbf RECID=23 STAMP=911581935
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_29_902331034.dbf RECID=24 STAMP=911581976
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_0ur5b8ps_1_1.bak RECID=30 STAMP=911582012
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_30_902331034.dbf RECID=25 STAMP=911582012
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_0vr5b8ps_1_1.bak RECID=31 STAMP=911582012
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_10r5b8pt_1_1.bak RECID=32 STAMP=911582013
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/control_PROD_20160511_14r5b8r3_1_1.bak RECID=36 STAMP=911582052
Deleted 15 objects


specification does not match any backup in the repository

released channel: c1

released channel: c2

RMAN>



[oracle@rhel64 arch]$ ls -lht
total 32K
-rw-r----- 1 oracle oinstall 2.0K May 11 17:16 arch_12b9d817_1_33_902331034.dbf
-rw-r----- 1 oracle oinstall  20K May 11 17:15 arch_12b9d817_1_32_902331034.dbf
-rw-r----- 1 oracle oinstall 7.0K May 11 17:14 arch_12b9d817_1_31_902331034.dbf
[oracle@rhel64 arch]$



[oracle@rhel64 rman_hot]$ ls -lht
total 2.2G
-rw-r----- 1 oracle oinstall 9.4M May 11 17:16 control_PROD_20160511_1ar5b8v3_1_1.bak
-rw-r----- 1 oracle oinstall 3.5K May 11 17:16 ar_PROD_20160511_19r5b8v2_1_1.bak
-rw-r----- 1 oracle oinstall 674M May 11 17:16 db_PROD_20160511_17r5b8u9_1_1.bak
-rw-r----- 1 oracle oinstall 428M May 11 17:16 db_PROD_20160511_18r5b8u9_1_1.bak
-rw-r----- 1 oracle oinstall  21K May 11 17:15 ar_PROD_20160511_16r5b8u8_1_1.bak
-rw-r----- 1 oracle oinstall 8.5K May 11 17:14 ar_PROD_20160511_13r5b8r2_1_1.bak
-rw-r----- 1 oracle oinstall 674M May 11 17:13 db_PROD_20160511_11r5b8pu_1_1.bak
-rw-r----- 1 oracle oinstall 428M May 11 17:13 db_PROD_20160511_12r5b8pu_1_1.bak
[oracle@rhel64 rman_hot]$



【第三次執行】


run{
crosscheck backup;
allocate channel c1 device type disk;
allocate channel c2 device type disk;
backup database format '/u01/app/oracle/backup/rman_hot/db_%d_%T_%U.bak'
plus archivelog format '/u01/app/oracle/backup/rman_hot/ar_%d_%T_%U.bak';
backup current controlfile format '/u01/app/oracle/backup/rman_hot/control_%d_%T_%U.bak';
report obsolete device type disk;
delete noprompt obsolete device type disk;
delete noprompt expired backup device type disk;
release channel c1;
release channel c2;
}

RMAN> run{
2> crosscheck backup;
3> allocate channel c1 device type disk;
4> allocate channel c2 device type disk;
5> backup database format '/u01/app/oracle/backup/rman_hot/db_%d_%T_%U.bak'
6> plus archivelog format '/u01/app/oracle/backup/rman_hot/ar_%d_%T_%U.bak';
7> backup current controlfile format '/u01/app/oracle/backup/rman_hot/control_%d_%T_%U.bak';
8> report obsolete device type disk;
9> delete noprompt obsolete device type disk;
10> delete noprompt expired backup device type disk;
11> release channel c1;
12> release channel c2;
13> }

allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=39 device type=DISK
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_12r5b8pu_1_1.bak RECID=33 STAMP=911582016
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_11r5b8pu_1_1.bak RECID=34 STAMP=911582014
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_13r5b8r2_1_1.bak RECID=35 STAMP=911582050
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-04 RECID=37 STAMP=911582053
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_16r5b8u8_1_1.bak RECID=38 STAMP=911582152
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_17r5b8u9_1_1.bak RECID=39 STAMP=911582153
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_18r5b8u9_1_1.bak RECID=40 STAMP=911582156
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_19r5b8v2_1_1.bak RECID=41 STAMP=911582178
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/control_PROD_20160511_1ar5b8v3_1_1.bak RECID=42 STAMP=911582180
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-05 RECID=43 STAMP=911582182
Crosschecked 10 objects


released channel: ORA_DISK_1
allocated channel: c1
channel c1: SID=39 device type=DISK

allocated channel: c2
channel c2: SID=40 device type=DISK


Starting backup at 11-MAY-16
current log archived
skipping archived logs of thread 1 from sequence 31 to 33; already backed up
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=34 RECID=29 STAMP=911582387
channel c1: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_1cr5b95j_1_1.bak tag=TAG20160511T171947 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-MAY-16

Starting backup at 11-MAY-16
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/PROD/example01.dbf
channel c1: starting piece 1 at 11-MAY-16
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD/users01.dbf
channel c2: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_1dr5b95k_1_1.bak tag=TAG20160511T171948 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:15
channel c2: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_1er5b95k_1_1.bak tag=TAG20160511T171948 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:25
Finished backup at 11-MAY-16

Starting backup at 11-MAY-16
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=35 RECID=30 STAMP=911582413
channel c1: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_1fr5b96d_1_1.bak tag=TAG20160511T172013 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-MAY-16

Starting backup at 11-MAY-16
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/control_PROD_20160511_1gr5b96e_1_1.bak tag=TAG20160511T172014 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-MAY-16

Starting Control File and SPFILE Autobackup at 11-MAY-16
piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-06 comment=NONE
Finished Control File and SPFILE Autobackup at 11-MAY-16

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           34     11-MAY-16        
 Backup Piece       34     11-MAY-16          /u01/app/oracle/backup/rman_hot/db_PROD_20160511_11r5b8pu_1_1.bak
Backup Set           33     11-MAY-16        
 Backup Piece       33     11-MAY-16          /u01/app/oracle/backup/rman_hot/db_PROD_20160511_12r5b8pu_1_1.bak
Archive Log          26     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_31_902331034.dbf
Backup Set           35     11-MAY-16        
 Backup Piece       35     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_13r5b8r2_1_1.bak
Backup Set           37     11-MAY-16        
 Backup Piece       37     11-MAY-16          /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-04
Archive Log          27     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_32_902331034.dbf
Backup Set           38     11-MAY-16        
 Backup Piece       38     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_16r5b8u8_1_1.bak
Backup Set           42     11-MAY-16        
 Backup Piece       42     11-MAY-16          /u01/app/oracle/backup/rman_hot/control_PROD_20160511_1ar5b8v3_1_1.bak

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           34     11-MAY-16        
 Backup Piece       34     11-MAY-16          /u01/app/oracle/backup/rman_hot/db_PROD_20160511_11r5b8pu_1_1.bak
Backup Set           33     11-MAY-16        
 Backup Piece       33     11-MAY-16          /u01/app/oracle/backup/rman_hot/db_PROD_20160511_12r5b8pu_1_1.bak
Archive Log          26     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_31_902331034.dbf
Backup Set           35     11-MAY-16        
 Backup Piece       35     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_13r5b8r2_1_1.bak
Backup Set           37     11-MAY-16        
 Backup Piece       37     11-MAY-16          /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-04
Archive Log          27     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_32_902331034.dbf
Backup Set           38     11-MAY-16        
 Backup Piece       38     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_16r5b8u8_1_1.bak
Backup Set           42     11-MAY-16        
 Backup Piece       42     11-MAY-16          /u01/app/oracle/backup/rman_hot/control_PROD_20160511_1ar5b8v3_1_1.bak
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_11r5b8pu_1_1.bak RECID=34 STAMP=911582014
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_12r5b8pu_1_1.bak RECID=33 STAMP=911582016
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_31_902331034.dbf RECID=26 STAMP=911582050
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_13r5b8r2_1_1.bak RECID=35 STAMP=911582050
deleted backup piece
backup piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-04 RECID=37 STAMP=911582053
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_32_902331034.dbf RECID=27 STAMP=911582152
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_16r5b8u8_1_1.bak RECID=38 STAMP=911582152
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/control_PROD_20160511_1ar5b8v3_1_1.bak RECID=42 STAMP=911582180
Deleted 8 objects


specification does not match any backup in the repository

released channel: c1

released channel: c2

RMAN>



[oracle@rhel64 arch]$ ls -lht
total 176K
-rw-r----- 1 oracle oinstall  15K May 11 17:20 arch_12b9d817_1_35_902331034.dbf
-rw-r----- 1 oracle oinstall 156K May 11 17:19 arch_12b9d817_1_34_902331034.dbf
-rw-r----- 1 oracle oinstall 2.0K May 11 17:16 arch_12b9d817_1_33_902331034.dbf
[oracle@rhel64 arch]$


[oracle@rhel64 rman_hot]$ ls -lht
total 2.2G
-rw-r----- 1 oracle oinstall 9.7M May 11 17:20 control_PROD_20160511_1gr5b96e_1_1.bak
-rw-r----- 1 oracle oinstall  16K May 11 17:20 ar_PROD_20160511_1fr5b96d_1_1.bak
-rw-r----- 1 oracle oinstall 428M May 11 17:20 db_PROD_20160511_1er5b95k_1_1.bak
-rw-r----- 1 oracle oinstall 674M May 11 17:19 db_PROD_20160511_1dr5b95k_1_1.bak
-rw-r----- 1 oracle oinstall 157K May 11 17:19 ar_PROD_20160511_1cr5b95j_1_1.bak
-rw-r----- 1 oracle oinstall 3.5K May 11 17:16 ar_PROD_20160511_19r5b8v2_1_1.bak
-rw-r----- 1 oracle oinstall 674M May 11 17:16 db_PROD_20160511_17r5b8u9_1_1.bak
-rw-r----- 1 oracle oinstall 428M May 11 17:16 db_PROD_20160511_18r5b8u9_1_1.bak
[oracle@rhel64 rman_hot]$





【編寫rman備份指令碼】


[oracle@rhel64 ~]$ vi /u01/app/oracle/scripts/PROD_rman_hotbackup.sh

[oracle@rhel64 ~]$ cat /u01/app/oracle/scripts/PROD_rman_hotbackup.sh
#!/bin/sh

export PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/practice/scripts:/home/oracle/bin
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=PROD
export PATH=$PATH:$ORACLE_HOME/bin

rman target / nocatalog msglog=/u01/app/oracle/backup/rman_hot/PROD_hotrman_`date +%Y%m%d-%H%M%S`.log <<eof
<EOF
run{
crosscheck backup;
allocate channel c1 device type disk;
allocate channel c2 device type disk;
backup database format '/u01/app/oracle/backup/rman_hot/db_%d_%T_%U.bak'
       plus archivelog format '/u01/app/oracle/backup/rman_hot/ar_%d_%T_%U.bak';
backup current controlfile format '/u01/app/oracle/backup/rman_hot/control_%d_%T_%U.bak';
report obsolete device type disk;
delete noprompt obsolete device type disk;
delete noprompt expired backup device type disk;
release channel c1;
release channel c2;
}

EOF
exit
[oracle@rhel64 ~]$



[oracle@rhel64 ~]$ chmod a+x /u01/app/oracle/scripts/PROD_rman_hotbackup.sh
[oracle@rhel64 ~]$ ls -l /u01/app/oracle/scripts/
total 4
-rwxr-xr-x 1 oracle oinstall 916 May 11 17:29 PROD_rman_hotbackup.sh
[oracle@rhel64 ~]$



手動執行指令碼測試

[oracle@rhel64 ~]$ /u01/app/oracle/scripts/PROD_rman_hotbackup.sh
RMAN> RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> RMAN> RMAN> [oracle@rhel64 ~]$
[oracle@rhel64 ~]$

檢視生成備份檔案及日誌
[oracle@rhel64 rman_hot]$ ls -lht
total 2.2G
-rw-r--r-- 1 oracle oinstall 9.0K May 11 17:31 PROD_hotrman_20160511-173040.log
-rw-r----- 1 oracle oinstall 9.7M May 11 17:31 control_PROD_20160511_1mr5b9qt_1_1.bak
-rw-r----- 1 oracle oinstall 3.5K May 11 17:31 ar_PROD_20160511_1lr5b9qs_1_1.bak
-rw-r----- 1 oracle oinstall 674M May 11 17:30 db_PROD_20160511_1jr5b9q3_1_1.bak
-rw-r----- 1 oracle oinstall 429M May 11 17:30 db_PROD_20160511_1kr5b9q3_1_1.bak
-rw-r----- 1 oracle oinstall 536K May 11 17:30 ar_PROD_20160511_1ir5b9q1_1_1.bak
-rw-r----- 1 oracle oinstall  16K May 11 17:20 ar_PROD_20160511_1fr5b96d_1_1.bak
-rw-r----- 1 oracle oinstall 428M May 11 17:20 db_PROD_20160511_1er5b95k_1_1.bak
-rw-r----- 1 oracle oinstall 674M May 11 17:19 db_PROD_20160511_1dr5b95k_1_1.bak
[oracle@rhel64 rman_hot]$


檢視備份日誌
[oracle@rhel64 rman_hot]$ cat PROD_hotrman_20160511-173040.log

Recovery Manager: Release 11.2.0.3.0 - Production on Wed May 11 17:30:40 2016

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

connected to target database: PROD (DBID=314169367)
using target database control file instead of recovery catalog

RMAN>
RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13>
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=48 device type=DISK
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_17r5b8u9_1_1.bak RECID=39 STAMP=911582153
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_18r5b8u9_1_1.bak RECID=40 STAMP=911582156
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_19r5b8v2_1_1.bak RECID=41 STAMP=911582178
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-05 RECID=43 STAMP=911582182
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_1cr5b95j_1_1.bak RECID=44 STAMP=911582387
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_1dr5b95k_1_1.bak RECID=45 STAMP=911582388
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_1er5b95k_1_1.bak RECID=46 STAMP=911582392
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_1fr5b96d_1_1.bak RECID=47 STAMP=911582413
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/backup/rman_hot/control_PROD_20160511_1gr5b96e_1_1.bak RECID=48 STAMP=911582415
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-06 RECID=49 STAMP=911582416
Crosschecked 10 objects


released channel: ORA_DISK_1
allocated channel: c1
channel c1: SID=48 device type=DISK

allocated channel: c2
channel c2: SID=49 device type=DISK


Starting backup at 11-MAY-16
current log archived
skipping archived logs of thread 1 from sequence 33 to 35; already backed up
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=36 RECID=31 STAMP=911583041
channel c1: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_1ir5b9q1_1_1.bak tag=TAG20160511T173041 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-MAY-16

Starting backup at 11-MAY-16
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/PROD/example01.dbf
channel c1: starting piece 1 at 11-MAY-16
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD/users01.dbf
channel c2: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_1jr5b9q3_1_1.bak tag=TAG20160511T173043 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:25
channel c2: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_1kr5b9q3_1_1.bak tag=TAG20160511T173043 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:25
Finished backup at 11-MAY-16

Starting backup at 11-MAY-16
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=37 RECID=32 STAMP=911583068
channel c1: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_1lr5b9qs_1_1.bak tag=TAG20160511T173108 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-MAY-16

Starting backup at 11-MAY-16
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 11-MAY-16
channel c1: finished piece 1 at 11-MAY-16
piece handle=/u01/app/oracle/backup/rman_hot/control_PROD_20160511_1mr5b9qt_1_1.bak tag=TAG20160511T173109 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-MAY-16

Starting Control File and SPFILE Autobackup at 11-MAY-16
piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-07 comment=NONE
Finished Control File and SPFILE Autobackup at 11-MAY-16

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           39     11-MAY-16        
 Backup Piece       39     11-MAY-16          /u01/app/oracle/backup/rman_hot/db_PROD_20160511_17r5b8u9_1_1.bak
Backup Set           40     11-MAY-16        
 Backup Piece       40     11-MAY-16          /u01/app/oracle/backup/rman_hot/db_PROD_20160511_18r5b8u9_1_1.bak
Archive Log          28     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_33_902331034.dbf
Backup Set           41     11-MAY-16        
 Backup Piece       41     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_19r5b8v2_1_1.bak
Backup Set           43     11-MAY-16        
 Backup Piece       43     11-MAY-16          /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-05
Archive Log          29     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_34_902331034.dbf
Backup Set           44     11-MAY-16        
 Backup Piece       44     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_1cr5b95j_1_1.bak
Backup Set           48     11-MAY-16        
 Backup Piece       48     11-MAY-16          /u01/app/oracle/backup/rman_hot/control_PROD_20160511_1gr5b96e_1_1.bak

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           39     11-MAY-16        
 Backup Piece       39     11-MAY-16          /u01/app/oracle/backup/rman_hot/db_PROD_20160511_17r5b8u9_1_1.bak
Backup Set           40     11-MAY-16        
 Backup Piece       40     11-MAY-16          /u01/app/oracle/backup/rman_hot/db_PROD_20160511_18r5b8u9_1_1.bak
Archive Log          28     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_33_902331034.dbf
Backup Set           41     11-MAY-16        
 Backup Piece       41     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_19r5b8v2_1_1.bak
Backup Set           43     11-MAY-16        
 Backup Piece       43     11-MAY-16          /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-05
Archive Log          29     11-MAY-16          /u01/app/oracle/arch/arch_12b9d817_1_34_902331034.dbf
Backup Set           44     11-MAY-16        
 Backup Piece       44     11-MAY-16          /u01/app/oracle/backup/rman_hot/ar_PROD_20160511_1cr5b95j_1_1.bak
Backup Set           48     11-MAY-16        
 Backup Piece       48     11-MAY-16          /u01/app/oracle/backup/rman_hot/control_PROD_20160511_1gr5b96e_1_1.bak
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_17r5b8u9_1_1.bak RECID=39 STAMP=911582153
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/db_PROD_20160511_18r5b8u9_1_1.bak RECID=40 STAMP=911582156
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_33_902331034.dbf RECID=28 STAMP=911582178
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_19r5b8v2_1_1.bak RECID=41 STAMP=911582178
deleted backup piece
backup piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-314169367-20160511-05 RECID=43 STAMP=911582182
deleted archived log
archived log file name=/u01/app/oracle/arch/arch_12b9d817_1_34_902331034.dbf RECID=29 STAMP=911582387
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/ar_PROD_20160511_1cr5b95j_1_1.bak RECID=44 STAMP=911582387
deleted backup piece
backup piece handle=/u01/app/oracle/backup/rman_hot/control_PROD_20160511_1gr5b96e_1_1.bak RECID=48 STAMP=911582415
Deleted 8 objects


specification does not match any backup in the repository

released channel: c1

released channel: c2

RMAN>
RMAN>

Recovery Manager complete.
[oracle@rhel64 rman_hot]$




編輯計劃任務【測試環境 每10分鐘備份一次】
[oracle@rhel64 ~]$ crontab -e
[oracle@rhel64 ~]$ crontab -l
0,10,20,30,40,50 * * * * /u01/app/oracle/scripts/PROD_rman_hotbackup.sh >> /u01/app/oracle/scripts/PROD_hotrman_`date +\%Y\%m\%d-\%H\%M\%S`.log 2>&1
[oracle@rhel64 ~]$




約半小時左右 觀察備份情況、rman備份日誌
[oracle@rhel64 rman_hot]$ ls -lh
total 2.2G
-rw-r----- 1 oracle oinstall 8.0K May 11 17:40 ar_PROD_20160511_1rr5bacd_1_1.bak
-rw-r----- 1 oracle oinstall 340K May 11 17:50 ar_PROD_20160511_1ur5baua_1_1.bak
-rw-r----- 1 oracle oinstall  10K May 11 17:50 ar_PROD_20160511_21r5bav5_1_1.bak
-rw-r----- 1 oracle oinstall 9.7M May 11 17:50 control_PROD_20160511_22r5bav6_1_1.bak
-rw-r----- 1 oracle oinstall 674M May 11 17:40 db_PROD_20160511_1pr5babk_1_1.bak
-rw-r----- 1 oracle oinstall 429M May 11 17:40 db_PROD_20160511_1qr5babk_1_1.bak
-rw-r----- 1 oracle oinstall 674M May 11 17:50 db_PROD_20160511_1vr5bauc_1_1.bak
-rw-r----- 1 oracle oinstall 429M May 11 17:50 db_PROD_20160511_20r5bauc_1_1.bak
-rw-r--r-- 1 oracle oinstall 9.0K May 11 17:31 PROD_hotrman_20160511-173040.log
-rw-r--r-- 1 oracle oinstall 9.0K May 11 17:40 PROD_hotrman_20160511-174001.log
-rw-r--r-- 1 oracle oinstall 9.0K May 11 17:50 PROD_hotrman_20160511-175001.log
[oracle@rhel64 rman_hot]$





均正常,則修改計劃任務
【生產環境,每天凌晨2點備份一次】


【編輯計劃任務】
[oracle@rhel64 ~]$ crontab -e
[oracle@rhel64 ~]$ crontab -l
0 2 * * * /u01/app/oracle/scripts/PROD_rman_fullbackup.sh >> /u01/app/oracle/scripts/PROD_hotrman_`date +\%Y\%m\%d-\%H\%M\%S`.log 2>&1



日常巡檢
每天檢視rman備份情況
1.檢視生成的備份日誌 cat /u01/app/oracle/backup/rman_hot/xxx.log
2.檢視生成的備份檔案 ls -lh /u01/app/oracle/backup/rman_hot
3.監控檔案系統空間使用  df -Th
4.監控歸檔日誌目錄  ls -lh /u01/app/oracle/arch





呂星昊
2016.5.11
</eof

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25462274/viewspace-2101587/,如需轉載,請註明出處,否則將追究法律責任。

相關文章