一、基本环境
(一)正式数据库环境
操作系统:LINUX rhel-server-6.5-x86_64
服务器 :H3C R6800 2台
数据库实例:CT 、PF 、LA 、PL
硬盘使用:CT/PF 3.1TB
LA/PL 1.6TB
备份文件大小:3.8TB
数据库路径:CT:/oracle1/app/oracle/oradata/CT
PF:/oracle1/app/oracle/oradata/PF
LA:/oracle2/app/oracle/oradata/LA
PL:/oracle2/app/oracle/oradata/PL
(二)恢复数据库环境
操作系统:LINUX rhel-server-6.5-x86_64
服务器 :DELL R910 1台
数据库实例:CT、PF 、LA、 PL
硬盘需要空间:CT/PF/LA/PL 4.5TB
数据库路径:CT:/oracle1/app/oracle/oradata/CT
PF:/oracle1/app/oracle/oradata/PF
LA:/oracle1/app/oracle/oradata/LA
PL:/oracle1/app/oracle/oradata/PL
按照以上环境可看出,数据库为相同操作系统,两个实例相同目录,另两个实例不同目录文件恢复操作。
二、备份数据
将正式库使用的四个数据库中的数据进行RMAN备份。备份语句如下:
--------备份 CT------------
run{
allocate channel ch1 device type disk rate 20M maxpiecesize 30G format=’/oracle1/app/oracle_backup/CT/%d_%T_%U.rmn’;
allocate channel ch2 device type disk rate 20M maxpiecesize 30G format=’/oracle1/app/oracle_backup/CT/%d_%T_%U.rmn’;
backup full database plus archivelog delete input;
backup spfile format ‘/oracle1/app/oracle_backup/CT/%d_%s_%p_%t.spf’;
backup current controlfile format ‘/oracle1/app/oracle_backup/CT/%d_%s_%p_%t.ctf’;
release channel ch1;
release channel ch2;
}
--------备份 PF------------
run{
allocate channel ch1 device type disk rate 20M maxpiecesize 30G format=’/oracle1/app/oracle_backup/PF/%d_%T_%U.rmn’;
allocate channel ch2 device type disk rate 20M maxpiecesize 30G format=’/oracle1/app/oracle_backup/PF/%d_%T_%U.rmn’;
backup full database plus archivelog delete input;
backup spfile format ‘/oracle1/app/oracle_backup/PF/%d_%s_%p_%t.spf’;
backup current controlfile format ‘/oracle1/app/oracle_backup/PF/%d_%s_%p_%t.ctf’;
release channel ch1;
release channel ch2;
}
--------备份 LA------------
run{
allocate channel ch1 device type disk rate 20M maxpiecesize 30G format=’/oracle2/app/oracle_backup/LA/%d_%T_%U.rmn’;
allocate channel ch2 device type disk rate 20M maxpiecesize 30G format=’/oracle2/app/oracle_backup/LA/%d_%T_%U.rmn’;
backup full database plus archivelog delete input;
backup spfile format ‘/oracle2/app/oracle_backup/LA/%d_%s_%p_%t.spf’;
backup current controlfile format ‘/oracle2/app/oracle_backup/LA/%d_%s_%p_%t.ctf’;
release channel ch1;
release channel ch2;
}
--------备份 PL------------
run{
allocate channel ch1 device type disk rate 20M maxpiecesize 30G format=’/oracle2/app/oracle_backup/PL/%d_%T_%U.rmn’;
allocate channel ch2 device type disk rate 20M maxpiecesize 30G format=’/oracle2/app/oracle_backup/PL/%d_%T_%U.rmn’;
backup full database plus archivelog delete input;
backup spfile format ‘/oracle2/app/oracle_backup/PL/%d_%s_%p_%t.spf’;
backup current controlfile format ‘/oracle2/app/oracle_backup/PL/%d_%s_%p_%t.ctf’;
release channel ch1;
release channel ch2;
}
三、搭建恢复环境
(一)操作系统及空间准备
DELL R910安装Linux 6.5 X64系统,挂载阵列(阵列磁盘空间为8.6TB)。
(二)安装oracle软件
安装所需Oracle11 X64数据库软件,建立监听,并创建原数据库所需CT/PF/LA/PL空实例。
(三)拷贝备份文件
将前期使用RMAN备份的正式数据拷贝至到测试环境相同目录下,准备做数据恢复。
四、数据库恢复
因实例文件恢复路径改变,CT/PF和LA/PL恢复方式不同,恢复方式如下:
(一)CT恢复
挂载数据库备份硬盘
su - root
fdisk -l
mount -t ntfs-3g /dev/sdc1 /oracle1/app/oracle_backup
连接实例
export ORACLE_SID=CT
启动到SQL模式
sqlplus / as sysdba
关闭数据库
shutdown immediate;
启动实例到nomount模式下
startup nomount;
退出连接
exit
重新连接数据库到rman
export ORACLE_SID=CT
rman target/
设置DBID号,已前库为准
set DBID=3812883168
恢复控制文件
restore controlfile from ‘/oracle1/app/oracle_backup/CT/CT_1570_1_1017966942.ctf’;(注意查看备份文件中的控制文件名,每次都不同)
启动数据库为mount模式
startup mount;
修改备份配置和路径
configure default device type to disk;
configure device type disk parallelism 1;
configure archivelog deletion policy to backed up 1 times to device type disk;
configure channel device type disk format ‘/oracle1/app/oracle_backup/CT/%d_%T_%U’ maxpiecesize 30G;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to ‘/oracle1/app/oracle_backup/CT/%d_%F’;
重新注册备份集
catalog start with ‘/oracle1/app/oracle_backup/CT’;
显示备份文件
list backup;
恢复数据文件
restore database;
恢复介质
recover database;
若运行时报以上错误,重新打开窗口(新建文件传输窗口)删除以下目录中的redo01.log,redo02.log,redo03.log 这3个文件。
rm -f /oracle1/app/oracle/oradata/CT/redo01.log
rm -f /oracle1/app/oracle/oradata/CT/redo02.log
rm -f /oracle1/app/oracle/oradata/CT/redo03.log
重新运行
recover database;
以上语句可能报错后可看到最大sequence值,用以下语句进行再次介质恢复成功:
run {
set until sequence 126049;
recover database;
}
启动数据库为日志模式
alter database open resetlogs;
退出RMAN模式
Exit
使用toad连接时报错
解决办法:在toad中执行以下语句即可,结果如图所示
//先执行以下语句,把报错的表空间停用
alter database tempfile ‘/oracle1/app/oracle/oradata/CT/temp01.dbf’ drop;
//再启用新的表空间
alter tablespace temp add tempfile ‘/oracle1/app/oracle/oradata/CT/temp01.dbf’ size 1024m reuse;
检查表空间是否正常,到此完成CT相同目录数据库文件恢复。
(二)PF恢复(同CT恢复一样)
连接实例
export ORACLE_SID=PF
启动到SQL模式
sqlplus / as sysdba
关闭数据库
shutdown immediate;
启动实例到nomount模式下
startup nomount;
退出连接
exit
重新连接数据库到rman
export ORACLE_SID=PF
rman target/
设置DBID号,已前库为准
set DBID=2858509157
恢复控制文件
restore controlfile from ‘/oracle1/app/oracle_backup/PF/PF_3327_1_1018047975.ctf’;(注意查看备份文件中的控制文件名)
启动数据库为mount模式
startup mount;
修改备份配置和路径
configure default device type to disk;
configure device type disk parallelism 1;
configure archivelog deletion policy to backed up 1 times to device type disk;
configure channel device type disk format ‘/oracle1/app/oracle_backup/PF/%d_%T_%U’ maxpiecesize 30G;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to ‘/oracle1/app/oracle_backup/PF/%d_%F’;
重新注册备份集
catalog start with ‘/oracle1/app/oracle_backup/PF’;
显示备份文件
list backup;
恢复数据文件
restore database;
恢复介质
recover database;
出现错误,删除以下目录中的redo01.log,redo02.log,redo03.log 这3个文件。(或者手动删除)
rm -f /oracle1/app/oracle/oradata/PF/redo01.log
rm -f /oracle1/app/oracle/oradata/PF/redo02.log
rm -f /oracle1/app/oracle/oradata/PF/redo03.log
重新运行
recover database;
以上语句可能报错后可看到最大sequence值,用以下语句进行再次介质恢复成功:
run {
set until sequence 319245;
recover database;
}
启动数据库为日志模式
alter database open resetlogs;
退出RMAN模式
Exit
toad连接时保存
解决办法:在toad中执行以下语句即可,结果如图所示
//先执行以下语句,把报错的表空间停用
alter database tempfile ‘/oracle1/app/oracle/oradata/PF/temp01.dbf’ drop;
//再启用新的表空间
alter tablespace temp add tempfile ‘/oracle1/app/oracle/oradata/PF/temp01.dbf’ size 1024m reuse;
检查表空间 是否正常,一般运行以上命令后表空间正常显示
(三)LA恢复
注:由于LA存放备份文件的路径与前两个实例不一样,故有点区别,需要修改恢复设置,具体如下:
挂载数据库备份硬盘
su - root
fdisk -l
mount -t ntfs-3g /dev/sdc1 /oracle1/app/oracle_backup
连接实例
su - oracle
export ORACLE_SID=LA
启动到SQL模式
sqlplus / as sysdba
关闭数据库
shutdown immediate;
启动实例到nomount模式下
startup nomount;
退出连接
exit
重新连接数据库到rman
export ORACLE_SID=LA
rman target/
设置DBID号,已前库为准
set DBID=1921671467
恢复控制文件
restore controlfile from ‘/oracle1/app/oracle_backup/LA/LA_670_1_1017954618.ctf’;(注意查看备份文件中的控制文件名)
启动数据库为mount模式
startup mount;
修改备份配置和路径
configure default device type to disk;
configure device type disk parallelism 1;
configure archivelog deletion policy to backed up 1 times to device type disk;
configure channel device type disk format ‘/oracle1/app/oracle_backup/LA/%d_%T_%U’ maxpiecesize 30G;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to ‘/oracle1/app/oracle_backup/LA/%d_%F’;
重新注册备份集
catalog start with ‘/oracle1/app/oracle_backup/LA’;
显示备份文件
list backup;
检查表空间序列顺序
report schema;
LA根据以上所得到序列顺序修改恢复测试目标路径语句如下:
run {
set newname for datafile 1 to ‘/oracle1/app/oracle/oradata/LA/SYSTEM01.DBF’;
set newname for datafile 2 to ‘/oracle1/app/oracle/oradata/LA/SYSAUX01.DBF’;
set newname for datafile 3 to ‘/oracle1/app/oracle/oradata/LA/UNDOTBS01.DBF’;
set newname for datafile 4 to ‘/oracle1/app/oracle/oradata/LA/USERS01.DBF’;
set newname for datafile 5 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_CPR’;
set newname for datafile 6 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_ORG’;
set newname for datafile 7 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_MNT’;
set newname for datafile 8 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_IDX’;
set newname for datafile 9 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_SYS’;
set newname for datafile 10 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_OTHER’;
set newname for datafile 11 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_ORG01’;
set newname for datafile 12 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_ORG02’;
set newname for datafile 13 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_ORG03’;
set newname for datafile 14 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_ORG04’;
set newname for datafile 15 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_ORG05’;
set newname for datafile 16 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_ORG06’;
set newname for datafile 17 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_ORG07’;
set newname for datafile 18 to ‘/oracle1/app/oracle/oradata/LA/TBS_LA_ORG08’;
restore database;
switch datafile all;
}
恢复介质
recover database;
以上语句可能报错后可看到最大sequence值,用以下语句进行再次介质恢复成功:
run {
set until sequence 26824;
recover database;
}
退出rman
Exit
因目标路径发生改变,特做以下操作,切换到SQL下,启动数据为mount模式
export ORACLE_SID=LA
sqlplus / as sysdba
shutdown immediate;
startup mount;
修改log文件存放路径
alter database rename file ‘/oracle2/app/oracle/oradata/LA/redo01.log’ to ‘/oracle1/app/oracle/oradata/LA/redo01.log’;
alter database rename file ‘/oracle2/app/oracle/oradata/LA/redo02.log’ to ‘/oracle1/app/oracle/oradata/LA/redo02.log’;
alter database rename file ‘/oracle2/app/oracle/oradata/LA/redo03.log’ to ‘/oracle1/app/oracle/oradata/LA/redo03.log’;
alter database rename file ‘/oracle2/app/oracle/oradata/LA/temp01.dbf’ to '/oracle1/app/oracle/oradata/LA/temp01.dbf ';
打开数据库设置log模式
alter database open resetlogs;
检查表空间大小
到此LA数据库恢复工作
(四)PL恢复(和LA恢复一样)
挂载数据库备份硬盘
su – root
fdisk –l
mount –t ntfs-3g /dev/sdd1 /oracle1/app/oracle_backup
连接实例
export ORACLE_SID=PL
启动到SQL模式
sqlplus / as sysdba
关闭数据库
shutdown immediate;
启动实例到nomount模式下
startup nomount;
退出连接
exit
重新连接数据库到rman
export ORACLE_SID=PL
rman target/
设置DBID号,已前库为准
set DBID=1862315518
恢复控制文件
restore controlfile from ‘/oracle1/app/oracle_backup/PL/PL_4464_1_1017999180.ctf’;(注意查看备份文件中的控制文件名)
启动数据库为mount模式
startup mount;
修改备份配置和路径
configure default device type to disk;
configure device type disk parallelism 1;
configure archivelog deletion policy to backed up 1 times to device type disk;
configure channel device type disk format ‘/oracle1/app/oracle_backup/PL/%d_%T_%U’ maxpiecesize 30G;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to ‘/oracle1/app/oracle_backup/PL/%d_%F’;
重新注册备份集
catalog start with ‘/oracle1/app/oracle_backup/PL’;
显示备份文件
list backup;
检查表空间序列顺序
report schema;
根据以上所得到序列顺序修改恢复测试目标路径语句如下:
run {
set newname for datafile 1 to ‘/oracle1/app/oracle/oradata/PL/system01.dbf’;
set newname for datafile 2 to ‘/oracle1/app/oracle/oradata/PL/sysaux01.dbf’;
set newname for datafile 3 to ‘/oracle1/app/oracle/oradata/PL/undotbs01.dbf’;
set newname for datafile 4 to ‘/oracle1/app/oracle/oradata/PL/users01.dbf’;
set newname for datafile 5 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR’;
set newname for datafile 6 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG’;
set newname for datafile 7 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_MNT’;
set newname for datafile 8 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_IDX’;
set newname for datafile 9 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_SYS’;
set newname for datafile 10 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_OTHER’;
set newname for datafile 11 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR01’;
set newname for datafile 12 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR02’;
set newname for datafile 13 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR03’;
set newname for datafile 14 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR04’;
set newname for datafile 15 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR05’;
set newname for datafile 16 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR06’;
set newname for datafile 17 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR07’;
set newname for datafile 18 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR08’;
set newname for datafile 19 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR09’;
set newname for datafile 20 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR10’;
set newname for datafile 21 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR11’;
set newname for datafile 22 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR12’;
set newname for datafile 23 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR13’;
set newname for datafile 24 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR14’;
set newname for datafile 25 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR15’;
set newname for datafile 26 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR16’;
set newname for datafile 27 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR17’;
set newname for datafile 28 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR18’;
set newname for datafile 29 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR19’;
set newname for datafile 30 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR20’;
set newname for datafile 31 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR21’;
set newname for datafile 32 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR22’;
set newname for datafile 33 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR23’;
set newname for datafile 34 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR24’;
set newname for datafile 35 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR25’;
set newname for datafile 36 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR26’;
set newname for datafile 37 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR27’;
set newname for datafile 38 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_MNT01’;
set newname for datafile 39 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG01’;
set newname for datafile 40 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG02’;
set newname for datafile 41 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG03’;
set newname for datafile 42 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG04’;
set newname for datafile 43 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG05’;
set newname for datafile 44 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG06’;
set newname for datafile 45 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG07’;
set newname for datafile 46 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG08’;
set newname for datafile 47 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG09’;
set newname for datafile 48 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG10’;
set newname for datafile 49 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG11’;
set newname for datafile 50 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG12’;
set newname for datafile 51 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG13’;
set newname for datafile 52 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG14’;
set newname for datafile 53 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG15’;
set newname for datafile 54 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG16’;
set newname for datafile 55 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG17’;
set newname for datafile 56 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG18’;
set newname for datafile 57 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG19’;
set newname for datafile 58 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG20’;
set newname for datafile 59 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR28’;
set newname for datafile 60 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR29’;
set newname for datafile 61 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR30’;
set newname for datafile 62 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG21’;
set newname for datafile 63 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG22’;
set newname for datafile 64 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG23’;
set newname for datafile 65 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG24’;
set newname for datafile 66 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG25’;
set newname for datafile 67 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG26’;
set newname for datafile 68 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG27’;
set newname for datafile 69 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG28’;
set newname for datafile 70 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG29’;
set newname for datafile 71 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG30’;
set newname for datafile 72 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG31’;
set newname for datafile 73 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG32’;
set newname for datafile 74 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG33’;
set newname for datafile 75 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG34’;
set newname for datafile 76 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG35’;
set newname for datafile 77 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG36’;
set newname for datafile 78 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG37’;
set newname for datafile 79 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG38’;
set newname for datafile 80 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG39’;
set newname for datafile 81 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG40’;
set newname for datafile 82 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG41’;
set newname for datafile 83 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG42’;
set newname for datafile 84 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG43’;
set newname for datafile 85 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG44’;
set newname for datafile 86 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG45’;
set newname for datafile 87 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_ORG46’;
set newname for datafile 88 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR31’;
set newname for datafile 89 to ‘/oracle1/app/oracle/oradata/PL/TBS_PL_CPR32’;
restore database;
switch datafile all;
}
恢复介质
recover database;
以上语句可能报错后可看到最大sequence值,用以下语句进行再次介质恢复成功:
run {
set until sequence 433548; recover database;
}
(每次这个值都不一样,以实际报错的值为准)
退出rman
Exit
因目标路径发生改变,特做以下操作,切换到SQL下,启动数据为mount模式
export ORACLE_SID=PL
sqlplus / as sysdba
shutdown immediate;
startup mount;
修改log文件存放路径
alter database rename file ‘/oracle2/app/oracle/oradata/PL/redo01.log’ to ‘/oracle1/app/oracle/oradata/PL/redo01.log’;
alter database rename file ‘/oracle2/app/oracle/oradata/PL/redo02.log’ to ‘/oracle1/app/oracle/oradata/PL/redo02.log’;
alter database rename file ‘/oracle2/app/oracle/oradata/PL/redo03.log’ to ‘/oracle1/app/oracle/oradata/PL/redo03.log’;
alter database rename file ‘/oracle2/app/oracle/oradata/PL/temp01.dbf’ to '/oracle1/app/oracle/oradata/PL /temp01.dbf ';
(最后一步出错是语句中多了一个空格,删掉即可)
打开数据库设置log模式
alter database open resetlogs;
检查表空间(正常)
到此完成四个数据库恢复工作。使用数据库软件检查各表均能正常访问,并能做数据增删改操作。恢复的数据完整。
注意:若使用toad连接时,出现以下问题
解决办法:在toad中执行以下语句即可,结果如图所示
CT库
//先执行以下语句,把报错的表空间删除
alter database tempfile ‘/oracle1/app/oracle/oradata/CT/temp01.dbf’ drop;
//再创建新的表空间
alter tablespace temp add tempfile ‘/oracle1/app/oracle/oradata/CT/temp01.dbf’ size 1024m reuse;
PF库
//先执行以下语句,把报错的表空间删除
alter database tempfile ‘/oracle1/app/oracle/oradata/PF/temp01.dbf’ drop;
//再创建新的表空间
alter tablespace temp add tempfile ‘/oracle1/app/oracle/oradata/PF/temp01.dbf’ size 1024m reuse;