Oracle 11g RMAN備份-RMAN的backup database plus archivelog命令背後的操作

yuntui發表於2016-11-03

--檢視當前的日誌組

sys@TESTDB11>select sequence#, group#, status from v$log;

 

 SEQUENCE#     GROUP# STATUS

---------- ---------- ----------------

        19          1 INACTIVE

        20          2 INACTIVE

        21          3 CURRENT

--檢視歸檔的日誌資訊

sys@TESTDB11>select sequence#, name, first_change#, next_change# from v$archived_log;

 

 SEQUENCE# NAME                                               FIRST_CHANGE# NEXT_CHANGE#

---------- -------------------------------------------------- ------------- ------------

        93 /archive1/1_93_813665348.dbf                             2521750      2522412

        93 /archive2/1_93_813665348.dbf                             2521750      2522412

        94 /archive1/1_94_813665348.dbf                             2522412      2523213

        94 /archive2/1_94_813665348.dbf                             2522412      2523213

        95 /archive1/1_95_813665348.dbf                             2523213      2525452

        95 /archive2/1_95_813665348.dbf                             2523213      2525452

        94 /archive1/1_94_813665348.dbf                             2522412      2523213

        94 /archive2/1_94_813665348.dbf                             2522412      2523213

        95 /archive1/1_95_813665348.dbf                             2523213      2525452

        95 /archive2/1_95_813665348.dbf                             2523213      2525452

        96 /archive1/1_96_813665348.dbf                             2525452      2526072

        96 /archive2/1_96_813665348.dbf                             2525452      2526072

         1 /archive1/1_1_823322444.dbf                              2526072      2527038

         1 /archive2/1_1_823322444.dbf                              2526072      2527038

         2 /archive1/1_2_823322444.dbf                              2527038      2527103

         2 /archive2/1_2_823322444.dbf                              2527038      2527103

         4 /archive1/1_4_823322444.dbf                              2529206      2529221

         4 /archive2/1_4_823322444.dbf                              2529206      2529221

         5 /archive1/1_5_823322444.dbf                              2529221      2529225

         5 /archive2/1_5_823322444.dbf                              2529221      2529225

         6 /archive1/1_6_823322444.dbf                              2529225      2529729

         6 /archive2/1_6_823322444.dbf                              2529225      2529729

         1 /archive1/1_1_823328120.dbf                              2529247      2545708

         1 /archive2/1_1_823328120.dbf                              2529247      2545708

         2 /archive1/1_2_823328120.dbf                              2545708      2556339

         2 /archive2/1_2_823328120.dbf                              2545708      2556339

         3 /archive1/1_3_823328120.dbf                              2556339      2556342

         3 /archive2/1_3_823328120.dbf                              2556339      2556342

         4 /archive1/1_4_823328120.dbf                              2556342      2556346

         4 /archive2/1_4_823328120.dbf                              2556342      2556346

         5 /archive1/1_5_823328120.dbf                              2556346      2556446

         5 /archive2/1_5_823328120.dbf                              2556346      2556446

         6 /archive1/1_6_823328120.dbf                              2556446      2556732

         6 /archive2/1_6_823328120.dbf                              2556446      2556732

         7 /archive1/1_7_823328120.dbf                              2556732      2557582

         7 /archive2/1_7_823328120.dbf                              2556732      2557582

         8 /archive1/1_8_823328120.dbf                              2557582      2557673

         8 /archive2/1_8_823328120.dbf                              2557582      2557673

         9 /archive1/1_9_823328120.dbf                              2557673      2557679

         9 /archive2/1_9_823328120.dbf                              2557673      2557679

        10 /archive1/1_10_823328120.dbf                             2557679      2557683

        10 /archive2/1_10_823328120.dbf                             2557679      2557683

        11 /archive1/1_11_823328120.dbf                             2557683      2558272

        11 /archive2/1_11_823328120.dbf                             2557683      2558272

        12 /archive1/1_12_823328120.dbf                             2558272      2558275

        12 /archive2/1_12_823328120.dbf                             2558272      2558275

        13 /archive1/1_13_823328120.dbf                             2558275      2558279

        13 /archive2/1_13_823328120.dbf                             2558275      2558279

        14 /archive1/1_14_823328120.dbf                             2558279      2562366

        14 /archive2/1_14_823328120.dbf                             2558279      2562366

        15 /archive1/1_15_823328120.dbf                             2562366      2564946

        15 /archive2/1_15_823328120.dbf                             2562366      2564946

        16 /archive1/1_16_823328120.dbf                             2564946      2591557

        16 /archive2/1_16_823328120.dbf                             2564946      2591557

        17 /archive1/1_17_823328120.dbf                             2591557      2594600

        17 /archive2/1_17_823328120.dbf                             2591557      2594600

        18 /archive1/1_18_823328120.dbf                             2594600      2614512

        18 /archive2/1_18_823328120.dbf                             2594600      2614512

        19 /archive1/1_19_823328120.dbf                             2614512      2623468

        19 /archive2/1_19_823328120.dbf                             2614512      2623468

        20 /archive1/1_20_823328120.dbf                             2623468      2642417

        20 /archive2/1_20_823328120.dbf                             2623468      2642417

 

