恢復例子:
一.環境
原環境:
os:redhat 5.4 oracle:10.2.1
恢復環境:
os:redhat 5.4 oracle:10.2.4
二.恢復步驟:
以下步驟在恢復環境執行:
1.建立初始化參數文件:
#vi initauxstand.ora
*.control_files='/opt/app/oracle/oradata/orastan/control01.ctl','/opt/app/oracle/o*.control_files='/opt/app/oracle/oradata/auxstand/control01.ctl','/opt/app/oracle/*.audit_file_dest='/opt/app/oracle/admin/auxstand/adump'
*.background_dump_dest='/opt/app/oracle/admin/auxstand/bdump'
*.compatible='10.2.0.4.0'
*.control_files='/opt/app/oracle/oradata/auxstand/control01.ctl','/opt/app/oracle/oradata/auxstand/control02.ctl','/opt/app/oracle/oradata/auxstand/control03.ctl'
*.core_dump_dest='/opt/app/oracle/admin/auxstand/cdump'
*.db_block_size=16384
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='auxstand'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/arch/arch_log'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=88080384
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_management='AUTO'
*.shared_pool_size=314572800
*.undo_tablespace='UNDOTBS1'
2.修改nbu配置文件:
1)client端:
#vi /usr/openv/netbackup/bp.conf
SERVER = nbuserver ##改為備份server
CLIENT_NAME = standbydb ##改為原環境的server名字
2)server端:
修改hosts文件
將standbydb的ip地址從原環境IP改為新環境的ip
3.使用rman的auxiliary模式進行恢復:
[oracle@ora9i dbs]$ rman auxiliary /
Recovery Manager: Release 10.2.0.4.0 - Production on Mon Apr 18 13:59:07 2011
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to auxiliary database: AUXSTAND (not mounted)
RMAN> connect target sys/manager1@orastandby
PL/SQL package SYS.DBMS_BACKUP_RESTORE version 10.02.00.00 in TARGET database is not current
PL/SQL package SYS.DBMS_RCVMAN version 10.02.00.00 in TARGET database is not current
connected to target database: ORASTAND (DBID=334367448)
RMAN> connect catalog rman/rman@rman
connected to recovery catalog database
RMAN> run{
2> allocate auxiliary channel ch1 DEVICE TYPE 'SBT_TAPE' PARMS 'ENV=(NB_ORA_CLIENT=standbydb)';
3> #allocate auxiliary channel ch1 DEVICE TYPE 'SBT_TAPE' parms='SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so ENV=(NB_ORA_CLIENT=g3rpt01)';
4>
5> set until time "to_date('04/18/2011 10:00:00','MM/DD/YYYY HH24:MI:SS')";
6>
7> set newname for datafile 1 to '/data/oradata/auxstand/system01.dbf';
8> set newname for datafile 17 to '/data/oradata/auxstand/system02.dbf';
9> set newname for datafile 2 to '/data/oradata/auxstand/undotbs01.dbf';
10> set newname for datafile 3 to '/data/oradata/auxstand/sysaux01.dbf';
11> set newname for datafile 4 to '/data/oradata/auxstand/users01.dbf';
12> set newname for datafile 5 to '/data/oradata/auxstand/data01.dbf';
13> set newname for datafile 6 to '/data/oradata/auxstand/data02.dbf';
14> set newname for datafile 7 to '/data/oradata/auxstand/sysaux02.dbf';
15> set newname for datafile 8 to '/data/oradata/auxstand/users02.dbf';
16> set newname for datafile 10 to '/data/oradata/auxstand/sysaux03.dbf';
17> set newname for datafile 11 to '/data/oradata/auxstand/test1.dbf';
18> set newname for datafile 13 to '/data/oradata/auxstand/genetest.dbf';
19> set newname for tempfile 1 to '/data/oradata/auxstand/temp01.dbf';
20> DUPLICATE TARGET DATABASE TO auxstand
21> SKIP tablespace LOG_DATA,MNT_DATA,PERFSTAT,SN_DATA,SPC,SYSTABLE,TS23,TS3,USER1
22> LOGFILE
23> GROUP 1 ('/data/oradata/auxstand/redo01a.log',
24> '/data/oradata/auxstand/redo01b.log') size 10240k reuse,
25> GROUP 2 ('/data/oradata/auxstand/redo02a.log',
26> '/data/oradata/auxstand/redo02b.log') size 10240k reuse;
27> }
allocated channel: ch1
channel ch1: sid=159 devtype=SBT_TAPE
channel ch1: VERITAS NetBackup for Oracle - Release 5.1 (2004043014)
executing command: SET until clause
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
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting Duplicate Db at 18-APR-11
Datafile 9 skipped by request
Datafile 12 skipped by request
Datafile 14 skipped by request
Datafile 15 skipped by request
Datafile 16 skipped by request
Datafile 18 skipped by request
Datafile 19 skipped by request
Datafile 20 skipped by request
Datafile 21 skipped by request
contents of Memory Script.:
{
set until scn 14420940;
set newname for datafile 1 to
"/data/oradata/auxstand/system01.dbf";
set newname for datafile 2 to
"/data/oradata/auxstand/undotbs01.dbf";
set newname for datafile 3 to
"/data/oradata/auxstand/sysaux01.dbf";
set newname for datafile 4 to
"/data/oradata/auxstand/users01.dbf";
set newname for datafile 5 to
"/data/oradata/auxstand/data01.dbf";
set newname for datafile 6 to
"/data/oradata/auxstand/data02.dbf";
set newname for datafile 7 to
"/data/oradata/auxstand/sysaux02.dbf";
set newname for datafile 8 to
"/data/oradata/auxstand/users02.dbf";
set newname for datafile 10 to
"/data/oradata/auxstand/sysaux03.dbf";
set newname for datafile 11 to
"/data/oradata/auxstand/test1.dbf";
set newname for datafile 13 to
"/data/oradata/auxstand/genetest.dbf";
set newname for datafile 17 to
"/data/oradata/auxstand/system02.dbf";
restore
check readonly
clone database
skip tablespace USER1,
TS3,
TS23,
SYSTABLE,
SPC,
SN_DATA,
PERFSTAT,
MNT_DATA,
LOG_DATA ;
}
executing Memory Script
executing command: SET until clause
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
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 18-APR-11
channel ch1: starting datafile backupset restore
channel ch1: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /data/oradata/auxstand/users01.dbf
restoring datafile 00007 to /data/oradata/auxstand/sysaux02.dbf
channel ch1: reading from backup piece bk_273_1_748777482
channel ch1: restored backup piece 1
piece handle=bk_273_1_748777482 tag=HOT_DB_BK_LEVEL0
channel ch1: restore complete, elapsed time: 00:00:55
channel ch1: starting datafile backupset restore
channel ch1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /data/oradata/auxstand/system01.dbf
restoring datafile 00008 to /data/oradata/auxstand/users02.dbf
channel ch1: reading from backup piece bk_274_1_748777808
channel ch1: restored backup piece 1
piece handle=bk_274_1_748777808 tag=HOT_DB_BK_LEVEL0
channel ch1: restore complete, elapsed time: 00:01:25
channel ch1: starting datafile backupset restore
channel ch1: specifying datafile(s) to restore from backup set
restoring datafile 00003 to /data/oradata/auxstand/sysaux01.dbf
restoring datafile 00006 to /data/oradata/auxstand/data02.dbf
restoring datafile 00011 to /data/oradata/auxstand/test1.dbf
channel ch1: reading from backup piece bk_275_1_748778016
channel ch1: restored backup piece 1
piece handle=bk_275_1_748778016 tag=HOT_DB_BK_LEVEL0
channel ch1: restore complete, elapsed time: 00:01:15
channel ch1: starting datafile backupset restore
channel ch1: specifying datafile(s) to restore from backup set
restoring datafile 00005 to /data/oradata/auxstand/data01.dbf
restoring datafile 00010 to /data/oradata/auxstand/sysaux03.dbf
restoring datafile 00013 to /data/oradata/auxstand/genetest.dbf
restoring datafile 00017 to /data/oradata/auxstand/system02.dbf
channel ch1: reading from backup piece bk_276_1_748778232
channel ch1: restored backup piece 1
piece handle=bk_276_1_748778232 tag=HOT_DB_BK_LEVEL0
channel ch1: restore complete, elapsed time: 00:00:46
channel ch1: starting datafile backupset restore
channel ch1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /data/oradata/auxstand/undotbs01.dbf
channel ch1: reading from backup piece bk_277_1_748778277
channel ch1: restored backup piece 1
piece handle=bk_277_1_748778277 tag=HOT_DB_BK_LEVEL0
channel ch1: restore complete, elapsed time: 00:01:05
Finished restore at 18-APR-11
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUXSTAND" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/data/oradata/auxstand/redo01a.log', '/data/oradata/auxstand/redo01b.log' ) SIZE 10240 K REUSE,
GROUP 2 ( '/data/oradata/auxstand/redo02a.log', '/data/oradata/auxstand/redo02b.log' ) SIZE 10240 K REUSE
DATAFILE
'/data/oradata/auxstand/system01.dbf'
CHARACTER SET ZHT16BIG5
contents of Memory Script.:
{
switch clone datafile all;
}
executing Memory Script
datafile 17 switched to datafile copy
input datafile copy recid=1 stamp=748793158 filename=/data/oradata/auxstand/system02.dbf
datafile 2 switched to datafile copy
input datafile copy recid=2 stamp=748793158 filename=/data/oradata/auxstand/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=3 stamp=748793158 filename=/data/oradata/auxstand/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=4 stamp=748793158 filename=/data/oradata/auxstand/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=5 stamp=748793158 filename=/data/oradata/auxstand/data01.dbf
datafile 6 switched to datafile copy
input datafile copy recid=6 stamp=748793158 filename=/data/oradata/auxstand/data02.dbf
datafile 7 switched to datafile copy
input datafile copy recid=7 stamp=748793158 filename=/data/oradata/auxstand/sysaux02.dbf
datafile 8 switched to datafile copy
input datafile copy recid=8 stamp=748793158 filename=/data/oradata/auxstand/users02.dbf
datafile 10 switched to datafile copy
input datafile copy recid=9 stamp=748793158 filename=/data/oradata/auxstand/sysaux03.dbf
datafile 11 switched to datafile copy
input datafile copy recid=10 stamp=748793158 filename=/data/oradata/auxstand/test1.dbf
datafile 13 switched to datafile copy
input datafile copy recid=11 stamp=748793158 filename=/data/oradata/auxstand/genetest.dbf
contents of Memory Script.:
{
set until time "to_date('04/18/2011 10:00:00','MM/DD/YYYY HH24:MI:SS')";
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 18-APR-11
datafile 9 not processed because file is offline
datafile 12 not processed because file is offline
datafile 14 not processed because file is offline
datafile 15 not processed because file is offline
datafile 16 not processed because file is offline
datafile 18 not processed because file is offline
datafile 19 not processed because file is offline
datafile 20 not processed because file is offline
datafile 21 not processed because file is offline
starting media recovery
channel ch1: starting archive log restore to default destination
channel ch1: restoring archive log
archive log thread=1 sequence=877
channel ch1: reading from backup piece al_278_1_748778431
channel ch1: restored backup piece 1
piece handle=al_278_1_748778431 tag=TAG20110418T100031
channel ch1: restore complete, elapsed time: 00:00:46
archive log filename=/arch/arch_log/1_877_733061336.dbf thread=1 sequence=877
channel clone_default: deleting archive log(s)
archive log filename=/arch/arch_log/1_877_733061336.dbf recid=1 stamp=748793192
media recovery complete, elapsed time: 00:00:01
Finished recover at 18-APR-11
contents of Memory Script.:
{
shutdown clone;
startup clone nomount ;
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 394264576 bytes
Fixed Size 1267692 bytes
Variable Size 339740692 bytes
Database Buffers 50331648 bytes
Redo Buffers 2924544 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUXSTAND" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/data/oradata/auxstand/redo01a.log', '/data/oradata/auxstand/redo01b.log' ) SIZE 10240 K REUSE,
GROUP 2 ( '/data/oradata/auxstand/redo02a.log', '/data/oradata/auxstand/redo02b.log' ) SIZE 10240 K REUSE
DATAFILE
'/data/oradata/auxstand/system01.dbf'
CHARACTER SET ZHT16BIG5
contents of Memory Script.:
{
set newname for tempfile 1 to
"/data/oradata/auxstand/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/data/oradata/auxstand/undotbs01.dbf";
catalog clone datafilecopy "/data/oradata/auxstand/sysaux01.dbf";
catalog clone datafilecopy "/data/oradata/auxstand/users01.dbf";
catalog clone datafilecopy "/data/oradata/auxstand/data01.dbf";
catalog clone datafilecopy "/data/oradata/auxstand/data02.dbf";
catalog clone datafilecopy "/data/oradata/auxstand/sysaux02.dbf";
catalog clone datafilecopy "/data/oradata/auxstand/users02.dbf";
catalog clone datafilecopy "/data/oradata/auxstand/sysaux03.dbf";
catalog clone datafilecopy "/data/oradata/auxstand/test1.dbf";
catalog clone datafilecopy "/data/oradata/auxstand/genetest.dbf";
catalog clone datafilecopy "/data/oradata/auxstand/system02.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /data/oradata/auxstand/temp01.dbf in control file
cataloged datafile copy
datafile copy filename=/data/oradata/auxstand/undotbs01.dbf recid=1 stamp=748793217
cataloged datafile copy
datafile copy filename=/data/oradata/auxstand/sysaux01.dbf recid=2 stamp=748793217
cataloged datafile copy
datafile copy filename=/data/oradata/auxstand/users01.dbf recid=3 stamp=748793217
cataloged datafile copy
datafile copy filename=/data/oradata/auxstand/data01.dbf recid=4 stamp=748793218
cataloged datafile copy
datafile copy filename=/data/oradata/auxstand/data02.dbf recid=5 stamp=748793218
cataloged datafile copy
datafile copy filename=/data/oradata/auxstand/sysaux02.dbf recid=6 stamp=748793218
cataloged datafile copy
datafile copy filename=/data/oradata/auxstand/users02.dbf recid=7 stamp=748793218
cataloged datafile copy
datafile copy filename=/data/oradata/auxstand/sysaux03.dbf recid=8 stamp=748793218
cataloged datafile copy
datafile copy filename=/data/oradata/auxstand/test1.dbf recid=9 stamp=748793218
cataloged datafile copy
datafile copy filename=/data/oradata/auxstand/genetest.dbf recid=10 stamp=748793219
cataloged datafile copy
datafile copy filename=/data/oradata/auxstand/system02.dbf recid=11 stamp=748793219
datafile 17 switched to datafile copy
input datafile copy recid=11 stamp=748793219 filename=/data/oradata/auxstand/system02.dbf
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=748793217 filename=/data/oradata/auxstand/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=748793217 filename=/data/oradata/auxstand/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=748793217 filename=/data/oradata/auxstand/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=748793218 filename=/data/oradata/auxstand/data01.dbf
datafile 6 switched to datafile copy
input datafile copy recid=5 stamp=748793218 filename=/data/oradata/auxstand/data02.dbf
datafile 7 switched to datafile copy
input datafile copy recid=6 stamp=748793218 filename=/data/oradata/auxstand/sysaux02.dbf
datafile 8 switched to datafile copy
input datafile copy recid=7 stamp=748793218 filename=/data/oradata/auxstand/users02.dbf
datafile 10 switched to datafile copy
input datafile copy recid=8 stamp=748793218 filename=/data/oradata/auxstand/sysaux03.dbf
datafile 11 switched to datafile copy
input datafile copy recid=9 stamp=748793218 filename=/data/oradata/auxstand/test1.dbf
datafile 13 switched to datafile copy
input datafile copy recid=10 stamp=748793219 filename=/data/oradata/auxstand/genetest.dbf
contents of Memory Script.:
{
Alter clone database open resetlogs;
}
executing Memory Script
Segmentation fault
4.從上面的結果可看到最後open resetlogs時出錯,嘗試開啟數據庫:
[oracle@ora9i dbs]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Apr 18 14:08:17 2011
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 394264576 bytes
Fixed Size 1267692 bytes
Variable Size 339740692 bytes
Database Buffers 50331648 bytes
Redo Buffers 2924544 bytes
Database mounted.
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/data/oradata/auxstand/system01.dbf'
3.還是出錯,這是因為oracle 版本不一樣,從10.2.1恢復到10.2.4要升級(同一版本的恢復不用做以下步驟):
[oracle@ora9i dbs]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Apr 18 14:20:52 2011
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 394264576 bytes
Fixed Size 1267692 bytes
Variable Size 339740692 bytes
Database Buffers 50331648 bytes
Redo Buffers 2924544 bytes
Database mounted.
SQL> alter database open UPGRADE;
alter database open UPGRADE
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/data/oradata/auxstand/system01.dbf'
SQL> recover database;
Media recovery complete.
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup UPGRADE;
ORACLE instance started.
升級數據庫
SQL> @/opt/oracle/oracle/product/10.2.0/db_1/rdbms/admin/catupgrd.sql ##升級腳本
SQL> shutdwon immediate
SQL> startup
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25402324/viewspace-715557/ ,如需转载,请注明出处,否则将追究法律责任。