ITPub博客

首页 > Linux操作系统 > Linux操作系统 > RMAN异机恢复测试

RMAN异机恢复测试

原创 Linux操作系统 作者:victor1010 时间:2008-11-28 09:02:41 0 删除 编辑

 


1、备份
[oracle@dbServer ~]$ /u01/app/oracle/9.2.0/bin/rman target /

Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: DEMO1 (DBID=3671812873)

RMAN> show all;

using target database controlfile instead of recovery catalog
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 ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/backup/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
RMAN configuration has no stored or default parameters
RMAN configuration has no stored or default parameters
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/9.2.0/dbs/snapcf_demo1.f'; # default

RMAN> backup database;

Starting backup at 19-NOV-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=18 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/demo1/system01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/demo1/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/demo1/example01.dbf
input datafile fno=00008 name=/u01/app/oracle/oradata/demo1/users01.dbf
input datafile fno=00009 name=/u01/app/oracle/oradata/demo1/xdb01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/demo1/indx01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/demo1/drsys01.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/demo1/odm01.dbf
input datafile fno=00007 name=/u01/app/oracle/oradata/demo1/tools01.dbf
channel ORA_DISK_1: starting piece 1 at 19-NOV-08
channel ORA_DISK_1: finished piece 1 at 19-NOV-08
piece handle=/u01/app/oracle/9.2.0/dbs/05k03hfi_1_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:06
Finished backup at 19-NOV-08

Starting Control File and SPFILE Autobackup at 19-NOV-08
piece handle=/u01/app/backup/c-3671812873-20081119-00 comment=NONE
Finished Control File and SPFILE Autobackup at 19-NOV-08

2、准备PFILE
[oracle@dbServer backup]$ sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on Wed Nov 19 14:01:07 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production

SQL> create pfile ='/u02/backup/pfile.ora ' from spfile;

File created.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
3、COPY 备份文件
cp /u01/app/backup/c-3671812873-20081119-00 control.bk
cp /u01/app/oracle/9.2.0/dbs/05k03hfi_1_1 05k03hfi_1_1

[oracle@dbServer backup]$ ls -l
total 538760
-rw-r-----  1 oracle oinstall 549208064 Nov 19 13:53 05k03hfi_1_1
-rw-r-----  1 oracle oinstall   1933312 Nov 19 13:52 control.bk
-rw-r--r--  1 oracle oinstall      1301 Nov 19 14:01 pfile.ora
[oracle@dbServer backup]$

4、创建路径
mkdir -p /u02/bdump
mkdir -p /u02/cdump
mkdir -p /u02/udump
mkdir -p /u02/arch
mkdir -p /u02/data
5、编辑PFILE
*.aq_tm_processes=1
*.background_dump_dest='/u02/bdump'
*.compatible='9.2.0.0.0'
*.control_files='/u02/data/control01.ctl','/u02/data/control02.ctl','/u02/data/control03.ctl'
*.core_dump_dest='/u02/cdump'
*.db_block_size=4096
*.db_cache_size=33554432
*.db_domain=''
*.db_file_multiblock_read_count=8
*.db_name='demo1'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=demo1XDB)'
*.fast_start_mttr_target=300
*.hash_join_enabled=FALSE
*.instance_name='demo1'
*.java_pool_size=83886080
*.job_queue_processes=10
*.large_pool_size=16777216
*.log_archive_dest_1='location=/u02/arch'
#*.log_archive_dest_2='service=standby reopen=300'
#*.log_archive_dest_3='service=demo11  LGWR  SYNC'
*.log_archive_start=TRUE
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=150
*.query_rewrite_enabled='FALSE'
*.remote_login_passwordfile='EXCLUSIVE'
*.remote_os_authent=TRUE
*.remote_os_roles=TRUE
*.shared_pool_size=83886080
*.sort_area_size=524288
#*.standby_archive_dest='/u02/oradata'
#*.standby_file_management='AUTO'
*.star_transformation_enabled='FALSE'
*.timed_statistics=TRUE
*.undo_management='AUTO'
*.undo_retention=900
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u02/udump'

6、statup nomount

SQL> startup nomount pfile=/u02/backup/init.ora
ORACLE instance started.

Total System Global Area
 236000356 bytes

Fixed Size
    451684 bytes

Variable Size
 201326592 bytes

Database Buffers
  33554432 bytes

Redo Buffers
    667648 bytes

7、登录RMAN,恢复controlfiles:

[oracle@dbServer backup]$ /u01/app/oracle/9.2.0/bin/rman target /

Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: demo1 (not mounted)

RMAN> restore controlfile from '/u02/backup/control.bk';

Starting restore at 19-NOV-08

using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=12 devtype=DISK
channel ORA_DISK_1: restoring controlfile
channel ORA_DISK_1: restore complete
replicating controlfile
input filename=/u02/data/control01.ctl
output filename=/u02/data/control02.ctl
output filename=/u02/data/control03.ctl
Finished restore at 19-NOV-08

8、MOUNT DATABASE
[oracle@dbServer data]$ sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on Wed Nov 19 14:27:09 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production

SQL> select status from v$instance;

STATUS
------------
STARTED

SQL> alter database mount;

Database altered.

SQL> select status from v$instance;

STATUS
------------------------------------
MOUNTED

9、恢复数据文件