62 rows selected.

 

--進行整個庫和歸檔的備份

RMAN> backup database plus archivelog;

 

 

Starting backup at 2013-08-14 04:48:25

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=93 RECID=2 STAMP=823320816

input archived log thread=1 sequence=94 RECID=8 STAMP=823322447

input archived log thread=1 sequence=95 RECID=9 STAMP=823322447

input archived log thread=1 sequence=96 RECID=12 STAMP=823322448

channel ORA_DISK_1: starting piece 1 at 2013-08-14 04:48:25

channel ORA_DISK_1: finished piece 1 at 2013-08-14 04:48:28

piece handle=/pooldisk02/backup03/1ioh8ekp_1_1 tag=TAG20130814T044825 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=1 RECID=14 STAMP=823323373

input archived log thread=1 sequence=2 RECID=15 STAMP=823323515

input archived log thread=1 sequence=4 RECID=18 STAMP=823328120

input archived log thread=1 sequence=5 RECID=20 STAMP=823328120

input archived log thread=1 sequence=6 RECID=21 STAMP=823328120

channel ORA_DISK_1: starting piece 1 at 2013-08-14 04:48:28

channel ORA_DISK_1: finished piece 1 at 2013-08-14 04:48:29

piece handle=/pooldisk02/backup03/1joh8eks_1_1 tag=TAG20130814T044825 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=1 RECID=24 STAMP=823349716

input archived log thread=1 sequence=2 RECID=26 STAMP=823363531

input archived log thread=1 sequence=3 RECID=28 STAMP=823363532

input archived log thread=1 sequence=4 RECID=30 STAMP=823363534

input archived log thread=1 sequence=5 RECID=32 STAMP=823363729

input archived log thread=1 sequence=6 RECID=34 STAMP=823363769

input archived log thread=1 sequence=7 RECID=36 STAMP=823363777

input archived log thread=1 sequence=8 RECID=37 STAMP=823363948

input archived log thread=1 sequence=9 RECID=40 STAMP=823363951

input archived log thread=1 sequence=10 RECID=42 STAMP=823363954

input archived log thread=1 sequence=11 RECID=44 STAMP=823364155

input archived log thread=1 sequence=12 RECID=46 STAMP=823364156

input archived log thread=1 sequence=13 RECID=48 STAMP=823364158

input archived log thread=1 sequence=14 RECID=50 STAMP=823364525

input archived log thread=1 sequence=15 RECID=51 STAMP=823364546

input archived log thread=1 sequence=16 RECID=54 STAMP=823365806

input archived log thread=1 sequence=17 RECID=55 STAMP=823367914

input archived log thread=1 sequence=18 RECID=58 STAMP=823384872

input archived log thread=1 sequence=19 RECID=59 STAMP=823392030

input archived log thread=1 sequence=20 RECID=62 STAMP=823408208

input archived log thread=1 sequence=21 RECID=63 STAMP=823409305

channel ORA_DISK_1: starting piece 1 at 2013-08-14 04:48:29

channel ORA_DISK_1: finished piece 1 at 2013-08-14 04:48:44

piece handle=/pooldisk02/backup03/1koh8ekt_1_1 tag=TAG20130814T044825 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15

Finished backup at 2013-08-14 04:48:44

 

Starting backup at 2013-08-14 04:48:45

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=00001 name=/oradata/system01.dbf

input datafile file number=00002 name=/oradata/sysaux01.dbf

input datafile file number=00005 name=/oradata/example01.dbf

