程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle數據庫基礎 >> 關於Oracle RMAN進行的一次有益測試

關於Oracle RMAN進行的一次有益測試

編輯:Oracle數據庫基礎
 1 測試說明

  進行異機數據庫之間的數據備份與恢復測試。假定條件如下:

  (1) 異機之間的數據備份與恢復;

  (2) 非DataGuard應用;

  (3) 源數據存儲采用ASM形式,恢復目標數據存儲采用文件系統;

  (4) 不使用Catalog數據庫;

  (5) RMAN備份在本地磁盤。

  2 測試環境

  2.1 主數據庫

  Test01:192.1.11.140

  OS :Red hat Linux AS 4.0

  Oracle :10.2.0.1

  數據存儲:ASM

  實例:單實例

  Test02:192.1.11.141

  OS :Red hat Linux AS 4.0

  Oracle :10.2.0.1

  數據存儲:文件系統

  實例:單實例

3 數據庫備份
3.1 備份腳本
CONFIGURE CONTROLFILE AUTOBACKUP ON;
run
{
Crosscheck backup;
Crosscheck archivelog all;
delete NOPROMPT expired backup;
delete NOPROMPT OBSOLETE;
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup full database tag 'FullBackup' format '/racbackup/bak/db_full_%T_%d_%t_%s_%p_bak0' ;
sql 'alter system archive log current';
backup format '/racbackup/bak/arch_%T_%d_%t_%s_%p_bak0' archivelog all delete input;
backup spfile include current controlfile format '/racbackup/bak/spfile_controlfile_%T_%d_%t_%s_%p_bak0';
release channel c1;
release channel c2;
release channel c3;
}

3.2 備份執行結果
[Oracle@test01 bin]$ ./rman nocatalog target /

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jul 24 13:29:18 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.

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

RMAN> show all;

RMAN configuration parameters 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 ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/app/Oracle/product/10.2.0/db_1/dbs/snapcf_bluesky.f'; # default

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

run
{
Crosscheck backup;
Crosscheck archivelog all;
delete NOPROMPT expired backup;
delete NOPROMPT OBSOLETE;
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup full database tag 'FullBackup' format '/racbackup/bak/db_full_%T_%d_%t_%s_%p_bak0' ;
sql 'alter system archive log current';
backup format '/racbackup/bak/arch_%T_%d_%t_%s_%p_bak0' archivelog all delete input;
backup spfile include current controlfile format '/racbackup/bak/spfile_controlfile_%T_%d_%t_%s_%p_bak0';
release channel c1;
release channel c2;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
release channel c3;
}

RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17>
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
validation succeeded for archived log
archive log filename=+DG01/bluesky/1_1_693060487.dbf recid=2 stamp=693062811
validation succeeded for archived log
archive log filename=+DG01/bluesky/1_2_693060487.dbf recid=1 stamp=693062808
validation succeeded for archived log
archive log filename=+DG01/bluesky/1_3_693060487.dbf recid=3 stamp=693062813
validation succeeded for archived log
archive log filename=+DG01/bluesky/1_4_693060487.dbf recid=4 stamp=693062815
validation succeeded for archived log
archive log filename=+DG01/bluesky/1_5_693060487.dbf recid=5 stamp=693062815
validation succeeded for archived log
archive log filename=+DG01/bluesky/1_6_693060487.dbf recid=6 stamp=693062816
validation succeeded for archived log
archive log filename=+DG01/bluesky/1_7_693060487.dbf recid=7 stamp=693062822
Crosschecked 7 objects


using channel ORA_DISK_1

RMAN retention policy will be applIEd to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
no obsolete backups found

released channel: ORA_DISK_1
allocated channel: c1
channel c1: sid=155 devtype=DISK

allocated channel: c2
channel c2: sid=138 devtype=DISK

allocated channel: c3
channel c3: sid=154 devtype=DISK