run
{
SET NEWNAME FOR DATAFILE 1 TO '/u02/data/system01.dbf  ';
SET NEWNAME FOR DATAFILE 2 TO '/u02/data/undotbs01.dbf ';
SET NEWNAME FOR DATAFILE 4 TO '/u02/data/example01.dbf ';
SET NEWNAME FOR DATAFILE 8 TO '/u02/data/users01.dbf   ';
SET NEWNAME FOR DATAFILE 9 TO '/u02/data/xdb01.dbf     ';
SET NEWNAME FOR DATAFILE 5 TO '/u02/data/indx01.dbf    ';
SET NEWNAME FOR DATAFILE 3 TO '/u02/data/drsys01.dbf   ';
SET NEWNAME FOR DATAFILE 6 TO '/u02/data/odm01.dbf     ';
SET NEWNAME FOR DATAFILE 7 TO '/u02/data/tools01.dbf   ';
                             
    RESTORE DATABASE;        
    SWITCH DATAFILE ALL;                                                 
          
}


[oracle@dbServer ~]$ /u01/app/oracle/9.2.0/bin/rman target /

Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: DEMO1 (DBID=3671812873)

RMAN> @/u02/datafile.ora

RMAN>
RMAN> run
2> {
3> SET NEWNAME FOR DATAFILE 1 TO '/u02/data/system01.dbf  ';
4> SET NEWNAME FOR DATAFILE 2 TO '/u02/data/undotbs01.dbf ';
5> SET NEWNAME FOR DATAFILE 4 TO '/u02/data/example01.dbf ';
6> SET NEWNAME FOR DATAFILE 8 TO '/u02/data/users01.dbf   ';
7> SET NEWNAME FOR DATAFILE 9 TO '/u02/data/xdb01.dbf     ';
8> SET NEWNAME FOR DATAFILE 5 TO '/u02/data/indx01.dbf    ';
9> SET NEWNAME FOR DATAFILE 3 TO '/u02/data/drsys01.dbf   ';
10> SET NEWNAME FOR DATAFILE 6 TO '/u02/data/odm01.dbf     ';
11> SET NEWNAME FOR DATAFILE 7 TO '/u02/data/tools01.dbf   ';
12>                              
13>     RESTORE DATABASE;        
14>     SWITCH DATAFILE ALL;                                                 
15>           
16> }
executing command: SET NEWNAME
using target database controlfile instead of recovery catalog

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 19-NOV-08

allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=13 devtype=DISK
datafile 3 is already restored to file /u02/data/drsys01.dbf  
datafile 4 is already restored to file /u02/data/example01.dbf
datafile 5 is already restored to file /u02/data/indx01.dbf   
datafile 6 is already restored to file /u02/data/odm01.dbf    
datafile 7 is already restored to file /u02/data/tools01.dbf  
datafile 8 is already restored to file /u02/data/users01.dbf  
datafile 9 is already restored to file /u02/data/xdb01.dbf    
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u02/data/system01.dbf 
restoring datafile 00002 to /u02/data/undotbs01.dbf
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/9.2.0/dbs/05k03hfi_1_1 tag=TAG20081119T134730 params=NULL
channel ORA_DISK_1: restore complete
Finished restore at 19-NOV-08

datafile 1 switched to datafile copy
input datafilecopy recid=13 stamp=671212168 filename=/u02/data/system01.dbf 
datafile 2 switched to datafile copy
input datafilecopy recid=14 stamp=671212168 filename=/u02/data/undotbs01.dbf
datafile 4 switched to datafile copy
input datafilecopy recid=15 stamp=671212168 filename=/u02/data/example01.dbf
datafile 8 switched to datafile copy
input datafilecopy recid=16 stamp=671212168 filename=/u02/data/users01.dbf  
datafile 9 switched to datafile copy
input datafilecopy recid=17 stamp=671212168 filename=/u02/data/xdb01.dbf    
datafile 5 switched to datafile copy
input datafilecopy recid=18 stamp=671212168 filename=/u02/data/indx01.dbf   
datafile 3 switched to datafile copy
input datafilecopy recid=19 stamp=671212168 filename=/u02/data/drsys01.dbf  
datafile 6 switched to datafile copy
input datafilecopy recid=20 stamp=671212168 filename=/u02/data/odm01.dbf    
datafile 7 switched to datafile copy
input datafilecopy recid=21 stamp=671212168 filename=/u02/data/tools01.dbf  

RMAN>
RMAN> **end-of-file**

10、恢复数据库
RMAN> recover database;

Starting recover at 19-NOV-08
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 33 is already on disk as file /u02/oradata/1_33.dbf
archive log thread 1 sequence 34 is already on disk as file /u02/oradata/1_34.dbf
archive log thread 1 sequence 37 is already on disk as file /u01/app/oracle/oradata/demo1/redo01.log
archive log thread 1 sequence 38 is already on disk as file /u01/app/oracle/oradata/demo1/redo02.log
archive log thread 1 sequence 39 is already on disk as file /u01/app/oracle/oradata/demo1/redo03.log
archive log filename=/u02/oradata/1_33.dbf thread=1 sequence=33
archive log filename=/u02/oradata/1_34.dbf thread=1 sequence=34
unable to find archive log
archive log thread=1 sequence=35
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/19/2008 15:50:44
RMAN-06054: media recovery requesting unknown log: thread 1 scn 668299

11、OPEN DB
RMAN> alter database open resetlogs;

database opened

RMAN>
12、CREATE SPFILE
SQL> create spfile from pfile='/u02/backup/init.ora';

File created.

13、创建临时文件

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8102208/viewspace-503802/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-04-29

  • 博文量
    296
  • 访问量
    571857