关于Oracle RMAN进行的一次有益测试


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;数据文件、日志文件等。

声明:
在进行测试时,http://www.eygle.com/digest/2009/02/rman_oracle10g_rac.html 给了极大的帮助,深表感谢。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3