Starting backup at 24-JUL-09
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00001 name=+DG01/bluesky/datafile/system.265.693060399
input datafile fno=00004 name=+DG01/bluesky/datafile/users.268.693060403
channel c1: starting pIEce 1 at 24-JUL-09
channel c2: starting full datafile backupset
channel c2: specifying datafile(s) in backupset
input datafile fno=00003 name=+DG01/bluesky/datafile/sysaux.266.693060401
input datafile fno=00002 name=+DG01/bluesky/datafile/undotbs1.267.693060403
channel c2: starting pIEce 1 at 24-JUL-09
channel c2: finished pIEce 1 at 24-JUL-09
pIEce handle=/racbackup/bak/db_full_20090724_BLUESKY_693062990_2_1_bak0 tag=FULLBACKUP comment=NONE
channel c2: backup set complete, elapsed time: 00:00:56
channel c1: finished pIEce 1 at 24-JUL-09
pIEce handle=/racbackup/bak/db_full_20090724_BLUESKY_693062990_1_1_bak0 tag=FULLBACKUP comment=NONE
channel c1: backup set complete, elapsed time: 00:01:17
Finished backup at 24-JUL-09

Starting Control File and SPFILE Autobackup at 24-JUL-09
pIEce handle=/opt/app/Oracle/product/10.2.0/db_1/dbs/c-1554831300-20090724-00 comment=NONE
Finished Control File and SPFILE Autobackup at 24-JUL-09

sql statement: alter system archive log current

Starting backup at 24-JUL-09
current log archived
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=1 recid=2 stamp=693062811
channel c1: starting pIEce 1 at 24-JUL-09
channel c2: starting archive log backupset
channel c2: specifying archive log(s) in backup set
input archive log thread=1 sequence=8 recid=8 stamp=693063079
input archive log thread=1 sequence=9 recid=9 stamp=693063079
channel c2: starting pIEce 1 at 24-JUL-09
channel c3: starting archive log backupset
channel c3: specifying archive log(s) in backup set
input archive log thread=1 sequence=2 recid=1 stamp=693062808
input archive log thread=1 sequence=3 recid=3 stamp=693062813
input archive log thread=1 sequence=4 recid=4 stamp=693062815
channel c3: starting pIEce 1 at 24-JUL-09
channel c2: finished pIEce 1 at 24-JUL-09
pIEce handle=/racbackup/bak/arch_20090724_BLUESKY_693063080_5_1_bak0 tag=TAG20090724T133119 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:01
channel c2: deleting archive log(s)
archive log filename=+DG01/bluesky/1_8_693060487.dbf recid=8 stamp=693063079
archive log filename=+DG01/bluesky/1_9_693060487.dbf recid=9 stamp=693063079
channel c3: finished pIEce 1 at 24-JUL-09
pIEce handle=/racbackup/bak/arch_20090724_BLUESKY_693063080_6_1_bak0 tag=TAG20090724T133119 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:03
channel c3: deleting archive log(s)
archive log filename=+DG01/bluesky/1_2_693060487.dbf recid=1 stamp=693062808
archive log filename=+DG01/bluesky/1_3_693060487.dbf recid=3 stamp=693062813
archive log filename=+DG01/bluesky/1_4_693060487.dbf recid=4 stamp=693062815
channel c1: finished pIEce 1 at 24-JUL-09
pIEce handle=/racbackup/bak/arch_20090724_BLUESKY_693063080_4_1_bak0 tag=TAG20090724T133119 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:04
channel c1: deleting archive log(s)
archive log filename=+DG01/bluesky/1_1_693060487.dbf recid=2 stamp=693062811
channel c2: starting archive log backupset
channel c2: specifying archive log(s) in backup set
input archive log thread=1 sequence=5 recid=5 stamp=693062815
input archive log thread=1 sequence=6 recid=6 stamp=693062816
input archive log thread=1 sequence=7 recid=7 stamp=693062822
channel c2: starting pIEce 1 at 24-JUL-09
channel c2: finished pIEce 1 at 24-JUL-09
pIEce handle=/racbackup/bak/arch_20090724_BLUESKY_693063083_7_1_bak0 tag=TAG20090724T133119 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:03
channel c2: deleting archive log(s)
archive log filename=+DG01/bluesky/1_5_693060487.dbf recid=5 stamp=693062815
archive log filename=+DG01/bluesky/1_6_693060487.dbf recid=6 stamp=693062816
archive log filename=+DG01/bluesky/1_7_693060487.dbf recid=7 stamp=693062822
Finished backup at 24-JUL-09