input datafile file number=00003 name=/oradata/undotbs01.dbf

input datafile file number=00007 name=/oradata/fbtbs01.dbf

input datafile file number=00008 name=/oradata/users02.dbf

input datafile file number=00006 name=/oradata/newts01.dbf

input datafile file number=00004 name=/oradata/users01.dbf

channel ORA_DISK_1: starting piece 1 at 2013-08-14 04:48:45

channel ORA_DISK_1: finished piece 1 at 2013-08-14 04:51:10

piece handle=/pooldisk02/backup03/1loh8eld_1_1 tag=TAG20130814T044845 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:02:25

Finished backup at 2013-08-14 04:51:10

 

Starting backup at 2013-08-14 04:51:10

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=22 RECID=65 STAMP=823409470

channel ORA_DISK_1: starting piece 1 at 2013-08-14 04:51:10

channel ORA_DISK_1: finished piece 1 at 2013-08-14 04:51:11

piece handle=/pooldisk02/backup03/1moh8epu_1_1 tag=TAG20130814T045110 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 2013-08-14 04:51:11

 

Starting Control File and SPFILE Autobackup at 2013-08-14 04:51:11

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823409472_90pnrjhy_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 2013-08-14 04:51:15     

 

--再次檢視當前日誌,發現在rman備份的過程中進行了日誌切換,並將原來的當前日誌組備份了出來

sys@TESTDB11>select sequence#, group#, status from v$log;

 

 SEQUENCE#     GROUP# STATUS

---------- ---------- ----------------

        22          1 ACTIVE

        23          2 CURRENT

        21          3 INACTIVE

 

--注意:在備份日誌的時候最好多切換一個備份出來

--backup database plus archivelog等待的做法是

RMAN> run {

2> backup database;

3> sql 'alter system switch logfile';

4> backup archivelog all;

5> }

 

--備份歸檔日誌,同時刪除原來的歸檔

RMAN> backup archivelog all delete input;

 

Starting backup at 2013-08-14 05:10:45

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=1 RECID=24 STAMP=823349716

input archived log thread=1 sequence=2 RECID=25 STAMP=823363531

input archived log thread=1 sequence=3 RECID=27 STAMP=823363532

input archived log thread=1 sequence=4 RECID=30 STAMP=823363534

input archived log thread=1 sequence=5 RECID=31 STAMP=823363729

input archived log thread=1 sequence=6 RECID=33 STAMP=823363769

input archived log thread=1 sequence=7 RECID=35 STAMP=823363777

input archived log thread=1 sequence=8 RECID=37 STAMP=823363948

input archived log thread=1 sequence=9 RECID=39 STAMP=823363951

input archived log thread=1 sequence=10 RECID=42 STAMP=823363954

input archived log thread=1 sequence=11 RECID=43 STAMP=823364155

input archived log thread=1 sequence=12 RECID=46 STAMP=823364156

input archived log thread=1 sequence=13 RECID=48 STAMP=823364158

input archived log thread=1 sequence=14 RECID=49 STAMP=823364525

input archived log thread=1 sequence=15 RECID=51 STAMP=823364546

input archived log thread=1 sequence=16 RECID=54 STAMP=823365806

input archived log thread=1 sequence=17 RECID=55 STAMP=823367914

input archived log thread=1 sequence=18 RECID=57 STAMP=823384872

input archived log thread=1 sequence=19 RECID=59 STAMP=823392030

input archived log thread=1 sequence=20 RECID=61 STAMP=823408208

input archived log thread=1 sequence=21 RECID=63 STAMP=823409305

input archived log thread=1 sequence=22 RECID=66 STAMP=823409470

input archived log thread=1 sequence=23 RECID=67 STAMP=823410645

channel ORA_DISK_1: starting piece 1 at 2013-08-14 05:10:46

channel ORA_DISK_1: finished piece 1 at 2013-08-14 05:11:11

piece handle=/pooldisk02/backup03/1ooh8fum_1_1 tag=TAG20130814T051045 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25

channel ORA_DISK_1: deleting archived log(s)

archived log file name=/archive2/1_1_823328120.dbf RECID=24 STAMP=823349716

archived log file name=/archive1/1_2_823328120.dbf RECID=25 STAMP=823363531

archived log file name=/archive1/1_3_823328120.dbf RECID=27 STAMP=823363532

