RMAN '异机异目录恢复'
RMAN '异机异目录恢复'
2011-07-04 12:31:55| 分类: oracle | 标签: |字号大中小 订阅
前提条件:RMAN生成的全备,异机异目录恢复
(参考:http://zhouwf0726.itpub.net/post/9689/244764)
1)在原始数据库上:
RMAN>CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN>backup database format='/mezi/oracle/app_11R1/rman_backup/%d_%s.dbf'
//将会生成两个文件,controlfile和数据库
2)将rman 生成的两个文件拷贝到远程服务器的目录: /db/sshan_temp/
将原始数据库的初始化参数文件拷贝到目标服务器:$ORACLE_HOME/dbs/
并修改相关目录:如controlfile目录和dump目录
3)恢复controlfile 文件
SQL>startup nomount;
#./rman target /
RMAN>restore controlfile from '/db/sshan_temp/ORCL_7.dbf';
4)恢复数据文件
RMAN>restore database from '/db/sshan_temp/ORCL_6.dbf';
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 04/09/2008 14:15:17
RMAN-06509: only SPFILE or controlfile can be restored from autobackup
RMAN>list backup;
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 21.00G DISK 00:07:34 01-JUL-11
BP Key: 3 Status: EXPIRED Compressed: NO Tag: TAG20110701T045821
Piece Name: /mezi/oracle/app_11R1/rman_backup/ORCL_6.dbf
由于没有相关权限,所以无法创建和原始数据库一样的rman备份目录。
**************************************************************************************************************************************************
查看控制文件中数据文件列表:
SQL>select name from v$datafile;
FILE# NAME
---------- --------------------------------------------------
1 /mezi/oracle/app_11R1/oradata/orcl/system01.dbf
2 /mezi/oracle/app_11R1/oradata/orcl/sysaux01.dbf
3 /mezi/oracle/app_11R1/oradata/orcl/undo.dbf
4 /mezi/oracle/app_11R1/oradata/orcl/dfdata01.dbf
5 /mezi/oracle/app_11R1/oradata/orcl/indx01.dbf
6 /mezi/oracle/app_11R1/oradata/orcl/tools01.dbf
7 /mezi/oracle/app_11R1/oradata/orcl/users01.dbf
8 /mezi/oracle/app_11R1/oradata/orcl/undo1.dbf
*************************************************************************************************************************************************
5)使用 dbms_backup_restore 来恢复
**************************************************************************************************************************************************
DECLARE
devtype varchar2(256);
done boolean;
BEGIN
devtype:=sys.dbms_backup_restore.deviceAllocate (type=>'',ident=>'t1');
sys.dbms_backup_restore.restoreSetDatafile;
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>1,toname=>'/db/mezi/oracle/app/oradata/orcl/system01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>2,toname=>'/db/mezi/oracle/app/oradata/orcl/sysaux01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>3,toname=>'/db/mezi/oracle/app/oradata/orcl/undo.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>4,toname=>'/db/mezi/oracle/app/oradata/orcl/dfdata01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>5,toname=>'/db/mezi/oracle/app/oradata/orcl/indx01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>6,toname=>'/db/mezi/oracle/app/oradata/orcl/tools01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>7,toname=>'/db/mezi/oracle/app/oradata/orcl/users01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>8,toname=>'/db/mezi/oracle/app/oradata/orcl/undo1.dbfF');
sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/db/sshan_temp/ORCL_6.dbf', params=>null);
sys.dbms_backup_restore.deviceDeallocate;
END;
/
**************************************************************************************************************************************************
余下的收尾工作:
SQL>recover database using backup controlfile until cacnel;
根据提示,数据原始数据库的一个archivelog文件名称
SQL>alter database rename datafile '/xxx/xxx/xxx.dbf' to '/xxx/xxx/xxx/xx/xx.dbf'; //修改控制文件中的数据文件路径
SQL>alter database rename datafile '/xx/xx/xx/xxlog.dbf' to '/xx/xxx/xx/xx/xx.dbf'; //修改控制文件中的redo Log 路径
(参考:http://zhouwf0726.itpub.net/post/9689/244764)
1)在原始数据库上:
RMAN>CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN>backup database format='/mezi/oracle/app_11R1/rman_backup/%d_%s.dbf'
//将会生成两个文件,controlfile和数据库
2)将rman 生成的两个文件拷贝到远程服务器的目录: /db/sshan_temp/
将原始数据库的初始化参数文件拷贝到目标服务器:$ORACLE_HOME/dbs/
并修改相关目录:如controlfile目录和dump目录
3)恢复controlfile 文件
SQL>startup nomount;
#./rman target /
RMAN>restore controlfile from '/db/sshan_temp/ORCL_7.dbf';
4)恢复数据文件
RMAN>restore database from '/db/sshan_temp/ORCL_6.dbf';
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 04/09/2008 14:15:17
RMAN-06509: only SPFILE or controlfile can be restored from autobackup
RMAN>list backup;
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 21.00G DISK 00:07:34 01-JUL-11
BP Key: 3 Status: EXPIRED Compressed: NO Tag: TAG20110701T045821
Piece Name: /mezi/oracle/app_11R1/rman_backup/ORCL_6.dbf
由于没有相关权限,所以无法创建和原始数据库一样的rman备份目录。
**************************************************************************************************************************************************
查看控制文件中数据文件列表:
SQL>select name from v$datafile;
FILE# NAME
---------- --------------------------------------------------
1 /mezi/oracle/app_11R1/oradata/orcl/system01.dbf
2 /mezi/oracle/app_11R1/oradata/orcl/sysaux01.dbf
3 /mezi/oracle/app_11R1/oradata/orcl/undo.dbf
4 /mezi/oracle/app_11R1/oradata/orcl/dfdata01.dbf
5 /mezi/oracle/app_11R1/oradata/orcl/indx01.dbf
6 /mezi/oracle/app_11R1/oradata/orcl/tools01.dbf
7 /mezi/oracle/app_11R1/oradata/orcl/users01.dbf
8 /mezi/oracle/app_11R1/oradata/orcl/undo1.dbf
*************************************************************************************************************************************************
5)使用 dbms_backup_restore 来恢复
**************************************************************************************************************************************************
DECLARE
devtype varchar2(256);
done boolean;
BEGIN
devtype:=sys.dbms_backup_restore.deviceAllocate (type=>'',ident=>'t1');
sys.dbms_backup_restore.restoreSetDatafile;
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>1,toname=>'/db/mezi/oracle/app/oradata/orcl/system01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>2,toname=>'/db/mezi/oracle/app/oradata/orcl/sysaux01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>3,toname=>'/db/mezi/oracle/app/oradata/orcl/undo.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>4,toname=>'/db/mezi/oracle/app/oradata/orcl/dfdata01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>5,toname=>'/db/mezi/oracle/app/oradata/orcl/indx01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>6,toname=>'/db/mezi/oracle/app/oradata/orcl/tools01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>7,toname=>'/db/mezi/oracle/app/oradata/orcl/users01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>8,toname=>'/db/mezi/oracle/app/oradata/orcl/undo1.dbfF');
sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/db/sshan_temp/ORCL_6.dbf', params=>null);
sys.dbms_backup_restore.deviceDeallocate;
END;
/
**************************************************************************************************************************************************
余下的收尾工作:
SQL>recover database using backup controlfile until cacnel;
根据提示,数据原始数据库的一个archivelog文件名称
SQL>alter database rename datafile '/xxx/xxx/xxx.dbf' to '/xxx/xxx/xxx/xx/xx.dbf'; //修改控制文件中的数据文件路径
SQL>alter database rename datafile '/xx/xx/xx/xxlog.dbf' to '/xx/xxx/xx/xx/xx.dbf'; //修改控制文件中的redo Log 路径
/*
这里或者在备库的pfile里做修改:
修改init*.ora文件
//改控制文件位置:
*.control_files='/disk1/oradata/crmdb/controlstby01.ctl','/disk1/oradata/crmdb/controlstby02.ctl'
//归档日志位置
*.log_archive_dest='/disk1/oradata/crmdb/arch'
//修改DBF文件,LOG文件的地址(如果路径一样,就不要改了)
*.db_file_name_convert=('/data/oradata/crmdb/','/disk1/oradata/crmdb/')
*.log_file_name_convert=('/data/oradata/crmdb/','/disk1/oradata/crmdb/')
//改控制文件位置:
*.control_files='/disk1/oradata/crmdb/controlstby01.ctl','/disk1/oradata/crmdb/controlstby02.ctl'
//归档日志位置
*.log_archive_dest='/disk1/oradata/crmdb/arch'
//修改DBF文件,LOG文件的地址(如果路径一样,就不要改了)
*.db_file_name_convert=('/data/oradata/crmdb/','/disk1/oradata/crmdb/')
*.log_file_name_convert=('/data/oradata/crmdb/','/disk1/oradata/crmdb/')
*/
SQL>alter database open resetlogs;