Starting backup at 24-JUL-09
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
including current control file in backupset
channel c1: starting pIEce 1 at 24-JUL-09
channel c2: starting full datafile backupset
channel c2: specifying datafile(s) in backupset
channel c1: finished pIEce 1 at 24-JUL-09
pIEce handle=/racbackup/bak/spfile_controlfile_20090724_BLUESKY_693063086_8_1_bak0 tag=TAG20090724T133126 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:03
including current SPFILE in backupset
channel c2: starting pIEce 1 at 24-JUL-09
channel c2: finished pIEce 1 at 24-JUL-09
pIEce handle=/racbackup/bak/spfile_controlfile_20090724_BLUESKY_693063088_9_1_bak0 tag=TAG20090724T133126 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:02
Finished backup at 24-JUL-09

Starting Control File and SPFILE Autobackup at 24-JUL-09
pIEce handle=/opt/app/Oracle/product/10.2.0/db_1/dbs/c-1554831300-20090724-01 comment=NONE
Finished Control File and SPFILE Autobackup at 24-JUL-09

released channel: c1

released channel: c2

released channel: c3

RMAN>

4 目標數據庫恢復
4.1 恢復參數文件
[Oracle@test02 bin]$ ./rman nocatalog target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Nov 28 13:37:59 2008

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database (not started)

RMAN> startup nomount

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/opt/app/Oracle/product/10.2.0/db_1/dbs/initbluesky.ora'

starting Oracle instance without parameter file for retrival of spfile
Oracle instance started

Total System Global Area 159383552 bytes

Fixed Size 1218268 bytes
Variable Size 54528292 bytes
Database Buffers 100663296 bytes
Redo Buffers 2973696 bytes

【恢復參數文件】
RMAN>

RMAN> run
2> {
3> restore spfile from '/racbackup/bak/spfile_controlfile_20090724_BLUESKY_693063088_9_1_bak0';
4> }

Starting restore at 28-NOV-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK

channel ORA_DISK_1: autobackup found: /racbackup/bak/spfile_controlfile_20090724_BLUESKY_693063088_9_1_bak0
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 28-NOV-08

RMAN>

 

4.2 恢復控制文件

【恢復控制文件】
RMAN> run
2> {
3> restore controlfile from '/racbackup/bak/spfile_controlfile_20090724_BLUESKY_693063086_8_1_bak0';
4> }

Starting restore at 28-NOV-08
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output filename=/opt/app/Oracle/product/10.2.0/db_1/dbs/cntrlbluesky.dbf
Finished restore at 28-NOV-08

RMAN>
【恢復控制文件成功,注意控制文件的輸出位置】
【此時如果mount ,則由於控制文件的位置不同造成失敗】
【修改參數文件,指定控制文件的位置】

[Oracle@test02 racbackup]$ ls
bak
[oracle@test02 racbackup]$ cp /opt/app/Oracle/product/10.2.0/db_1/dbs/cntrlbluesky.dbf ./
[Oracle@test02 racbackup]$ ls -l
total 6912
drwxr-xr-x 2 Oracle oinstall 4096 Jul 24 2009 bak
-rw-r----- 1 Oracle oinstall 7061504 Nov 28 13:44 cntrlbluesky.dbf
[Oracle@test02 racbackup]$

SQL> shutdown abort
Oracle instance shut down.
SQL>
SQL> startup nomount
Oracle instance started.

Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 92276304 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
SQL> show parameter spfile;

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /opt/app/Oracle/product/10.2.0
/db_1/dbs/spfilebluesky.ora
SQL> alter system set control_files='/opt/app/Oracle/product/10.2.0/db_1/dbs/cntrlbluesky.dbf' scope=spfile;

System altered.

SQL> shutdown abort
Oracle instance shut down.
SQL> startup mount
Oracle instance started.

Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 92276304 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL>
【至此數據庫處於mount狀態】


