Oracle 11G RMAN 单实例异机恢复

前端之家收集整理的这篇文章主要介绍了Oracle 11G RMAN 单实例异机恢复前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

数据备份当然是为数据恢复准备,新环境的oracle一直在进行备份,但都没有测试验证备份的有效性,所以本次测试的重要性不言而喻了!以下为WIN平台下RMAN异机恢复实例。


源库

目标库

操作系统

WIN SVR 2008 R2

WIN SVR 2008 R2

主机名

Ora

ORATEST

IP

192.168.18.20

192.168.18.25

数据库版本

11.2.0.1.0

11.2.0.1.0

存储方式

单实例

单实例

ORACLE_HOME

D:\app\Administrator\product\11.2.0\dbhome_1

D:\app\Administrator\product\11.2.0\dbhome_1

ORACLE_SID

HWPROD

HWPROD

源库备份操作:

相关备份配置及脚本如下:

RMAN> show all;

db_unique_name HWPROD 数据库 RMAN 配置参数为:

CONFIGURE RETENTION POLICY TO RECOVERYWINDOW OF 3 DAYS; #保留备份为3

CONFIGURE BACKUP OPTIMIZATION OFF; #default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; #default

CONFIGURE CONTROLFILE AUTOBACKUP ON; #需要打开自动备份

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FORDEVICE TYPE DISK TO 'e:\data_backup\

ctl_%F.bak'; #指定备份控制文件及参数文件备份路径格式

CONFIGURE DEVICE TYPE DISK PARALLELISM 1BACKUP TYPE TO BACKUPSET; # default

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICETYPE DISK TO 1; # default

CONFIGURE ARCHIVELOG BACKUP COPIES FORDEVICE TYPE DISK TO 1; # default

CONFIGURE MAXSETSIZE TO UNLIMITED; #default

CONFIGURE ENCRYPTION FOR DATABASE OFF; #default

CONFIGURE ENCRYPTION ALGORITHM 'AES128'; #default

CONFIGURE COMPRESSION ALGORITHM 'BASIC' ASOF RELEASE 'DEFAULT' OPTIMIZE FOR LOA

D TRUE ; # default

CONFIGURE ARCHIVELOG DELETION POLICY TONONE; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO'D:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHO

ME_1\DATABASE\SNCFHWPROD.ORA'; # default

full_backup.sql

run{

allocate channel d1 type disk;

allocate channel d2 type disk;

backup as compressed backupset fulldatabase format 'e:\data_backup\full_%d_%s_%p_%u_%t.bak';

sql 'alter system archive logcurrent';

backup archivelog all format'e:\data_backup\log_%d_%s_%p_%u_%t.bak' delete all input;

release channel d1;

release channel d2;

report obsolete;

crosscheck backup;

delete noprompt expired backup;

delete noprompt obsolete;

}

full_backup.bat

set oracle_sid=hwprod

set d=%date:~,4%%date:~5,2%%date:~8,2%

echo=>e:\rman_script\log\full_backup_%d%.log

rman target /cmdfile=e:\rman_script\full_backup.sqlmsglog=e:\rman_script\log\full_backup_%d%.log

RMAN恢复思路步骤:

  • 初始化数据库,安装相同环境;

  • 恢复参数文件

  • 恢复控制文件

  • 启动数据库MOUNT状态,利用控制文件进行数据恢复;

  • 查看归档日志备份sequence

  • Restore �Crecover―alter database open ressetlogs;

  • 验证;

  • 设置监听

1、系统安装完成后,安装ORACLE软件,选择只安装软件,并安装与源库相同路径,然后把相关备份文件拷贝到原备份路径,为避免不必要的麻烦,建议设置与源库一致。

2、建立相关的密码文件,服务,监听器,否则无法连接DB

C:\Users\Administrator>D:

D:\>cd D:\app\Administrator\product\11.2.0\dbhome_1\BIN


D:\app\Administrator\product\11.2.0\dbhome_1\BIN>orapwd file=D:\app\Administrato

r\product\11.2.0\dbhome_1\database\pwdhwprod.ora password=oracle entries=5;

D:\app\Administrator\product\11.2.0\dbhome_1\BIN>oradim -new -sid HWPROD -startm

ode m

实例已创建。

D:\app\Administrator\product\11.2.0\dbhome_1\BIN>set ORACLE_SID=HWPROD

D:\app\Administrator\product\11.2.0\dbhome_1\BIN>

wKioL1kCqc7QOc1BAABHhlprgvs295.png-wh_50


D:\app\Administrator\product\11.2.0\dbhome_1\BIN>sqlplus/ as sysdba

sql*Plus: Release 11.2.0.1.0 Production on 星期五 4 21 14:19:482017

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

已连接到空闲例程。

sql>

wKioL1kCqhnStZLCAAAw976cjSY886.png-wh_50

此时可以连接到DB了。

