本文主要就使用netbackup服务器上的rman的备份集,在异机进行数据库恢复进行详细的操作说明.
- 环境描述
1.1 源数据库信息
Hostname: sstydb
Oracle_sid:sstydb
Oracle_version:10.2.0.4.0
DBID: 3469129877
Os:Linux 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux
安装了netbackup client 和netbackup for oracle db,并在netbackup服务器上定义了策略(并激活)和client
数据库在netbackup服务器进行了全库和归档日志的备份
rman备份集没有使用catalog数据库进行记录(nocatalog方式)
netbackup服务器上设置允许异机恢复.
1.2 目标库信息
Hostname:ttjkdb
Oracle_sid:sstydb
Oracle_version:10.2.0.4.0
Os:Linux 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux
安装了oracle数据库环境,没有创建数据库实例
安装了netbackup client 和netbackup for oracle db,并在netbackup服务器上定义了策略(并激活)和client
通过了sbttest,可以访问netbackup的带库,rman可以访问netbackup服务器的介质
- 主要工作目标
在目标服务器(ttjkdb)上,使用rman工具和netbackup服务器上源库的rman备份集,进行数据库的不完整恢复(无法获得在线运行源库的redo文件),即在目标服务器上测试源库的灾难性恢复.
- 异机恢复的主要操作步骤
3.1目标机上进行数据库实例环境的准备工作
3.1.1编辑/home/oracle/.bash_profile文件设置ORACLE_SID参数
$more /home/oracle/.bash_profile
…...
ORACLE_SID=sstydb:export ORACLE_SID
…...
3.1.2 编辑$ORACLE_HOME/dbs/init.ora文件,设置实例参数
$more $ORACLE_HOME/dbs/initsstydb.ora
*.compatible='10.2.0.3.0'
*.control_files='/oradata/sstydb/control01.ctl','/oradata/sstydb/control02.ctl','/oradata/sstydb/control03.ctl'
*.core_dump_dest='/oracle/admin/sstydb/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='sstydb'
*.db_recovery_file_dest='/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/oradata/archivelog/'
*.open_cursors=300
*.pga_aggregate_target=384827392
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=555
*.sga_target=1154482176
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/oracle/admin/sstydb/udump'
注意:
Db_name 一定要设置为源库的数据库名称,dump的几个目录可以修改,归档日志目录和sga的设置可以修改
3.1.3 准备数据库数据目录和dump文件目录
本例中,目标数据库与源数据库的数据文件的目录和文件名称完全相同
ttjkdb$mkdir /oradata/sstydb
ttjkdb$cd /oracle/admin
ttjkdb$mkdir sstydb
ttjkdb$cd sstydb
ttjkdb$mkdir adump bdump cdump udump
3.1.4 启动数据库实例到nomount状态
Ttjkdb$export ORACLE_SID=sstydb
ttjkdb$sqlplus / as sysdba
SQL>startup nomount;
ORACLE instance started.
Total System Global Area 1157627904 bytes
Fixed Size 2083432 bytes
Variable Size 301991320 bytes
Database Buffers 838860800 bytes
Redo Buffers 14692352 bytes
SQL> exit
数据库实例启动到nomount状态,为后面的控制文件的恢复做好了准备
3.2 目标库服务器上恢复控制文件,启动数据库到mount状态
3.2.1 控制文件恢复的场景与约束
Oracle 官方文档中,关于restore controlfile的应用场景的描述,起到很好的指引作用,少走了很多弯路,如下:
RESTORE CONTROLFILE; | RESTORE CONTROLFILE FROM AUTOBACKUP; | RESTORE CONTROLFILE …TO 'filename'; | RESTORE CONTROLFILE… FROM 'media_handle' or TAG 'user_tag'; | |
No catalog target started in NOMOUNT state | Error.Must specify FROM AUTOBACKUP. | First run SET DBID.Restores to CONTROL_FILES locations. | First run SET DBID. Must specify FROM AUTOBACKUP.Restores only to filename. | First run SET DBID.Restores from specified file(cannot restore from TAG).If TO 'filename' not used,restores to all CONTROL_FILES location. |
NO catalog target mounted or open | Error.Must use TO 'filename',where filename is not in CONTROL_FILE list. | Error.Must use TO 'filename',where fileame is not in CONTROL_FILES list. | Restores only to filename,where filename is not in CONTROL_FILES list. | Restores form. specified file.If TO 'filename' not used,restores to all CONTROL_FILES locations. |
Catalog,target started in NOMOUNT state | Restores to CONTROL_FILES locations,RUN SET DBID only if DB_NAME not unique in catalog. | Only use with catalog for testing purposes. | Restores only to filename,where filename is not in CONTROL_FILES list. | Restores form. specified file.If TO 'filename' not used,restores to all CONTROL_FILES locations. |
Catalog,target mounted or open | Error.Must use TO 'filename',where filename is not in CONTROL_FILE list. | Do not use with catalog. | Restores only to filename,where filename is not in CONTROL_FILES list. | Restores form. specified file.If TO 'filename' not used,restores to all CONTROL_FILES locations. |
本例我们属于第一种情况:No catalog,target started in NOMOUNT state,所以只有3个途径进行恢复(见上表的第2行的第3,4,5列)因为目标库与源库的数据文件的目录完全相同,controlfile也就恢复到init.ora设置的目录,所以3,4列可以合并为3列,即:RESTORE CONTROLFILE FROM AUTOBACKUP;
第2行第5列,因为不可以使用tag,所以可以缩写为:RESTORE CONTROLFILE FROM 'media_handle';
这样本例就可以使用两个方式进行controlfile恢复工作
A. RESTORE CONTROLFILE FROM AUTOBACKUP;
B. RESTORE CONTROLFILE FROM 'media_handle'
3.2.2 controlfile的恢复
先检查一下源库的controlfile的备份情况
sstydb$rman target /
Rman>list backup of controlfile;
…...
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1109 Full 7.00M SBT_TAPE 00:00:57 15-OCT-10
BP Key: 1109 Status: AVAILABLE Compressed: NO Tag: TAG20101015T123430
Handle: cntrl_1118_1_732458070 Media: G:\\sstydb_1287117303_C1_F1
Control File Included: Ckp SCN: 13520941 Ckp time: 15-OCT-10
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1110 Full 7.00M SBT_TAPE 00:01:09 15-OCT-10
BP Key: 1110 Status: AVAILABLE Compressed: NO Tag: TAG20101015T123535
Handle: c-3469129477-20101015-02 Media: G:\\sstydb_1287117380_C1_F1
Control File Included: Ckp SCN: 13520988 Ckp time: 15-OCT-10
查询源库的DBID
Sstydb$sqlplus / as sysdba
SQL>select dbid from v$database;
DBID
--------
3469129877
A.使用FROM AUTOBACKUP 方式进行controlfile恢复
Ttjkdb$rman target /
Rman>set DBID=3469129877
Rman>run{
allocate channel d1 type 'sbt_tape' parms="ENV=(NB_ORA_CLIENT=sstydb)";
send 'NB_ORA_SERV=netbackup';
restore controlfile from 'c-3469129477-20101015-02';
Release channel d1;}
released channel: ORA_DISK_1
allocated channel: d1
channel d1: sid=541 devtype=SBT_TAPE
channel d1: Veritas NetBackup for Oracle - Release 6.5 (2007072323)
sent command to channel: d1
Starting restore at 15-OCT-10
channel d1: restoring control file
channel d1: restore complete, elapsed time: 00:00:48
output filename=/oradata/sstydb/control01.ctl
output filename=/oradata/sstydb/control02.ctl
output filename=/oradata/sstydb/control03.ctl
Finished restore at 15-OCT-10
released channel: d1
使用from autobackup 方式进行恢复有一个前提,就是源库的rman环境里设置了控制文件的自动备份
Sstydb$rman target /
Rman>show all;
RMAN configuration parameters are:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'TAPE' TO '%F';
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/oracle/product/10.2.0/db_1/dbs/snapcf_gcwz_web.f'; # default
…...
如果源库没有设置autobackup,可以通过的命令进行设置
Rman>CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN>CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'TAPE' TO '%F';
B. 使用FROM 'media_handle' 方式进行controlfile恢复
Ttjkdb$rman target /
Rman>set DBID=3469129877
Rman>run{
allocate channel d1 type 'sbt_tape' parms="ENV=(NB_ORA_CLIENT=sstydb)";
send 'NB_ORA_SERV=netbackup';
restore controlfile from autobackup;
Release channel d1;}
经实际测试使用A方式进行controlfile的恢复,耗时比B方式多;A方式可能需要扫描带库,所以速度慢很多,B方式直接去访问带库中的指定内容,时间要快一点,从速度上上比较,建议选择B方式进行controlfile的恢复。
3.2.3 启动目标数据库实例到mount状态
Ttjkdb$sqlplus / as sysdba
SQL>alter database mount;
将数据库启动到mount状态后,就可以进行数据库的restore和recovery了。
3.3 目标数据库实例恢复,以resetlogs方式打开数据库实例
3.3.1 目标数据库实例恢复
Ttjkdb$rman target /
Rman>set DBID=3469129877
Rman>run{
allocate channel d1 type 'sbt_tape' parms="ENV=(NB_ORA_CLIENT=tydb)";
send 'NB_ORA_SERV=netbackup';
Restore database;
Recover database;
Release channel d1;}
allocated channel: d1
channel d1: sid=541 devtype=SBT_TAPE
…...
channel d1: Veritas NetBackup for Oracle - Release 6.5 (2007072323)
sent command to channel: d1
channel d1: starting datafile backupset restore
channel d1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oradata/gcwz_web/system01.dbf
restoring datafile 00002 to /oradata/gcwz_web/undotbs01.dbf
…...
channel d1: reading from backup piece bk_1094_1_732284984
channel d1: restored backup piece 1
piece handle=bk_1094_1_732284984 tag=HOT_DB_BK_LEVEL0
channel d1: restore complete, elapsed time: 00:01:26
Finished restore at 15-OCT-10
Starting recover at 15-OCT-10
starting media recovery
channel d1: starting archive log restore to default destination
……
piece handle=2clqc5eg_1_1 tag=TAG20101013T180048
channel d1: restore complete, elapsed time: 00:00:56
archive log filename=/oradata/archivelog/1_665_690800133.dbf thread=1 sequence=665
archive log filename=/oradata/archivelog/1_666_690800133.dbf thread=1 sequence=666
unable to find archive log
archive log thread=1 sequence=1
released channel: d1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 10/15/2010 17:45:30
RMAN-06054: media recovery requesting unknown log: thread 1 seq 1 lowscn 13414913
这里有rman的报错,这个错误因为rman在向下应用日志的时候,找不到下一个日志序列=到达尾部(永远会存在),我们可以忽略这个错误。
3.3.2 以resetlogs方式打开数据库实例
Ttjkdb$sqlplus / as sysdba
SQL> alter database open resetlogs;
Database altered.
SQL> select open_mode,name from v$database;
OPEN_MODE NAME
---------- ---------
READ WRITE SSTYDB
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/32980/viewspace-676035/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/32980/viewspace-676035/