4.3 數據文件RESTORE
[Oracle@test02 bin]$ ./rman nocatalog target /

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Nov 28 13:49:02 2008

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: BLUESKY (DBID=1554831300, not open)
using target database control file instead of recovery catalog

RMAN> list backup of database;


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

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 146.06M DISK 00:00:45 24-JUL-09
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: FULLBACKUP
PIEce Name: /racbackup/bak/db_full_20090724_BLUESKY_693062990_2_1_bak0
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 453685 24-JUL-09 +DG01/bluesky/datafile/undotbs1.267.693060403
3 Full 453685 24-JUL-09 +DG01/bluesky/datafile/sysaux.266.693060401

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 348.96M DISK 00:01:15 24-JUL-09
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: FULLBACKUP
PIEce Name: /racbackup/bak/db_full_20090724_BLUESKY_693062990_1_1_bak0
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 453684 24-JUL-09 +DG01/bluesky/datafile/system.265.693060399
4 Full 453684 24-JUL-09 +DG01/bluesky/datafile/users.268.693060403

RMAN>
【可以看到有4個數據文件,由於源數據庫采用ASM存儲,需要進行轉儲resotre】


run{
set newname for datafile 1 to '/racbackup/system01.dbf';
set newname for datafile 2 to '/racbackup/undotbs01.dbf';
set newname for datafile 3 to '/racbackup/sysaux01.dbf';
set newname for datafile 4 to '/racbackup/users01.dbf';
restore database;
switch datafile all;
}

 

RMAN> run{
2> set newname for datafile 1 to '/racbackup/system01.dbf';
3> set newname for datafile 2 to '/racbackup/undotbs01.dbf';
4> set newname for datafile 3 to '/racbackup/sysaux01.dbf';
5> set newname for datafile 4 to '/racbackup/users01.dbf';
6> restore database;
7> switch datafile all;
8> }

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 28-NOV-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /racbackup/undotbs01.dbf
restoring datafile 00003 to /racbackup/sysaux01.dbf
channel ORA_DISK_1: reading from backup pIEce /racbackup/bak/db_full_20090724_BLUESKY_693062990_2_1_bak0
channel ORA_DISK_1: restored backup pIEce 1
pIEce handle=/racbackup/bak/db_full_20090724_BLUESKY_693062990_2_1_bak0 tag=FULLBACKUP
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /racbackup/system01.dbf
restoring datafile 00004 to /racbackup/users01.dbf
channel ORA_DISK_1: reading from backup pIEce /racbackup/bak/db_full_20090724_BLUESKY_693062990_1_1_bak0
channel ORA_DISK_1: restored backup pIEce 1
pIEce handle=/racbackup/bak/db_full_20090724_BLUESKY_693062990_1_1_bak0 tag=FULLBACKUP
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
Finished restore at 28-NOV-08

datafile 1 switched to datafile copy
input datafile copy recid=5 stamp=671982781 filename=/racbackup/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=6 stamp=671982781 filename=/racbackup/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=7 stamp=671982781 filename=/racbackup/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=8 stamp=671982781 filename=/racbackup/users01.dbf

RMAN>

[Oracle@test02 racbackup]$ pwd
/racbackup
[Oracle@test02 racbackup]$ ls -l
total 765468
drwxr-xr-x 2 Oracle oinstall 4096 Jul 24 2009 bak
-rw-r----- 1 Oracle oinstall 7061504 Nov 28 13:44 cntrlbluesky.dbf
-rw-r----- 1 Oracle oinstall 241180672 Nov 28 13:52 sysaux01.dbf
-rw-r----- 1 Oracle oinstall 503324672 Nov 28 13:52 system01.dbf
-rw-r----- 1 Oracle oinstall 26222592 Nov 28 13:52 undotbs01.dbf
-rw-r----- 1 Oracle oinstall 5251072 Nov 28 13:52 users01.dbf
[Oracle@test02 racbackup]$

【數據文件進行了轉儲,此時數據庫為mount狀態。可以看到控制文件、數據文件都已經生成。缺少redo log文件】

 