archived log file name=/archive2/1_4_823328120.dbf RECID=30 STAMP=823363534

archived log file name=/archive1/1_5_823328120.dbf RECID=31 STAMP=823363729

archived log file name=/archive1/1_6_823328120.dbf RECID=33 STAMP=823363769

archived log file name=/archive1/1_7_823328120.dbf RECID=35 STAMP=823363777

archived log file name=/archive1/1_8_823328120.dbf RECID=37 STAMP=823363948

archived log file name=/archive1/1_9_823328120.dbf RECID=39 STAMP=823363951

archived log file name=/archive2/1_10_823328120.dbf RECID=42 STAMP=823363954

archived log file name=/archive1/1_11_823328120.dbf RECID=43 STAMP=823364155

archived log file name=/archive2/1_12_823328120.dbf RECID=46 STAMP=823364156

archived log file name=/archive2/1_13_823328120.dbf RECID=48 STAMP=823364158

archived log file name=/archive1/1_14_823328120.dbf RECID=49 STAMP=823364525

archived log file name=/archive1/1_15_823328120.dbf RECID=51 STAMP=823364546

archived log file name=/archive2/1_16_823328120.dbf RECID=54 STAMP=823365806

archived log file name=/archive1/1_17_823328120.dbf RECID=55 STAMP=823367914

archived log file name=/archive1/1_18_823328120.dbf RECID=57 STAMP=823384872

archived log file name=/archive1/1_19_823328120.dbf RECID=59 STAMP=823392030

archived log file name=/archive1/1_20_823328120.dbf RECID=61 STAMP=823408208

archived log file name=/archive1/1_21_823328120.dbf RECID=63 STAMP=823409305

archived log file name=/archive2/1_22_823328120.dbf RECID=66 STAMP=823409470

archived log file name=/archive1/1_23_823328120.dbf RECID=67 STAMP=823410645

Finished backup at 2013-08-14 05:11:12

 

Starting Control File and SPFILE Autobackup at 2013-08-14 05:11:12

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823410672_90poy1w2_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 2013-08-14 05:11:15

 

--檢視原來的位置,都已經被刪除了

[oracle@S1011:/u02/block_change_tracking2]$ cd /archive1

[oracle@S1011:/archive1]$ ls

 

--控制檔案和初始化引數檔案的備份,可以自動進行,也可以在rman中手工進行

--1.rman中手工備份當前的控制檔案

RMAN> backup current controlfile;

 

Starting backup at 2013-08-14 05:14:42

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

channel ORA_DISK_1: starting piece 1 at 2013-08-14 05:14:43

channel ORA_DISK_1: finished piece 1 at 2013-08-14 05:14:44

piece handle=/pooldisk02/backup03/1qoh8g62_1_1 tag=TAG20130814T051442 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 2013-08-14 05:14:44

 

Starting Control File and SPFILE Autobackup at 2013-08-14 05:14:44

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823410884_90pp4o15_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 2013-08-14 05:14:45

 

--進行自動備份,只需要開啟相應的引數

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 1 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> CONFIGURE CONTROLFILE AUTOBACKUP ON;

 

old RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored

 

--或備份集中包含資料檔案1,就會自動備份控制檔案

RMAN> backup tablespace system;

 

Starting backup at 2013-08-14 05:17:03

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=00001 name=/oradata/system01.dbf

channel ORA_DISK_1: starting piece 1 at 2013-08-14 05:17:03

channel ORA_DISK_1: finished piece 1 at 2013-08-14 05:17:58

piece handle=/pooldisk02/backup03/1soh8gaf_1_1 tag=TAG20130814T051703 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55

Finished backup at 2013-08-14 05:17:58

 

Starting Control File and SPFILE Autobackup at 2013-08-14 05:17:58

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823411078_90ppbqdv_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 2013-08-14 05:18:01

 

--備份初始化引數檔案

RMAN> backup spfile;

 

Starting backup at 2013-08-14 05:20:44

using channel ORA_DISK_1

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 05:20:44

channel ORA_DISK_1: finished piece 1 at 2013-08-14 05:20:45

piece handle=/pooldisk02/backup03/1uoh8ghc_1_1 tag=TAG20130814T052044 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 2013-08-14 05:20:45

 

Starting Control File and SPFILE Autobackup at 2013-08-14 05:20:45

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823411245_90pphxjk_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 2013-08-14 05:20:46

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

相關文章