3、手动建立一个pfile文件,放到D:\app\Administrator\product\11.2.0\dbhome_1\database目录下,inithwprod.ora内容如下:

db_name=HWPROD

java_pool_size=4194304

large_pool_size=4194304

shared_pool_size=96468992

wKiom1kCqlPzsnnhAAAochqfGro724.png-wh_50

以此pfile启动数据库nomount状态:

wKioL1kCqqWCHAsNAABGZ5PeOjE703.png-wh_50

sql> startuppfile='D:\app\Administrator\product\11.2.0\dbhome_1\database\inithw

prod.ora' nomount;

ORACLE 例程已经启动。

Total System Global Area 162873344 bytes

Fixed Size 2173800 bytes

Variable Size 104858776 bytes

Database Buffers 50331648 bytes

Redo Buffers 5509120 bytes

4、切换到RMAN下,并SETDBID=3279461817(源库DBID),恢复spfile文件

wKiom1kCqteRcIgHAABW61dRT94467.png-wh_50

wKioL1kCqtfDWV4hAABUz4YCS2Y719.png-wh_50


Restore SPfile文件,找到源spfile备份相关文件进行恢复:

RMAN> restore spfile from'e:\data_backup\CTL_C-3279461817-20170427-00';

启动 restore 27-4 -17

使用目标数据库控制文件替代恢复目录

分配的通道: ORA_DISK_1

通道 ORA_DISK_1: SID=135 设备类型=DISK

通道 ORA_DISK_1: 正在从 AUTOBACKUP e:\data_backup\CTL_C-3279461817-20170427-00

还原 spfile

通道 ORA_DISK_1: AUTOBACKUP 还原 SPFILE 已完成

完成 restore 27-4 -17

wKiom1kCqvrhWyTWAABb39lEZYE664.png-wh_50

5SPfile恢复完成,关闭数据库,用刚恢复的spfile启动数据库nomount状态(注意需要创建flash_recovery_areaORADATA目录,否则会报错ORA-01263: Name given for file destination directory is invalid ,同时需注意修改还原过来的SPfile文件,这里应该注意,源库可能空间较大,关于sga,pga等酌情根据目标库修改),否则会报OSD-00026超出内存等错误,不能正常nomount

wKioL1kCqxvBCO2QAABEkpuc8xs350.png-wh_50


建立相关目录:

wKioL1kCq0iDxfTIAACM8_VbfkI826.png-wh_50

再启动:

wKiom1kCq3DDUTWAAABD4fwyHYg998.png-wh_50

6restore恢复controlfile

wKiom1kCq4Wj_WGUAABXIUQXNqs921.png-wh_50

RMAN> restore controlfile from'E:\data_backup\CTL_C-3279461817-20170427-01';

接下来把数据库修改MOUNT状态:

wKiom1kCq7iiIH_kAABUjj7gB08950.png-wh_50

7、查看归档日志备份的状态,其最大sequence18437

wKioL1kCq9iD2_ZfAAByIFANEqg849.png-wh_50

RMAN> list backup of archivelog all;

8、进行数据文件恢复:

wKiom1kCq_-yIw2SAABhdEBsLc4501.png-wh_50

RMAN> run {

2> set until sequence 18437;

3> restore database;

4> }

wKiom1kCrCvjWLAZAABkEfhAIx0638.png-wh_50

RMAN> run {

2> set until sequence 18437;

3> recover database;

4> }

9resetlogs 打开数据库

wKioL1kCrEvg7uDAAABilW97oUs894.png-wh_50

RMAN> alter database open resetlogs;

10、查看数据库状态:

wKioL1kCrG6A8jsfAAAn1Dw1hOQ985.png-wh_50

11添加注册SID

wKioL1kCrInyb453AACszi3b0lU105.png-wh_50

12、创建SPfile

sql>createspfilefrompfile;

13、重启数据库,是否以SPFILE启动:

sql>select decode(count(*),1,'spfile','pfile') from v$spparameter whererownum

=1 and isspecified = 'TRUE';

wKioL1kCrKmTaOwvAABBARpmX7g209.png-wh_50

14修改listener.ora,tnsnames.ora

wKiom1kCrMGRhv7SAABW38TJ9Lo572.png-wh_50

listener.ora

# listener.ora Network Configuration File:D:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = HWPROD)

(ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1)

(SID_NAME = HWPROD)

)

)

LISTENER =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = ORATEST)(PORT = 1521))

)

ADR_BASE_LISTENER =D:\app\Administrator\product\11.2.0\dbhome_1\log

tnsnames.ora

# tnsnames.ora Network Configuration File:D:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora

# Generated by Oracle configuration tools.

HWPROD =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.25)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = HWPROD)

)

)

查看监听状态:

wKioL1kCrOLyBvRrAABjwHoBGzU386.png-wh_50

验证数据,OK!


参考:http://blog.itpub.net/29119536/viewspace-1171894/

原文链接:https://www.f2er.com/oracle/209429.html

猜你在找的Oracle相关文章