4.4 REDO LOG的處理
SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DG01/bluesky/onlinelog/group_3.272.693060493
+DG01/bluesky/onlinelog/group_2.271.693060491
+DG01/bluesky/onlinelog/group_1.270.693060487

SQL> alter database rename file '+DG01/bluesky/onlinelog/group_3.272.693060493' to '/ racbackup /redolog01';

Database altered.

SQL> alter database rename file '+DG01/bluesky/onlinelog/group_2.271.693060491' to '/ racbackup /redolog02';

Database altered.

SQL> alter database rename file '+DG01/bluesky/onlinelog/group_1.270.693060487' to '/ racbackup /redolog03';

Database altered.

4.5 RESOTRE ARCHIVELOG文件
【列舉歸檔日志的備份情況】
RMAN> list backup of archivelog all;


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

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
4 32.50K DISK 00:00:01 24-JUL-09
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20090724T133119
PIEce Name: /racbackup/bak/arch_20090724_BLUESKY_693063080_5_1_bak0

List of Archived Logs in backup set 4
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 8 453548 24-JUL-09 453729 24-JUL-09
1 9 453729 24-JUL-09 453734 24-JUL-09

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
5 3.00K DISK 00:00:01 24-JUL-09
BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20090724T133119
PIEce Name: /racbackup/bak/arch_20090724_BLUESKY_693063080_6_1_bak0

List of Archived Logs in backup set 5
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 2 453534 24-JUL-09 453536 24-JUL-09
1 3 453536 24-JUL-09 453539 24-JUL-09
1 4 453539 24-JUL-09 453541 24-JUL-09

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
6 31.85M DISK 00:00:03 24-JUL-09
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20090724T133119
PIEce Name: /racbackup/bak/arch_20090724_BLUESKY_693063080_4_1_bak0

List of Archived Logs in backup set 6
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 1 446075 24-JUL-09 453534 24-JUL-09

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
7 3.00K DISK 00:00:02 24-JUL-09
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20090724T133119
PIEce Name: /racbackup/bak/arch_20090724_BLUESKY_693063083_7_1_bak0

List of Archived Logs in backup set 7
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 5 453541 24-JUL-09 453543 24-JUL-09
1 6 453543 24-JUL-09 453545 24-JUL-09
1 7 453545 24-JUL-09 453548 24-JUL-09

RMAN>

 

【恢復歸檔日志】
RMAN> run{
2> set archivelog destination to '/racbackup';
3> restore archivelog all;
4> }

executing command: SET ARCHIVELOG DESTINATION

Starting restore at 28-NOV-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=158 devtype=DISK

channel ORA_DISK_1: starting archive log restore to user-specifIEd destination
archive log destination=/racbackup
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=8
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=9
channel ORA_DISK_1: reading from backup pIEce /racbackup/bak/arch_20090724_BLUESKY_693063080_5_1_bak0
channel ORA_DISK_1: restored backup pIEce 1
pIEce handle=/racbackup/bak/arch_20090724_BLUESKY_693063080_5_1_bak0 tag=TAG20090724T133119
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting archive log restore to user-specifIEd destination
archive log destination=/racbackup
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=2
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=3
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=4
channel ORA_DISK_1: reading from backup pIEce /racbackup/bak/arch_20090724_BLUESKY_693063080_6_1_bak0
channel ORA_DISK_1: restored backup pIEce 1
pIEce handle=/racbackup/bak/arch_20090724_BLUESKY_693063080_6_1_bak0 tag=TAG20090724T133119
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting archive log restore to user-specifIEd destination
archive log destination=/racbackup
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=1
channel ORA_DISK_1: reading from backup pIEce /racbackup/bak/arch_20090724_BLUESKY_693063080_4_1_bak0
channel ORA_DISK_1: restored backup pIEce 1
pIEce handle=/racbackup/bak/arch_20090724_BLUESKY_693063080_4_1_bak0 tag=TAG20090724T133119
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting archive log restore to user-specifIEd destination
archive log destination=/racbackup
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=5
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=6
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=7
channel ORA_DISK_1: reading from backup pIEce /racbackup/bak/arch_20090724_BLUESKY_693063083_7_1_bak0
channel ORA_DISK_1: restored backup pIEce 1
pIEce handle=/racbackup/bak/arch_20090724_BLUESKY_693063083_7_1_bak0 tag=TAG20090724T133119
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 28-NOV-08

RMAN>
【恢復歸檔日志成功。】


4.6 Recover DATABASE
基本可以進行數據庫的Recover了。突然想起參數文件制定的歸檔路徑沒有改動。
SQL> show parameter log_archive_dest_1

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1 string LOCATION=+DG01/bluesky/
SQL> alter system set log_archive_dest_1='LOCATION=/racbackup';

System altered.

SQL> show parameter log_archive_dest_1

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1 string LOCATION=/racbackup
log_archive_dest_10 string
SQL>

RMAN> recover database ;

Starting recover at 28-NOV-08
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 8 is already on disk as file /racbackup/1_8_693060487.dbf
archive log thread 1 sequence 9 is already on disk as file /racbackup/1_9_693060487.dbf
archive log filename=/racbackup/1_8_693060487.dbf thread=1 sequence=8
archive log filename=/racbackup/1_9_693060487.dbf thread=1 sequence=9
unable to find archive log
archive log thread=1 sequence=10
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/28/2008 14:21:03
RMAN-06054: media recovery requesting unknown log: thread 1 seq 10 lowscn 453734

RMAN>

【正常,聯機日志丟失,不能進行完整性恢復。只能進行不完成恢復。】


4.7 開啟數據庫
SQL> alter database open resetlogs;

Database altered.

SQL>
SQL> select * from t;

ID
----------
1
2
3

SQL>
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /racbackup
Oldest online log sequence 0
Next log sequence to archive 1
Current log sequence 1
SQL>

4.8 後續處理
注意,此時數據庫可以打開,但是個別參數,臨時表空間等內容需要重新建立。
【默認表空間的數據文件不存儲】
SQL> select file_name from dba_temp_files;
select file_name from dba_temp_files
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: '+DG01/bluesky/tempfile/temp.273.693060515'


SQL>
SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
+DG01/bluesky/tempfile/temp.273.693060515
/racbackup/temp01.dbf

【創建臨時表空間】
SQL> create temporary tablespace TEMP1 tempfile '/racbackup/temp01.dbf' size 50M autoextend off;

Tablespace created.

【修改數據庫默認臨時表空間為TEMP1】

SQL> alter database default temporary tablespace TEMP1;

Database altered.

【刪除原默認表空間】
SQL> drop tablespace TEMP including contents and datafiles;

Tablespace dropped.

5 小結
總結本次測試:
(1) ASM作為Oracle的一種數據存儲方式,可理解為文件系統存儲,兩者之間可以進行互換;
(2) 備份腳本很重要,只有備份了,才能恢復,不要奢望其他的投機方式。本次測試,假定了一種極端情況即源數據庫除備份集外,其他部分全部無可獲取。所以,備份集中要包括參數文件、歸檔日志、數據文件、控制文件等。
(3) 測試過程中由於采用nocatalog方式,所有備份系統記錄在控制文件中。建議采用備份數據文件,備份歸檔日志,備份參數文件,備份控制文件的順序編寫備份腳本。如果先備份了控制文件,再備份歸檔日志,則可能在恢復時不能list backup of archivelog all;的全部需要內容。
(4) 由於源數據庫redo log丟失,則目標數據庫只能進行不完整恢復。
(5) 由於源數據庫采用ASM存儲,restore datafile時,需要用到轉儲方式。
(6) 數據庫的啟動/關閉順序很重要,每個步驟環環相套,完全理解其過程,非常重要。總結一下Linux/UNIX的過程;
a) Nomount,與$Oracle_SID的設置相關,與參數文件相關。(為什麼在RMAN下,沒有參數文件也能啟動,我有點沒有想明白,到底用的什麼參數文件,還是RMAN恢復的一種特例情況(技巧)?)
b) Mount,控制文件;
c) Open;數據文件、日志文件等。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved